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

#
#	gmake Makefile for libfu.a
#
include ${DEPTROOT}/etc/gmake.init
#
#	The definitions below use ":=" instead of "=".  This form
#	of definition is slightly easier to process and understand
#	and is safe if each definition includes only previously defined
#	variables (or none at all).  When in doubt, use the old "=".
#
#	fortran compiler flags: for now, wrap cray2 flags in -CRAY ... -ALL
#
FFlags		:=	-O
sunFCFlags	:=	${sunFCFlags} -u
crayFCFlags	:=	${crayFCFlags} -Wf"-astack" -DCRAY
RS6000FCFlags   :=      -D_IBMR2 -nodoc -qxflag=hsflt -qcharlen=8192
hpFCFlags       :=      ${hpFCFlags} -u -O2 -nodoc
convexFCFlags	:=	-O2 -re -pa
#
#	C compiler flags: same on all machines
#
CFLAGS		:=	-O
convexCFLAGS	:=	-O2 -re -pa

ifneq "${FLD}" "pgf77"
intelLibes += -lU77
endif
Libes	:= 
Libes	:=	${Libes} ${${Vendor}Libes} ${${TArchDir}Libes}
#
#	This is the guy we're trying to make.  Note that the
#	target is a function of the target architecture.
#
# LocalLib := .
LIB		:=	${LocalLib}/libfu.a
#
#	These are the C source files that go into ${LIB}
#
ifeq "${Vendor}" "convex" 
CSrcs		:=	abortfu.c	ciofu.c		exitfu.c \
			forkfu.c	getenvfu.c	isenvfu.c \
			putenvfu.c	systemfu.c	\
			u0ewrt.c	u0f2cstr.c \
			u0stodpr.c	waitfu.c	epsubs.c \
			u0argvv.c	u0argcc.c \
			gethostfu.c
else
ifeq "${Vendor}" "NCP" 
CSrcs		:=	abortfu.c	ciofu.c		exitfu.c \
			forkfu.c	getenvfu.c	isenvfu.c \
			putenvfu.c	systemfu.c	\
			u0ewrt.c	u0f2cstr.c \
			u0stodpr.c	waitfu.c	\
			u0argvv.c	u0argcc.c \
			gethostfu.c
else
CSrcs		:=	abortfu.c	ciofu.c		exitfu.c \
			forkfu.c	getenvfu.c	isenvfu.c \
			putenvfu.c	systemfu.c	\
			u0ewrt.c	u0f2cstr.c \
			u0stodpr.c	waitfu.c	epsubs.c \
			u0argvv.c	u0argcc.c \
			gethostfu.c
endif
endif

# I removed these and substituted fargsv.c and fargsys.c, which interface to
# the C argument handling routines in libcu.a
#
#			fargsys.c	fargsv.c

#
#	These are the F8x source files that go into ${LIB}.
#	cf8x files would also go in this list.
#
F77Srcs		:=	alloclun.F	\
			cfatal.F	efatal.F	freelun.F \
			isdouble.F	\
			isint.F	isreal.F	lunsleft.F \
			nblen.F	nfatal.F	\
			u0flcm.F	\
			arg0.F	argeat.F 	\
			argfre.F	argi4.F	argis.F \
			argr4.F	argr8.F	argstr.F \
			iargcc.F	u0argadm.F	u0arlc.F \
			sargvv.F getname.F xtrarg.F

SafeFiles	:=	${AllSrcs} argtester.F Makefile ${wildcard *.h}

#
#	This is the target.  It's also the default target because
#	it's the first target.
#
targets:	${LIB} test

${LIB}:	${AllObjs}
	${AR} rv ${LIB} $?
	${RANLIB} ${LIB}

.PHONY: safe all remotes targets

all:	safe ${LIB} remotes

test: ${TArchDir}/argtester.o
	${LinkF} -o ./argtest $< ${LIB} ${Libes}
	./argtest -i4 1 -r4 2. -r8 3. -V -str test
	-rm argtest
#
#	Send changed source (and make) files to the Cray and
#	rebuild the default target.  (Another reason to choose
#	the default target wisely.)
#
remotes:	RemoteCopies RemoteMakes

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

RemoteMakes:	${SafeFiles}
	shadowexec -v ${MAKE}
	touch RemoteMakes
#
#	"gmake safe" makes a hidden archive of all of the source files
#	and Makefile.  The archive is named .safe and its write permissions
#	are all turned off.  Note that "rm -f" will still zap it.  (We
#	probably should be putting safe archives somewhere else.
#
safe:	.safe.${jdate}.Z

.safe.${jdate}.Z:	${SafeFiles}
	${MakeSafe}
#
#	'included.files' contains the automatically formed list
#	of '.h' files used by all of the source files.  It should
#	be included -after- the default target has been specified.
#
include ${TArchDir}/included.files
#
#	How to recreate the list of include files if any of the
#	source has been changed.
#
${TArchDir}/included.files: ${AllSrcs}
	${FindIncludes}
#
#	Causes the library to be rebuilt from source.  Sometimes
#	useful if you change compiler options, etc.
#
anew:
	-rm -f ${LIB} ${AllObjs}
	gmake ${LIB}
#
#	Generate new listings for changed source files.
#
#	These targets use a script (prettyp) which must be
#	in your PATH.
#
listing:
	make listingc
	make listingc8x

listingc:	${CSrcs} Makefile
	prettyp -lc $?
	touch listingc

listingc8x:	${F8xSrcs}
	prettyp -lcf8x $?
	touch listingc8x

clean:
	-rm ${TArchDir}/included.files ${AllObjs} ${TArchDir}/argtester.o \
	RemoteCopies RemoteMakes ${LIB}
