make depend

Richard Draves draves at harvard.ARPA
Tue Feb 26 13:41:08 AEST 1985


I recently ran across an undocumented flag for cpp that makes the
following entry for makefiles convenient.  It automagically
updates file dependencies.  If your cpp doesn't have this
feature, or you don't like depending on undocumented features,
you can write you own shell script to accomplish the same thing.

	# This has only been tested on 4.2BSD

	CPP	=	/lib/cpp
	ED	=	/bin/ed
	CFILES	=	main.c

	depend	:
			{ echo '/^# DO NOT DELETE THIS LINE/+1,$$c';	\
			  for i in $(CFILES); do $(CPP) -M $$i; done;	\
			  echo '.';					\
			  echo 'w';					\
			} | $(ED) - Makefile

	# File Relationships
	# DO NOT DELETE THIS LINE -- make depends on it.
	# This line will be replaced by your file dependencies.

Rich
-- 

	"a picture in the head is a gory murder in an art gallery"

					-- Stephen Kosslyn



More information about the Comp.lang.c mailing list