make depend

Guy Harris guy at rlgvax.UUCP
Sat Mar 9 17:45:26 AEST 1985


> I just wanted  to mention that ATT's Unix Toolchest, which allows you to
> sign up for software which is delivered electronically, provies a tool
> call "makefile", which will read through your software in the current
> directory, and generate a makefile for you.  If there is a makefile there,
> it will keep any comments you had when it produces the new one.  It is
> available (source!) for a reasonable price, only $95.

For what it's worth, the following, courtesy of the University of California
at Berkeley (or whoever did it first) will do much the same, if you have
"/lib/cpp -M" (or its equivalent; somebody posted a script that filtered
the output of a regular "cpp" to produce dependencies):

	depend:
		for i in ${SOURCES}; do \
			/lib/cpp -M $$i >>makedep; \
		done
		echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
		echo '.kb' >>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

if you stick

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

and two blank lines after it at the end of your Makefile, and if you
have ${SOURCES} as a macro which expands to the names of all your source
files.


-- 
	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list