0

I have a number of binary files (images, etc.). I need to copy some of them to an output directory as part of my build process.

The list of files that need to be copied is based on some rather complex logic, and it are generated dynamically by a Python script.

Suppose I have the following in deps.txt:

a.png
b.gif
c.mp4

How could I use a makefile to copy any necessary files to the output directory?

For example, if the output directoryalready included c.mp4 and an out-of-date version of b.gif, running the makefile would copy a.png and b.gif to the output directory (but not c.mp4).

4

1 回答 1

3

如果您使用 GNU make,最简单的方法是使用自动生成的包含文件,如下所示:

deps.txt.mk: deps.txt
        cat $< | while read f; do echo "\$$(OUTPUT_DIR)/$$f: $$f ; cp $$< $$@"; done > $@

-include deps.txt.mk

如果您不使用 GNU make,则必须改用递归:有一个创建 makefile 的规则(如上所示),然后运行$(MAKE) -f deps.txt.mk以实际进行安装。如果您需要该示例,请告诉我。

于 2013-06-05T01:32:05.777 回答