Consider the following setup:
$ touch 1.src 2.src 3.src
$ cat Makefile
%.dst: %.src
@convert -o "$@" "$<"
We can compile our .src files into .dst files by running make 1.dst 2.dst 3.dst which calls the convert (just a placeholder) tool three times.
This setup is fine if there is little overhead in calling convert. However, in my case, it has a startup penalty of a few seconds for every single call. Luckily, the tool can convert multiple files in a single call while paying the startup penalty only once, i.e. convert -o '{}.dst' 1.src 2.src 3.src.
Is there a way in GNU make to specify that multiple src files should be batched into a single call to convert?
Edit: To be more precise, what feature I am looking for: Say that 1.dst is already newer than 1.src so it doesn't need to be recompiled. If I run make 1.dst 2.dst 3.dst, I would like GNU make to execute convert -o '{}.dst' 2.src 3.src.
A quick and dirty way would be creating a .PHONY rule that simply converts all src files to dst files but that way I would convert every src file each and every time. Further more, specifying dst files as prerequisites in other rules would also no longer be possible.
Thanks in advance!
make -j. Making multiple targets from multiple files in one step is clunky (as you can see from proposed answers),Makefilegets more complex and harder to maintain and probably you will hit different corner cases where it will become a bottleneck in a different way. I would consider whether reducing startup overhead is worth future maintenance. Maybe a simple parallelmakewould suffice instead? - raspymake -jwherever I can. The issue with theconverttool is that it takes like 3 seconds to start up and less than a second to compile the source. Even if I run it in parallel, it spends a lot of time on the same startup process over and over again. I'm not sure if it's possible to reduce startup overhead. The tool is written in python and probably spends that startup time in the interpreter. - shilch