The Makefile below works well with OpenBSD make and bmake but fails with
GNU make. I'm looking for a way to make this work with GNU make,
preferably in a portable way.
#v+
.SUFFIXES: .in
all: foo
.in: bar
test -f bar
cat bar > $@
.PHONY: bar
bar:
echo bar > $@
.PHONY: clean
clean:
rm -f foo bar
#v-
With this example Makefile and a file 'foo.in' in the same directory I
can just call bmake and it works as expected. I get a file foo which
contains 'bar'. gmake throws an error:
#v+
% gmake
test -f bar
gmake: *** [Makefile:6: foo] Error 1
#v-
But:
#v+
% gmake bar && gmake
echo bar > bar
test -f bar
cat bar > foo
#v-
Why is GNU make ignoring the prerequisite? How do I fix this?