craftsman.don
craftsman.don

Reputation: 178

use makefile to parallelize bash script

I have some .src files, and I want to render ONE .png file given A .src files. That is, every .src file can be rendered independently.

I used to write a bash script using loop. But this loop can not be executed parallel.

So I want to write a makefile and make use of 'make -jN'.

The question is, what is the target in my makefile? (I tried this; %.png : %.src cat $< but it does not work)

Upvotes: 2

Views: 276

Answers (2)

choroba
choroba

Reputation: 242343

You can execute bash commands in a loop in parallel:

for i in {1..10} ; do sleep 10 & done ; echo Waiting ; time wait

Upvotes: 1

Simon Richter
Simon Richter

Reputation: 29618

You need a rule that lists all generated files as dependencies. When using GNU make, that could be

all: $(subst .src,.png,$(wildcard *.src))

Upvotes: 2

Related Questions