问题
How can I execute a shell script before building my targets in a Makefile, and see the output as it runs?
I have a script called prepare.sh
that generates a bunch of .pyx files.
The .pyx files are the starting point of my build process involving make.
It goes from .pyx -> .c -> .o -> .so
I don't like having to run prepare.sh separately prior to make. I'd like make to run it for me.
I got it to work but I don't see the output of the command. I'd like to see it. This is what I have now:
PATH := ${PYTHONHOME}/bin:${PATH}
NOTHING:=$(shell ./prepare.sh)
PYXS?=$(wildcard merged/*.pyx)
SOURCES=$(PYXS:.pyx=.c)
OBJECTS=$(SOURCES:.c=.o)
SOBJECTS=$(OBJECTS:.o=.so)
回答1:
Redirect the output of your script to stderr. In this case you also can get rid of dummy NOTHING
variable:
$(shell ./prepare.sh >&2)
UPD.
Another option is to execute the script inside a recipe which runs prior to everithing else:
.PHONY : prepare
prepare :
./prepare.sh
-include prepare
See also: the original Beta's answer with this hack, GNU Make manual entry explaining how it works.
来源:https://stackoverflow.com/questions/11021245/see-output-of-shell-script-in-makefile