I have a single command my_app
that produces two files file1.o
and file2.o
following an answer from SO I came up with the follwoing:
all: file1.o file2.o
%1.o %2.o : input.txt
my_app input.txt
But that doesn't work and triggers every time even when file1.o
and file2.o
already exist and input.txt
hasn't changed. Then I realized that the targets need to be mentioned with $*
so the following works
all: file1.o file2.o
%1.o %2.o : input.txt
@echo ($*1.o)
@echo ($*2.o)
my_app input.txt
Which produces
$ make
file1.o
file2.o
my_app input.txt
Ok, good enough, but how do I make it without printing the files? Do I have to trick Make by suppressing the output somehow or is there another more programmatic way to solve this?