[EMAIL PROTECTED] wrote: > $(OUT_LIB_DIR)/$(OUT_LIB): $(SRCS) > $(COMPILE) $(CFLAGS) -c $? > $(MKLIB) $(OUT_LIB_DIR)/$(OUT_LIB) $(OBJS) > $(RM) $(OBJS)
> This seems to work just fine for source file changes. But I cant seem to > figure out how to add header file dependencies to it? I can see 3 different ways: 1) Recompile all sources if any header file change. 2) List object dependencies in Makefile and recompile only whats necessary. 3) Let gcc do the job of way 2) by using the -M flag to create dependency files for include in your Makefile. > The reason I didnt put the OBJ file rule in the makefile is because I > dont want the .o files, I create an .a file out of all the .o's so I > delete the .o's. So I skipped that step, thats y compiling and archiving > are in one step. > Now if I add $(INCLUDES) in the OUT_LIB target then if I change the > header file, it tries to compile it, and I can see y it does that. I > want when the header file is changed it should remake all the $(SRCS) > files or a subset of those that depend on it. You can't both have your cake and eat it. Say that your .a file contains two .o files which depend on different .h files. If one .h file is changed you have the choice between recompoling all .o files or only the .o file that needs to be recompiled. To find out which .o file needs to be recompiled gnu make must know the time stamp of the .o file and the .h file. Gnu make will not know the time stamp of the .o file if it is hidden in the .a file. To only recompile the .o file that depends on a .h file you must leave the .o files visible to gnu make. regards Henrik -- The address in the header is only to prevent spam. My real address is: hc8(at)uthyres.com Examples of addresses which go to spammers: [EMAIL PROTECTED] [EMAIL PROTECTED] _______________________________________________ help-gnu-utils mailing list help-gnu-utils@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-utils