GCC dependency generation for a different output directory

后端 未结 7 431
深忆病人
深忆病人 2021-01-30 14:30

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

7条回答
  •  生来不讨喜
    2021-01-30 15:00

    Detailing on DGentry's answer, this has worked well for me:

    .depend: $(SOURCES)
        $(CC) $(CFLAGS) -MM $(SOURCES) | sed 's|[a-zA-Z0-9_-]*\.o|$(OBJDIR)/&|' > ./.depend
    

    This also works in the case where there is only one dependency file that contains the dependency rules for all source files.

提交回复
热议问题