Hello Experts & Experts,
I need to verify the method of automatic dependency generation.
My directory structure is nested:
TOP_DIR/
|-- Makefile
`-- src
`-- Makefile
I do make at TOP_DIR, and my .o files are generated with .c files in
SRC subdirectory.
What I have done is as follows:
%.d : %.c
@$(SET) -e; \
$(RM) $@; \
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
$(SED) 's,\($(notdir $*)\)\.o:,$*.o $@: ,g' < $@.$$$$ > $@; \
$(RM) $@.$$$$
Is my rule correct?
I need to do this, but as per the gnu documentation on web, I see that
the following is done:
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed s,\($*\)\.o[ :]*,\1.o $@ : ,g < $@.$$$$ > $@; \
rm -f $@.$$$$
I feel that the second is fundamentally wrong because:
1) It does not use notdir, and hence assumes that all my object files
are in the current directory.
2) looks for a pattern [ :]*, which is also not correct. It should
just be a plain ':'.
Any comments? OR Am I wrong?
Finally, this generates a dependency file in SRC sub directory. The
file is not hidden. If I have to make it hidden, what change will I
have to make in the rule? I tried writing the rule, but I was not
successful.
Regards,
Ajay
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make