On Wed, Sep 23, 2015 at 12:57 PM, John Westing <john.blank.west...@gmail.com > wrote:
> I made a typo in my previous email: The following make file duplicates the > problem, the one in the previous email does not: > > a.d: > gcc -m32 -MM -o $@ a.c > sed 's!a.o!$@ a.o!' --in-place $@ > > a.o: > gcc -c -m32 -o $@ a.c > > all: a.d a.o > > -include a.d > > > See: https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html#Remaking-Makefiles Specifically, after reading all the Makefiles (like "a.d", since it's included), if any of them need to be rebuilt, it will be updated and then make re-executes itself. You can get a clue that this is happening by adding $(info Starting make) or something at the top of your Makefile. Then you'll see: Starting make gcc -m32 -MM -o a.d a.c sed 's!a.o!a.d a.o!' --in-place a.d Starting make make: 'a.d' is up to date. So make runs, sees that a.d needs to be updated, updates it automatically, restarts, re-reads all the Makfiles, and now it tries to build 'a.d' since you specified that as a target. Though normally you don't want to include .d files as targets in your Makefile. Just generate them as a side-effect of compilation with -MMD or whatever in gcc and then include them, and you can avoid the whole issue. -Mike
_______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make