This answer, just as that of @Vroomfondel aims to circumvent the loop problem in an elegant way.
My take is to let make
generate the loop itself as an imported makefile like this:
include Loop.mk
Loop.mk:Loop.sh
Loop.sh > $@
The shell script can the be as advanced as you like but a minimal working example could be
#!/bin/bash
LoopTargets=""
NoTargest=5
for Target in `seq $NoTargest` ; do
File="target_${Target}.dat"
echo $File:data_script.sh
echo $'\t'./data_script.ss $Target
LoopTargets="$LoopTargets $File"
done
echo;echo;echo LoopTargets:=$LoopTargets
which generates the file
target_1.dat:data_script.sh
./data_script.ss 1
target_2.dat:data_script.sh
./data_script.ss 2
target_3.dat:data_script.sh
./data_script.ss 3
target_4.dat:data_script.sh
./data_script.ss 4
target_5.dat:data_script.sh
./data_script.ss 5
LoopTargets:= target_1.dat target_2.dat target_3.dat target_4.dat target_5.dat
And advantage there is that make
can itself keep track of which files have been generated and which ones need to be (re)generated. As such, this also enables make
to use the -j
flag for parallelization.