在GNU Makefile中的catch-all规则中覆盖目标目录

时间:2012-05-21 18:06:34

标签: gnu-make

请考虑以下事项:

SRCS = somefile.c util/someother.c ../src/more.c

%.o : %.c
    $(GCC) -MD -c $< -o $@ -Wp,-MD,.deps/$*.d
    @cp .deps/$*.d .deps/$*.P; \
      sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
          -e '/^$$/ d' -e 's/$$/ :/' < .deps/$*.d >> .deps/$*.P; \
      rm -f .deps/$*.d

-include $(SRCS:%.c=.deps/%.P)

我如何更改上述内容以使.o文件以./结尾?目前,他们在源文件所在的目录中构建,这很糟糕。

1 个答案:

答案 0 :(得分:0)

我这样做:

SRCS = somefile.c someother.c more.c

%.o : %.c
    [same as before]

-include $(SRCS:%.c=.deps/%.P)

vpath %.c util ../src