This is my contrived Makefile to illustrate my question:
allinfiles = file1.in file2.in file3.in
alloutfiles = file1.out file2.out file3.out
all: $(alloutfiles)
clean:
-rm *.pyc *.in *.out > /dev/null 2>&1
# my.py generates file1.in file2.in file3.in
$(allinfiles): my.py; python my.py
%.out: %.in
cp $< $@
My contrived Python script:
#!/usr/bin/env python
for i in 1,2,3:
filename = 'file{}.in'.format( i )
f = file( filename, 'wt' )
f.write( filename )
f.close()
Result:
$ make clean; make -j 8
python my.py
python my.py
python my.py
Question 1: how do I write my rules so that my.py
is executed only once since it generates all the .in
files?
NB: Unless I misunderstood, I'm trying to use this answer and not getting the results I expected.
Question 2: is there a way to log all the build outputs by their target? That is, if instead of $(shell cp $< $@)
, the recipe generated much output, how do I separate the output by target or input file?