I\'m using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency f
Ok, just to make sure I've got the question right: I'm assuming you have test.c
which includes test.h
, and you want to generate subdir/test.d
(while not generating subdir/test.o
) where subdir/test.d
contains
subdir/test.o: test.c test.h
rather than
test.o: test.c test.h
which is what you get right now. Is that right?
I was not able to come up with an easy way to do exactly what you're asking for. However, looking at Dependency Generation Improvements, if you want to create the .d
file while you generate the .o file, you can use:
gcc $(INCLUDES) -MMD $(CFLAGS) $(SRC) -o $(SUBDIR)/$(OBJ)
(Given SRC=test.c
, SUBDIR=subdir
, and OBJ=test.o
.) This will create both subdir/test.o and subdir/test.d, where subdir/test.d
contains the desired output as above.