🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by David Herron -- One of the verte... Mon, 20 Mar 1989 20:33
make depend script for SysV
#991
Author: David Herron -- One of the verte...
Date: Mon, 20 Mar 1989 20:33
15 lines
878 bytes
I just came up with a make depend script for use on System V
and other systems whose cc/cpp gives the following two flags:

	-E	Run cpp only
	-H	print on stderr a list of included files.

With suitable munging this works fine in the MMDF sources.


Is anybody interested in having this??
-- 
<-- David Herron; an MMDF guy                              <david@ms.uky.edu>
<-- ska: David le casse\*'      {rutgers,uunet}!ukma!david, david@UKMA.BITNET
<-- 
<-- The problem with mnemonics is they mean different things to different people.
Re: make depend script for SysV
#992
Author: David Herron -- One of the verte...
Date: Fri, 24 Mar 1989 21:50
103 lines
4723 bytes
In article <11300@s.ms.uky.edu>, david@ms.uky.edu (David Herron -- One of the vertebrae) writes:
> I just came up with a make depend script for use on System V
> and other systems whose cc/cpp gives the following two flags:

Well, a buncha people asked for it so here it is ... The following is the make depend
from my working copy of MMDF.  (MMDF users, this will be 'official' shortly :-)).
The uncommented sections are what I am using right now on a ATT6386 with SysVr3.2
to which I'm porting MMDF.

The idea is to run "cc -E -H" and munge the output of that to be "file.o: the-include-file"
and feed that into a duplicate of the original awk script written on cc -M sites.
Output from cc -E -H is:

	stdout:		the result from cpp on the source file
	stderr:		any error messages go here as does a list of included files.
			the included files are output one per line.

I throw stdout to /dev/null and massage stderr with an awk script which either
munges an included file to "file.o: the-include-file" or prints an error message
on /dev/tty.  Hopefully there won't be any error messages.

A kudo.  In the middle of the script I "rm -f $$i.deps $$i.out".  "$$i.out" isn't
used anylonger but was there during my debugging.

Originally this scripthad the "-M" hard coded, but since the Ultrix people changed it
to be "-Em" I introduced the "THE_M_FLAG" business.


Finally, I don't claim any ownership over this.  I've seen these same scripts
floating around in many a Makefile.  I *hope* that everybody puts these to use
in their own Makefile's.  I'd like to know if someone can clean this up any.



#
#  #include dependencies
#
#  Two versions are supplied.  One for sites with cc -M (4.3BSD)
#  and one for those that don't have it.  Comment out the one
#  you do not want.

#  This one is for sites without cc -M
# depend:
# 	cat </dev/null >x.c
# 	for i in $(MODULES); do \
# 		(echo $$i.o: $$i.c >>makedep; \
# 		grep '^#[ 	]*include' x.c $$i.c | sed \
# 			-e 's,c:[^"]*"\./\([^"]*\)".*,o: \1,' \
# 			-e 's,c:[^"]*"/\([^"]*\)".*,o: /\1,' \
# 			-e 's,c:[^"]*"\([^"]*\)".*,o: ../../h/\1,' \
# 			-e 's,c:[^<]*<\(.*\)>.*,o: /usr/include/\1,' \
# 			>>makedep); done
# 	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
# 	echo '$$r makedep' >>eddep
# 	echo 'w' >>eddep
# 	cp Makefile.real Makefile.bak
# 	ed - Makefile.real < eddep
# 	rm eddep makedep x.c
# 	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.real
# 	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.real
# 	echo '# see make depend above' >> Makefile.real

THE_M_FLAG= -E -H

#  This one is for sites with cc -M
depend:
# 	( for i in ${MODULES} ; do \
# 		${CC} ${THE_M_FLAG} ${CFLAGS} $$i.c ; done ) | \
# 	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
	( for i in ${MODULES} ; do \
		echo $$i >/tmp/curfile; echo "$$i.o: $$i.c" ; \
		${CC} ${THE_M_FLAG} ${CFLAGS} $$i.c >/dev/null 2>$$i.deps; \
		awk <$$i.deps 'NF > 1 { print >"/dev/tty"; next } \
			{print "'`cat /tmp/curfile`'.o: " $$1}' ; \
		rm -f $$i.deps $$i.out; done ) | \
	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
#		awk 'NF == 2 { file = $$2; next } \
#		     NF == 1 { if (length(rec) == 0) { rec = file ".o: " } \
#				if (length(rec $$1) > 70) { \
#					print rec $$1; rec = "" } else { \
#					rec = rec " " $$1 } \
#				}'; done ) >makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile.real Makefile.bak
	ed - Makefile.real < eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.real
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.real
	echo '# see make depend above' >> Makefile.real

-- 
<- David Herron; an MMDF guy                              <david@ms.uky.edu>
<- ska: David le casse\*'      {rutgers,uunet}!ukma!david, david@UKMA.BITNET
<- 
<- The problem with mnemonics is they mean different things to different people.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads