GCC dependency generation for a different output directory

后端 未结 7 428
深忆病人
深忆病人 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:01

    The answer is in the GCC manual: use the -MT flag.

    -MT target

    Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any directory components and any file suffix such as .c, and appends the platform's usual object suffix. The result is the target.

    An -MT option will set the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to -MT, or use multiple -MT options.

    For example, -MT '$(objpfx)foo.o' might give

    $(objpfx)foo.o: foo.c
    

提交回复
热议问题