1
votes

I'm incrementally verifying my build output and I want to be able to exit after a given recipe is executed.

If the original recipe is

$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
    $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@

I want to be able to add one line at the end like so

$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
    $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
    some_command

and some_command should merely stop the execution of the makefile without interfering with the rest of the recipe.

If I set some_command as exit 1, I get

../py/py.mk:269: recipe for target 'build-gnu/genhdr/mpversion.h' failed make: * [build-gnu/genhdr/mpversion.h] Error 1 make: * Deleting file 'build-gnu/genhdr/mpversion.h'

If I set some_command as $(error), the recipe isn't even executed even though it's BEFORE the $(error)

Is there such a command that stops executing the makefile but doesn't delete the target?

UPDATE
I've found this hack: make .PRECIOUS depend on the target and add exit 1 as the last line in the recipe.

1

1 Answers

1
votes

If the file you want to keep is an intermediate file (not mentioned as target or dependency of a rule - but possibly implied via a pattern rule), then you'll need to make it a dependency of .PRECIOUS.

Otherwise, it should be sufficient to temporarily remove or comment out the .DELETE_ON_ERROR: target that we all put in every Makefile.