I have a makefile that is running a custom program on large numbers of input file. The program has large startup cost, and is more efficient processing multiple files in the same run
I would like to leverage make parallel processing, so i wrote a simple makefile, which I execute with make -j
In = f1.in f2.in …
Out = $(in:.in=.out)
All: $(out)
%.out: %.in
Program $< > $@
I would like to speed up processing by invoking ‘program’ N times, each with multiple files.
My question: is there away to split the $(in) into N lists, each containing about the same number of files, so i can write the efficient to execute makefile. Am ok with fixed N value like 8.
All: l1.out l2.out … l8.out
l1.out: $(select 1, 8, $(in))
Program $^ > $@
Which will work well with make -j: parralel execution, without excessive invocation of ‘program’
Needless to say: looking for solution that will NOT result in multiple invocation of external helpers like bash/awk. Ideally, a solution that will not invoke any external helpers.