temp标记makefile中的一些目标

时间:2012-07-19 01:44:58

标签: makefile gnu-make

我希望编译 $(APPS)的部分目标,但不包括makefile中 $(OFF)中的目标:

APPS = a b c d e f g
OFF = d e

all: $(APPS)

partial: $(APPS) - $(OFF)

我该怎么做?

1 个答案:

答案 0 :(得分:1)

我可能只是采取略微不同的方法:

ON = a b c f g
OFF = d e
APPS = $(ON) $(OFF)

partial: $(ON)

但如果这对您的需求来说过于简单,那么filter-out function可以提供您想要的确切操作:

      objects=main1.o foo.o main2.o bar.o
      mains=main1.o main2.o
      $(filter-out $(mains),$(objects))

我认为用这种格式重写你的例子是:

APPS = a b c d e f g
OFF = c d

partial: $(filter-out $(APPS),$(OFF))