[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with recompiling, when changing header files in C
From: |
Paul D. Smith |
Subject: |
Re: Problems with recompiling, when changing header files in C |
Date: |
Fri, 9 Mar 2001 11:07:56 -0500 |
%% Peter Biechele <address@hidden> writes:
pb> I create dependencies using .d files automatically uisng the gcc -M
feature
pb> I include the so created .d files using:
pb> -include $(C_SRC_FILES:.c=.d)
pb> -include $(ASS_SRC_FILES:.ss=.d)
I assume that in your makefile you're not really prefixing these lines
with a TAB, as you've done here, are you?
That would be Very Bad.
pb> Then if I change one of the c files everything works great.
pb> BUT if I change one of the header files, nothing gets recompiled !!!!!
pb> One of the .d files looks for example like this:
pb> - -------------------
pb> modTask.o modTask.d : aufsicht/modTask.c \
pb> include/hwdefs.h
pb> - -------------------
pb> If I change the file include/hwdefs.h, NOTHING gets recompiled !!!!
pb> I use rules like:
pb> - ----------------
pb> ## Rules to make the object files
pb> ##
pb> %.o : %.c $(ALL_MAKEFILES)
pb> @echo " **** Compiling file $< "
pb> $(CC) -c $(CFLAGS) $< -o $(OBJECT_DIR)/$(notdir $@)
pb> %.o : %.ss $(ALL_MAKEFILES)
pb> @echo " **** Compiling file $< "
pb> $(CC) -c $(CFLAGS) $< -o $(OBJECT_DIR)/$(notdir $@)
pb> - -----------------------
You don't show the line that references the .o's, but I bet it's
something like:
foo: $(patsubst %.c,$(OBJECT_DIR)/%.o,$(C_SRC_FILES))
Your problem is that you're breaking Paul's Second Rule of Makefiles
with your implicit %.o rules above. You _cannot_ use this method to put
object files in remote directories and have it work correctly.
This rule:
%.o : %.c $(ALL_MAKEFILES)
@echo " **** Compiling file $< "
$(CC) -c $(CFLAGS) $< -o $(OBJECT_DIR)/$(notdir $@)
tells make that if it runs the script you gave, it will create a file
XXX.o from a file XXX.c... but that's _NOT_ what the rule does; it
creates a file $(OBJECT_DIR)/XXX.o. You've lied to make, and it will
have its revenge! :).
Check my site below for some docs on this.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist