Makefile 在条件上添加先决条件
如果在工作区中找到另一个文件,是否可以添加先决条件?或者我怎样才能实现以下想法?基本上,如果我的工作区在特定位置有一个lcf文件,我需要创建另一个文件。。大概是这样的:Makefile 在条件上添加先决条件,makefile,prerequisites,Makefile,Prerequisites,如果在工作区中找到另一个文件,是否可以添加先决条件?或者我怎样才能实现以下想法?基本上,如果我的工作区在特定位置有一个lcf文件,我需要创建另一个文件。。大概是这样的: lcf := ../base_sw/lcf/base.lcf .PHONY : all : $(objects) # if $(lcf) file exists then all : $(objects) sup.a2l sup.a2l : # Perl script runs here to produce su
lcf := ../base_sw/lcf/base.lcf
.PHONY :
all : $(objects)
# if $(lcf) file exists then
all : $(objects) sup.a2l
sup.a2l :
# Perl script runs here to produce sup.a2l
@echo Chris > $@
这应该做到:
lcf := $(wildcard ../base_sw/lcf/base.lcf)
.PHONY :
all : $(objects) $(lcf)
我想我自己已经设法回答了这个问题 如果lcf文件不存在,则通配符函数不返回任何内容:
lcf := $(wildcard ../base_sw/lcf/base.lcf)
开始生成需要生成的文件:
make_these_file := $(obejcts)
如果lcf变量不为空,请附加到文件列表:
ifneq ($(lcf),)
make_these_file += sup.a2l
endif
现在,我们的目标需要文件来实现:
.PHONY :
all : $(make_these_file)
sup.a2l :
# Perl script here to produce sup.a2l
@echo Chris > $@
为我工作:)