# $Header:Makefile_ca 12.0$ 
# $ACIS:Makefile_ca 12.0$ 
# $Source: /ibm/acis/usr/src/usr.lib/RCS/Makefile_ca,v $ 

#
# 5799-WZQ (C) COPYRIGHT = NONE
# LICENSED MATERIALS - PROPERTY OF IBM
#
#
# Copyright (c) 1983 Regents of the University of California.
# All rights reserved.  The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
#	@(#)Makefile	5.10 (Berkeley) 6/7/86
#
DESTDIR=
CFLAGS=	-O
TAGSFILE=tags

# Subdirectories whose routines are included in the making of the
# master tags file (/usr/lib/tags); the Fortran libraries should
# be on this list, but we don't control them....
#
TAGSDIR=libcurses libdbm libln libm libmp libpc libtermlib librpcsvc

# Programs that live in subdirectories, and have makefiles of their own.
#
# NOTYET SUBDIR=	lib2648 
# NOTYET libpc
# NOTYET SUBDIR=	libom	# Ship it, but do not make it.
SUBDIR=	font learn libaed libcurses libdbm libfp libg \
	libF77 libI77 libU77 libln \
	libm libmp libplot libtermlib liby lpr man me ms sendmail \
	librpcsvc

# Shell scripts that need only be installed and are never removed.
#
SCRIPT=	makewhatis

# C programs that live in the current directory and do not need
# explicit make lines.
#
STD=	getNAME makekey

# C programs that live in the current directory and need explicit make lines.
#
NSTD=	

all:	${SUBDIR} ${STD} ${NSTD}

LINKS:
	-ln -s /sys/rpcsvc librpcsvc

${SUBDIR}: FRC LINKS
	cd $@; make ${MFLAGS}

FRC:

${STD}:
	${CC} ${CFLAGS} -o $@ $@.c

install: $(DESTDIR)/usr/lib all
	for i in ${SUBDIR}; do \
		(cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install); done
	for i in ${SCRIPT}; do (install -c $$i.sh ${DESTDIR}/usr/lib/$$i); done
	for i in ${SCRIPT}; do (sh ./$$i.sh); done	# create whatis data base.
	for i in ${STD} ${NSTD}; do (install -c -s $$i ${DESTDIR}/usr/lib/$$i); done
	install -c lib.b ${DESTDIR}/usr/lib/lib.b
	install -c eign ${DESTDIR}/usr/lib/eign
	chmod 444 ${DESTDIR}/usr/lib/eign

$(DESTDIR)/usr/lib:
	mkdir $(DESTDIR)/usr/lib

installdatafiles:
	install -c -m 444 crontab ${DESTDIR}/usr/lib/crontab
#	cd sendmail/lib; make ${MFLAGS} DESTDIR=${DESTDIR} installdatafiles
#	cd adb; make ${MFLAGS} DESTDIR=${DESTDIR} install

clean:
	rm -f a.out core *.s *.o tags
	for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} clean); done
	rm -f ${STD} ${NSTD}

depend:
	for i in ${STD} ${NSTD}; do \
	    ${CC} -M ${INCPATH} ${CFLAGS} $$i.c | sed 's/\.o//' | \
	    awk ' { if ($$1 != prev) \
		{ if (rec != "") print rec; rec = $$0; prev = $$1; } \
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
		else rec = rec " " $$2 } } \
		END { print rec } ' >> makedep; done
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile

tags: LINKS
	-for i in ${TAGSDIR}; do \
		(cd $$i; make ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \
	done


# Files listed in ${NSTD} have explicit make lines given below.

# DO NOT DELETE THIS LINE -- make depend uses it

getNAME: getNAME.c /usr/include/strings.h /usr/include/stdio.h
makekey: makekey.c
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
