On 2019-04-11 03:04, Thomas Nyberg wrote:
Hello,
I would like my Makefile to:
1. Check if a variable is set to specific value,
2. If it is, execute a script and get its return value,
3. Stop executing Makefile depending upon return value.
Here is the Makefile I have:
`Makefile`
-------------------------------------------------------------
FORCE=true
Missing:
.PHONY: all check_force
so that make doesn't probe the filesystem looking for
targets named "all" and "check_force" (and refuse to build anything if
they both exist and "all" is newer).
all: check_force
@echo "success"
check_force:
ifeq ($(FORCE),true)
ifeq lines cannot be indented with a tab. Tabbed lines
are strictly recipe lines.
$(shell sh ./prompt.sh)
This should just be: ./prompt.sh since it's just a step
in the recipe; $(shell ...) is usually used outside of recipes for
obtaining the effect of executing a shell command while Makefile syntax
is being read, and substituting its output.
In a recipe line if we do $(shell echo foo), make will execute "echo
foo" during the expansion of the recipe line and capture the "foo"
output which will then be integrated into the expanded recipe line. Your
recipe line here is saying, "take the output of sh ./prompt.sh and
execute it as a command, failing the recipe if that command fails".
endif
we need an unconditionally successful recipe if the
variable isn't "true", rather than a blank recipe:
else
exit 1
endif
Cheers ...
_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make