Makefile compare strings resulting in shell command
I have the following (part of a larger multiline bash script) in my makefile. The variables A
, B
come from shell command execution via $$(...)
, but the code below is enough to reproduce the problem:
test:
A=1;
B=2;
diff < ( echo $$A ) < ( echo $$B ) || exit 1
syntax error near unexpected token `('.
How can this be done in make? I know there is ifeq
and similar in Makefile, but I guess its not suitable for multiline bash scripts in Makefiles.
The correct syntax of Process substitution is
<( echo $$A )
ie no space between <
and (
.
Be sure to specify
SHELL ::= /bin/bash
or some other shell that supports it.
The default shell is /bin/sh
which doesn't have Process Substitution. You need to change the shell:
SHELL:=/bin/bash
test:
A=1;
B=2;
diff <( echo $$A ) <( echo $$B ) || exit 1
链接地址: http://www.djcxy.com/p/97110.html