Here's a simple Makefile with 4 targets (a
, b
, c
and all
). Target b
can fail (represented here with exit 1
).
a:
echo "a"
b:
exit 1
c:
echo "c"
all: a b c
When running make all
, c
is never printed as b
fails and target c
is consequently not run. But in my particular case, I want c
to be run, even if b
fails.
I'm wondering if there is a way to define the "continue if error" policy directly inside the dependencies of target all
.
I know that the desired behaviour can be reached by :
- running
make -i all
(--ignore-errors
) ormake -k all
(--keep-going
) - using a "recursive" make
- prefixing failing command in
b
with-
(like-exit 1
) - running tasks separately with
make a; make b || make c
but all of these options implies to modify targets a
, b
or c
, or modify the way make all
is called.
Is there a way to have the expected behaviour by just modifying the all
target dependencies (something like all: a -b c
, but that definition does not work, obviously)?
Additional requirement : make all
should return with exit code 1 if b
fails, even if c
target succeeds.