make

Programming, for all ages and all languages.
Post Reply
Ozguxxx

make

Post by Ozguxxx »

I spent about 5 hours of spare time on finding a bug. The bug was not in actual code but rather it was in makefile that I used for building project. Only one header file that is depended by an object file was not added to object file's dependency list. So object file was not updated and boom, a very meaningless error... :( OK, I know that this is my stupidity but I really get god *amn irritated by such errors, is there an easy way - a macro, etc- to check if all header files are included in object file's dependency list in a makefile? Because some source code files include 7-8 header files, how can I always keep track of this? Thanx... I think I will never use make files... >:(
Tim

Re:make

Post by Tim »

I use an automatic dependency scheme in my makefiles. gcc has an option to emit make-compatible dependency list files, which you can include into your makefile.

Code: Select all

OBJS = file1.o file2.o file3.o
%.d:   %.c
   echo -n $(dir $<) > $@
   $(CC) -c -M $< $(CFLAGS) >> $@

all: app.exe

app.exe: $(OBJS)
   ld -o app.exe $(OBJS)

include $(OBJS:.o=.d)
Post Reply