# Make file for the research project
#
# $Header: makefile,v 1.1 87/03/31 08:57:26 tsay Exp $
# $Source: /oc/kuh/tsay/RESEARCH/PROUD/RCS/makefile,v $
#

CFILES	= proud.c

COBJS 	= proud.o

SUBCOBJS = gp/*.o dp/*.o input/*.o output/*.o 

OCTCOBJS = gp/*.o dp/*.o input/*.o output/*.o

ALLBELLS = gp/bell dp/bell input/bell output/bell

#OCTBELLS = IOPA/bell GPGR/bell DPDR/bell INPUT/bell OCT/bell

HFILES = include/prdef.h include/prstr.h

TARGET  = proud

ALL: .DO_THIS_FIRST ${TARGET}

SOURCE=	${HFILES} ${CFILES}
 
ALLFILES= ${SOURCE} makefile .pr

LINTFLAGS =
OCTLINTFLAGS = -I/users/cad/include

CFLAGS = -g -X ${LINTFLAGS}
OCTCFLAGS = ${CFLAGS} $(OCTLINTFLAGS)

LDFLAGS=

LIBS = -lm
OCTLIBS = /users/cad/lib/liboct.a ${LIBS}
OCTLINT = /users/cad/lib/llib-loct.ln

.c.o :
	cc ${CFLAGS} ${LIBS} -c $*.c

.DO_THIS_FIRST:
	cd gp;   make
	cd dp;   make
	cd input;  make
	cd output; make
	touch bell

${TARGET}: ${ALLBELLS} ${COBJS} 
	cc ${CFLAGS} -o ${TARGET} ${COBJS} ${SUBCOBJS}\
	${LDFLAGS} ${LIBS}

oct: ${OCTBELLS} ${COBJS} 
	cc ${OCTCFLAGS} -o ${TARGET} ${COBJS} ${OCTCOBJS}\
	${LDFLAGS} ${OCTLIBS}
	mv proud ../../cells/proud

lint:
	lint -hav ${CFILES} > lint.out
 
clean:
	-rm -f ${COBJS} 

lp: .pr
.pr: NONEXISTENT
	csh .pr ${SOURCE} makefile 
#	touch .pr
NONEXISTENT:
	echo force the make
 
get:
	sccs get ${SOURCE}
edit:
	sccs edit ${SOURCE}
ip:
	pr -f ${SOURCE} | lpr -Pkip &
 
depend: ${SOURCE}
	cd gp;   make depend
	cd dp;   make depend
	cd input;  make depend
	cd output; make depend
	grep	'^#include' ${CFILES}		| grep -v '<'		\
	| sed	's/:[^"]*"\([^"]*\)".*/: \1/'				\
	| sed	's/\.c/.o/' | sed 's,../[a-z]*/,,'			\
	| awk	' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; }\
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; }\
		else rec = rec " " $$2 } }				\
		END { print rec } '					\
	> makedep
#	grep	'^#include' ${HFILES}		| grep -v '<'		\
#	| sed	-e 's/:[^"]*"\([^"]*\)".*/: \1/p'			\
#		-e 's/\([^:]*\):.*/	$${TOUCH} \1/'			\
#	>> makedep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d'	>  eddep
	echo '$$r makedep'				>> eddep
	echo 'w'					>> eddep
	ed - < eddep makefile
	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

#-----------------------------------------------------------------
# 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
