Makefiles -- .c and .h

Steve Ralston sralston at srwic.UUCP
Tue Nov 20 18:50:51 AEST 1990


Of the many replies to this subject, I have not seen mention of the method
which I am currently using, namely:

	gcc -M file.c

For those without gcc, press the 'n' key:
According to the man page on gcc:

	  -M   Tell the	preprocessor to	output a rule suitable for
	       make(1) describing the dependencies of each source
	       file.  For each source file, the	preprocessor outputs
	       one make-rule whose target is the object	file name for
	       that source file	and whose dependencies are all the
	       files #included in it.  This rule may be	a single line
	       or may be continued with	\-newline if it	is long.

	       -M implies -E.

	  -E   Run only	the C preprocessor.  Preprocess	all the	C
	       source files specified and output the results to
	       standard	output.

It's not real difficult to incorporate this command right in your Makefile
(piping to sed, etc, or whatever) so that when you type something like:

	make depend

the dependency lists are recreated from scratch.
-- 
Steve Ralston						sralston at srwic.UUCP
235 N Zelta						voice: 316-686-2019
Wichita, KS 67206			..!uunet!ncrlnk!ncrwic!srwic!sralston



More information about the Comp.unix.programmer mailing list