At 04:58 PM 1/15/2003 -0500, Paul D. Smith wrote:
Good question. I guess I shouldn't have said 'gcc -M deficiencies'%% gk <[EMAIL PROTECTED]> writes:g> Since gcc -M only returns prerequisite files included with #include g> directive, it cannot list prerequisite files accessed by fopen(), g> etc. Why in the world would you want to recompile a C file because a file that it fopen()s had changed?
I didn't mean to imply that gcc -M SHOULD include any other files, just that there is a need of some way to determine additional prerequisites of the OUTPUT sometimes.
Sometimes if foo.o is part of a chain of makefile rules, the output target that depends on foo.o needs to know what files the OUTPUT of foo.o depends on.
Strictly speaking foo.o does not depend on a file opened by fopen(), but the OUTPUT that is produced by executing foo.o may depend on the files used, which could be determinable automatically if foo.c 'registered' the files it's output depends on, as in my PHP example in previous post.
I think perhaps the answer to my question is to build the functionality I'm seeking into foo.o
But this imposes requires foo.c to process options, which isn't always what I want:
$foo.o -M
foo.txt
Simple example:
'foo.c' reads a file 'foo.txt' and writes the contents to /dev/stdout
'foo.o' outputs the contents of file: 'foo.txt'
# makefile
.PHONY: result
CC=gcc
# Command to generate a list of dependencies from a source file (including the source file)
# $(1) - source file
# remove the leading 'outputFile.o :'
define prerequisites
$(filter-out \,$(patsubst %:,,$(shell $(CC) -M $(1))))
endef
# IS THE THE ANSWER?
# $(1) - binary file
define get_prerequisites
$(1) -M
endef
foo.result: foo.o $(call get_prerequisites,foo.o)
@$< > $@
foo.o: $(call prerequisites,foo.c)
$(CC) -o $@ $<
# eof
- Greg Keraunen
http://www.xmake.org
http://www.xmlmake.com
_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make
