########################################################################
#                 copyright 2001, Amoco Production Company             #
#                             All Rights Reserved                      #
#                     an affiliate of BP America Inc.                  #
########################################################################

include ${DEPTROOT}/usp/etc/gmake.init
include ${DEPTROOT}/etc/gmake.mathadv

Libes		:= ${MathAdvO} -lut -lieeeio -lfu -lm
sun4cg92Libes   := ${sun4cg92Libes} -Bdynamic -ldl -Bstatic
sun4cg92-SC4Libes   := ${sun4cg92-SC4Libes} -Bdynamic -ldl -Bstatic
sun4uLibes    := ${sun4uLibes} -Bdynamic -ldl -Bstatic
sun4u-SC4Libes    := ${sun4u-SC4Libes} -Bdynamic -ldl -Bstatic
Libes   :=      ${Libes} ${${Vendor}Libes} ${${TArchDir}Libes}

sun4CCFlags	:=	${sun4CCFlags} -D _NO_PROTO
cray2CCFlags	:=	${cray2CCFlags} -D_NO_PROTO
crayxeaCCFlags  :=	${crayxeaCCFlags} -D_NO_PROTO
crayc90CCFlags  :=	${crayc90CCFlags} -D_NO_PROTO
crayympCCFlags  :=	${crayympCCFlags} -D_NO_PROTO
crayj90CCFlags  :=	${crayj90CCFlags} -DCRAY -DCRAYJ90 -D _NO_PROTO
hpCCFlags       :=      ${hpCCFlags} -D_hpux -O -Wp,-H500000
sgiCCFlags      :=      ${sgiCCFlags} -O3

sun4FCFlags	:=	${sun4FCFlags} -DSUN -O -nodoc
cray2FCFlags	:=	${cray2FCFlags} -DCRAY -DCRAY2 -Wf"-astack" -Wf"-es" -Wf"-dp"
crayxeaFCFlags	:=	${crayxeaFCFlags} -DCRAY -DCRAYXEA -Wf"-eus" -Wf"-dp"
crayc90FCFlags	:=	${crayc90FCFlags} -DCRAY -DCRAYC90 -Wf"-eus" -Wf"-dp"
crayympFCFlags	:=	${crayympFCFlags} -DCRAY -DCRAYYMP -Wf"-eus" -Wf"-dp"
crayj90FCFlags  :=      ${crayj90FCFlags} -DCRAY -DCRAYJ90 -Wf"-eus" -Wf"-dp"

hpFCFlags       :=      ${hpFCFlags} -D_hpux -O +e
hpFLFlags       :=      ${hpFLFlags} +U77 -D_hpux +e
rs6000CCFlags   :=      ${rs6000CCFlags} -D_IBMR2 -O
rs6000FCFlags   :=      ${rs6000FCFlags} -D_IBMR2 -O -nodoc -qxflag=hsflt
convexCCFlags   :=	${convexCCFlags} -D__convex__ -O2 -re
convexFCFlags   :=	${convexFCFlags} -D__convex__ -O2 -re
sgiFCFlags      :=      ${sgiFCFlags} -O3 -DIRIX -OPT:const_copy_limit=14667 \
			-OPT:fold_arith_limit=2711

sun4cg89FCFlags :=      ${sun4cg89FCFlags} -fast -O4 -cg89
sun4cg89FLFlags :=      ${sun4cg89FLFlags} -fast -O4

sun4cg92FCFlags :=      ${sun4cg92FCFlags} -fast -O4 -cg92
sun4cg92FLFlags :=      ${sun4cg92FLFlags} -fast -O4

c2mpLibes       :=      ${c2mpLibes} -lveclib

CSrcs		:= 
F77Srcs         :=      lsqrmod.F		\
                        mainsub.F	\
			minimizer.F     \
                        forward.F       \
                        backward.F      \
                        putzero.F       \
                        erreur.F        \
                        rdparm.F        \
                        cmdlin.F        \
                        lnst.F          \
                        int2str.F       \
                        int_to_str.F    \
                        real_to_str.F   \
                        linear.F        \
                        linear2.F       \
                        norm.F          \
                        normdata.F      \
                        movebis.F       \
                        readrestart.F   \
                        writerestart.F  \
                        info.F          \
                        remove.F        \
                        putcmdlin.F     \
                        test.F          \
                        callsys.F       \
                        copy.F


SafeFiles	:= ${AllSrcs} Makefile

PRGM		:= ${LocalBin}/lsqrmod

targets : ${PRGM}

all :  safe clean targets install remotes

${PRGM}    :  ${F77Objs} ${CObjs}
	${LinkF} -o $@ ${AllObjs} ${Libes} ${LibFtn${TArchDir}}

install:
	mancopy 1 lsqrmod
	execopy  lsqrmod
	shadowexec -v ${MAKE} install

remotes:	RemoteCopies RemoteMakes

RemoteCopies:	${SafeFiles}
	shadowcopy -v $? && touch RemoteCopies

RemoteMakes:	${SafeFiles}
	shadowexec -v ${MAKE} && touch RemoteMakes

safe:	.safe.${jdate}.Z

.safe.${jdate}.Z:	${SafeFiles}
	${MakeSafe}

include ${TArchDir}/included.files

${TArchDir}/included.files: ${AllSrcs}
	usp_d_stamp
	${FindIncludes}

clean:
	-rm ${TArchDir}/included.files ${AllObjs} ${PRGM} date.h RemoteCopies RemoteMakes ${wildcard ShdCpy*}
