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

#
#	gmake for libcu.a
#
#	presume lint is architecture dependent.
#
include ${DEPTROOT}/etc/gmake.init

CFlags		:=	${CFlags} -O
# CFlags		:=	${CFlags} -g
sun4cg92CCFlags	:=	${sun4cg92CCFlags} -O -DNEED_GETDTABLESIZE
sun4cg92-SC4CCFlags	:=	${sun4cg92-SC4CCFlags} -O -DNEED_GETDTABLESIZE
convexCFlags	:=	${convexCFlags} -O2 -re -pa
LINTFLAGS	:=	${LINTFLAGS} -a -u ${CIncludes}

LIB		:=	$(LocalLib)/libcu.a
LINTLIB		:=	$(LocalLib)/llib-lcu.ln

CSrcs		:=	progname.c efopen.c cumalloc.c cuerror.c lists.c \
			allocstr.c dlist.c whereami.c elapsedtime.c	\
			nmprintf.c cumsg.c argsys.c is_a_pipe.c fppar.c \
			getdtablesize.c bcopy.c bzero.c

Hs		:=	listdefs.h

SafeFiles	:=	${CSrcs} Makefile ${wildcard *.h}

LINTS		:=	${CSrcs:%.c=${TArchDir}/%.ln}

#
#	the dummy target must be first to get ${RANLIB} run properly.
#
${LIB}:	${CObjs}
	${AR} rv ${LIB} $?
	${RANLIB} $(LIB)

.PHONY: all safe remotes targets

targets:	${LIB}

all:	safe ${LIB} remotes

include ${TArchDir}/included.files

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

${TArchDir}/%.ln:	%.c
	lint -c $(LINTFLAGS) -o $@ $<

#
#	BAD KLUDGE:  lint doesn't seem to honor -o sun?/file.ln
#
${TArchDir}.lint:	$(LINTS)
		mv *.ln ${TArchDir}
		touch ${TArchDir}.lint

lint:
	make ${TArchDir}.lint

lintlib: lint ${LINTLIB}

${LINTLIB}: ${LINTS}
	lint $(LINTFLAGS) -o tmp $(LINTS)
	mv llib-ltmp.ln $(LINTLIB)

anew:
	-rm -f $(LIB)
	make $(LIB)

.PHONY: safe
safe:	.safe.${jdate}.Z

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

listing: makefile $(HS) $(SOURCES)
	prettyt -lc $?
	touch listing

.PHONY:	remotes
remotes: RemoteCopies RemoteMakes

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

RemoteMakes:	${SafeFiles}
	shadowexec gmake &&  touch RemoteMakes

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