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

#
#	libut
#
include	${DEPTROOT}/usp/etc/gmake.init
include	${DEPTROOT}/etc/gmake.usp
include	${DEPTROOT}/etc/gmake.as

sun3CCFlags	:=	${sun3CCFlags} -DSUN -O
sun3fpaCCFlags	:=	${sun3fpaCCFlags} -DSUN -ffpa -O
sun4CCFlags	:=	${sun4CCFlags} -DSUN -O
crayCCFlags	:=	${crayCCFlags} -DCRAY
convexCCFlags	:=	${convexCCFlags} -re -O2 -pa

sgiFCFlags	:=	${sgiCCFlags} -OPT:fold_arith_limit=1500
sun3FCFlags	:=	${sun3FCFlags} -DSUN -O
sun3fpaFCFlags	:=	${sun3fpaFCFlags} -DSUN -ffpa -O
sun4FCFlags	:=	${sun4FCFlags} -DSUN -O
cray2FCFlags	:=	${cray2FCFlags} -Wf"-eP"
cray2CCFlags	:=	${cray2CCFlags} -h pagelm
crayFCFlags	:=	${crayFCFlags} -DCRAY -Wf"-i64" -Wf"-dp" -Wf"-astack"
convexCCFlags	:=	${convexCCFlags} -re -O2 -pa

LIB		:=	${LocalLib}/libut.a
LIBLINK		:=	${LocalLib}/libusp_ut.a

CSrcs		:=	GETPPS.c STOINT.c STOFLT.c fcsub.c ctoint.c  \
			inttoc.c move.c save.c get_c_string.c pipcnt.c \
			gtime.c galloc.c grealloc.c gcalloc.c gfree.c \
			timer.c mod.c shwhed.c qform.c getreal.c \
			hlh_utils.c getrin.c ikpchk.c sscanf.c ludsk.c \
			lutty.c pipchk.c csissub.c csave.c savchk.c \
			getsize.c gethlh.c \
			float_to_ibm.c ibm_to_float.c

# gettims.c

cray2ASrcs	:=	craymfold.S

ASrcs		:=	${${TArchDir}ASrcs}

sunF77Srcs	:=	sunmfold.F
convexF77Srcs	:=	sunmfold.F
hpF77Srcs	:=	sunmfold.F
ibmF77Srcs	:=	sunmfold.F
sgiF77Srcs	:=	sunmfold.F

F77Srcs		:=	acctid.F butt.F dagc.F dagr.F fold.F \
			four.F vmult.F fsissub.F gamoco.F geocode.F  \
			geostuff.F hlhut.F  hlhprt.F  \
			multisub.F pwrof2.F gain.F filter.F  \
			revers.F filco.F icopen.F lenth.F lenthr.F secon1.F  \
			openpr.F opnlst.F cross.F cross0.F dot.F eurekb.F \
			smooth.F shape.F ordfft.F daopen.F \
			acct.F riprnt.f wrcard.f sortx.F median.F mdian2.F \
			convert.F parse.F mapmem.F timstr.F \
			timend.F rdsis.F  prmmlt.F powerp.F \
			gttapr.F detmut.F resmut.F seisflush.F \
			SmoothFit.F minmax.F realft.F four1.F fits.F fit.F HEAPSORT.F \
			getsmpint.F mutdet.F mutres.F \
			Polynomial.F \
			${${Vendor}F77Srcs}

SafeFiles	:=	${CSrcs} ${F77Srcs} ${ASrcs} \
			${sunF77Srcs} ${cray2ASrcs} Makefile

${LIB}:  ${CObjs} ${F77Objs} ${AObjs}
	rm -f ${LIB}
	${AR} r ${LIB} ${CObjs} ${F77Objs} ${AObjs}
	test -h ${LIBLINK} || (cd ${DEPTROOT}/usp/lib/${TArchDir} ; ln -s libut.a libusp_ut.a)
	${RANLIB} ${LIB}

.PHONY:	all remotes safe targets

targets:	${LIB}

all :	safe targets remotes

remotes:	RemoteCopies RemoteMakes

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

RemoteMakes:	${SafeFiles}
	shadowexec ${MAKE}
	touch RemoteMakes

include	${TArchDir}/included.files

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

safe:	.safe.${jdate}.Z

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

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