# Makefile for /usr/doc/usd subdir's
#
# 	$Source: $
#	$Author: $
#	$Locker: $
#	$Header: $
DESTDIR=

# Programs that live in subdirectories, and have makefiles of their own.
#
SUBDIR= 01.begin 02.learn 03.shell 04.csh 05.dc 06.bc 07.Mail \
	08.mh 09.newsread 10.etiq 11.notes 12.edtut 13.edadv \
	14.edit 15.vi 16.ex 17.jove 18.sed 19.awk 20.msmacros \
	21.msdiffs 22.memacros 23.meref 24.troff 25.trofftut \
	26.eqn 27.eqnguide 28.tbl 29.refer 30.invert 31.bib \
	32.diction 33.rogue 34.trek 

# .PS and .LPT files that live in the current directory and need
# explicit make lines.
#
PS= 00.contents.PS
LPT= 00.contents.LPT

# location of nroff and troff
NROFF= nroff
TROFF= psroff -t

all:	${SUBDIR} ${PS} ${LPT}

${SUBDIR}: FRC
	cd $@; make NROFF=${NROFF} TROFF=${TROFF} ${MFLAGS} all; cd ..

${PS}: FRC
	for i in ${PS}; do \
	    base=`echo $$i | awk -F. '{printf "%s.%s\n", $$1, $$2}'`; \
	    (${TROFF} -ms $$base > $$i); \
	done

${LPT}: FRC
	for i in ${LPT}; do \
	    base=`echo $$i | awk -F. '{printf "%s.%s\n", $$1, $$2}'`; \
	    (${NROFF} -ms $$base > $$i); \
	done

FRC:

install:
	for i in ${SUBDIR}; do \
	    (cd $$i; make ${MFLAGS} DESTDIR=${DESTDIR} install; cd ..); done
	done
	for i in ${PS}; do \
	    (install -c -s $$i $(DESTDIR)/usr/doc/usd/$$i); \
	done
	for i in ${LPT}; do \
	    (install -c -s $$i $(DESTDIR)/usr/doc/usd/$$i); \
	done

clean:
	for i in ${SUBDIR}; do (cd $$i; make ${MFLAGS} clean; cd ..); done
	for i in ${PS}; do rm $$i; done
	for i in ${LPT}; do rm $$i; done

depend:
	cat </dev/null >x.c
	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 x.c
	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

# DO NOT DELETE THIS LINE -- make depend uses it
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
