Skip to content

Instantly share code, notes, and snippets.

@gilligan
Created February 8, 2015 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilligan/d85f867c3815d92b63b9 to your computer and use it in GitHub Desktop.
Save gilligan/d85f867c3815d92b63b9 to your computer and use it in GitHub Desktop.
parallel make problem
#!/bin/bash
echo "MAGIC!"
cp src/foo.y dst/foo.x
cp src/bar.y dst/bar.x
cp src/baz.y dst/baz.x
all: foo
foo: dst/foo.x dst/bar.x dst/baz.x
dst/foo.x dst/bar.x dst/baz.x : src/foo.y src/bar.y src/baz.y
@./magic
clean:
rm dst/*
@gilligan
Copy link
Author

gilligan commented Feb 8, 2015

$ make
MAGIC!

versus

$ make -j 8
MAGIC!
MAGIC!
MAGIC!
cp: cannot create regular file ‘dst/foo.x’: File exists

how can I get make to only invoke magic once as it is supposed to ?

@gilligan
Copy link
Author

gilligan commented Feb 8, 2015

all: foo
foo: dst/foo.x dst/bar.x dst/baz.x
dst/%.x: src/%.y ; ./magic
clean:
    -rm dst/*

#dst/foo.x dst/bar.x dst/baz.x : src/foo.y src/bar.y src/baz.y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment