How to apply a command to all the changed dependencies in GNU Make?
Not sure what to google for this, so excuse me if the question is stupid.
I have a Makefile rule that depends on several files. When any of them changes, I want make
to invoke a program and pass to it the list of the changed files as command line arguments. Ideally, I want so开发者_运维知识库mething like this:
myfiles: file1.txt file2.txt file3.txt
my_command $(CHANGED_DEPENDENCIES)
For example, if I changed file1.txt
and file2.txt
, I'd expect make
to invoke my_command file1.txt file2.txt
How do I accomplish that?
Thanks.
Use an automatic variable:
$? The names of all the dependencies that are newer than the target, with spaces between them. For dependencies which are archive members, only the member named is used (see section Using make to Update Archive Files).
See gnu make
精彩评论