0

This question builds upon How to generate a source file when building using autotools

I want to do something like

<generated-c-files>: input.txt generator
    ./generator input.txt      # produces <generated-c-files>

The earlier question answers this scenario when the generated c file(s) have fixed name(s) known a priori. However, I have a variable number of files with variable names being generated, depending on the contents of input.txt. What is a good way to do it with autotools?

I am using wildcards to pick up all generated files, which are being placed in a single build folder. However, this requires me to make twice, where the first make fails to link. This seems to be because the wildcard is evaluated before generator is executed. I would like to do it with one successful make and, preferably, not use wildcards.

4

1 回答 1

0

我想说,由于解析的责任input.txt被封装在 中generator,它generator可以告诉你要生成哪些文件。它应该有一些选项,所以你可以做一些事情,例如:

GENERATED_C_FILES := $(shell ./generator --list-output-files input.txt)

# We don't list generator as a prerequisite here because it has to exist
# for the above to work.

$(GENERATED_C_FILES): input.txt
    ./generator input.txt

可以通过一些技巧make来检测generator丢失的内容、重建它并重新运行它自己。但是,更简单和清楚的是,也许generator构建时实用程序可以在某个./configure时间产生,以便可以依赖它在某个make时间出现。

于 2013-10-24T06:18:42.040 回答