make/tests/scripts/functions/eval
Paul Smith 8572d6adf0 Major updates in preparation for 3.80.
New version of the manual, put into the doc subdir.
Enhancements: $(eval ...) and $(value ...) functions, various bug
fixes, etc.  See the ChangeLog.
More to come.
2002-07-08 02:26:47 +00:00

60 lines
1.2 KiB
Perl

# -*-perl-*-
$description = "Test the eval function.";
$details = "This is a test of the eval function in GNU make.
This function will evaluate inline makefile syntax and incorporate the
results into its internal database.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
define Y
all:: ; @echo $AA
A = B
endef
X = $(eval $(value Y))
$(eval $(shell echo A = A))
$(eval $(Y))
$(eval A = C)
$(eval $(X))
EOF
close(MAKEFILE);
&run_make_with_options($makefile, "", &get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "AA\nBA\n";
&compare_output($answer,&get_logfile(1));
# Test to make sure defining variables when we have extra scope pushed works
# as expected.
$makefile2 = &get_tmpfile;
open(MAKEFILE,"> $makefile2");
print MAKEFILE <<'EOF';
VARS = A B
VARSET = $(1) = $(2)
$(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))
all: ; @echo A = $(A) B = $(B)
EOF
close(MAKEFILE);
&run_make_with_options($makefile2, "", &get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "A = A B = B\n";
&compare_output($answer,&get_logfile(1));
1;