简体   繁体   English

GNU make-如何将隐式模式设置为先决条件

[英]GNU make - how to set an implicit pattern as a prerequisite

I have this implicit rule: 我有这个隐含规则:

%.so: %.so.5
    qnx_ln $< $@

I realized that for another target, I have to make all .so files the prerequisite for that target. 我意识到,对于另一个目标,我必须使所有.so文件成为该目标的先决条件。

I tried this: 我尝试了这个:

makegen: $(TEAM_ROOT)HMI_FORGF/src/src.pro module_dirs %.so
    ...

But I got the output 但是我得到了输出

*** No rule to make target '%.so', needed by 'makegen'. ***没有规则来使目标为'makegen'所需要的'%.so'。 Stop. 停止。

% prerequisite patterns can only be used in static and implicit pattern rules, where they match the respective % part of the target; %先决条件模式只能在静态和隐式模式规则中使用,它们与目标的相应%部分匹配; when used in a regular rule % is a literal character. 在常规规则中使用时, %是文字字符。

You'll need to specify the dependencies literally, unless there is some correspondence between certain source filenames and the .so filenames that you can leverage, presumably you're already doing either of these to link the .so files in the first place. 您需要从字面上指定依赖项,除非某些源文件名和您可以利用的.so文件名之间存在某种对应关系,否则大概您已经在做任何一种链接.so文件的工作。

As pointed out previously, no you can't do that because this is not how prerequisite patterns work. 如前所述,您不能这样做,因为这不是先决条件模式的工作方式。 Maybe you gave the following a thought and rejected it but I suspect you might find the following a close-enough fit: 也许您提出了以下想法并拒绝了它,但我怀疑您可能会发现以下内容非常合适:

%.so.target: %.so.5
        echo $< >> $(BUILD)/so.targets

SO_TARGETS=$(basename $(shell cat $(BUILD)/so.targets))

makegen: $(TEAM_ROOT)HMI_FORGF/src/src.pro module_dirs $(SO_TARGETS)

Maybe you are looking for a rule to match on every existing *.so file? 也许您正在寻找与每个现有* .so文件匹配的规则?

makegen: $(TEAM_ROOT)HMI_FORGF/src/src.pro module_dirs $(wildcard *.so)
    ...

However, if there are patterns which could generate *.so files which have not yet generated those files, they will (obviously) not be matched by the wildcard, which simply examines existing files. 但是,如果存在可以生成* .so文件的模式, 这些模式尚未生成这些文件,则(显然)通配符将不匹配它们,后者仅检查现有文件。 If that's what you actually want to accomplish, you'll probably want to enumerate the actual files, one way or another. 如果这是您实际想要完成的工作,则可能需要以一种或另一种方式枚举实际文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM