Here's what I have so far related to the Mage build tool.
[mgear/mgear.git] / experiments / if-two-commands.mk
1 # Make expands the command script as a whole before splitting it into lines
2 # and executing each line.
3
4 define mm-gen-commands
5 exec 3>$@.tmp && echo $(call sq,$(call fmt-make-assignment,cmd-$(target),$(cmd))) >&3 && set -o pipefail && { ($(cmd)) 2>&1 | sed -re '1s/^/errors-$$(target):=$$(empty)/; 1!s/^/errors-$$(target)+=$$(nl)/' >&3; xc=$$?; } && { [ $xc == 0 ] || echo "exitcode-$(target):=$$xc" >&3 } && if [ $xc != 0 ] || cmp -s $(target) $(target).tmp; then mv -f $@.tmp $@; else rm -f $(target) && mv -f $@.tmp $@ && mv -f $(target).tmp $(target); fi
6 echo bar
7 endef
8
9 phooey:
10         $(if x,$(mm-gen-commands),)
11         $(eval include $@)