3 $description = "Test the eval function.";
5 $details = "This is a test of the eval function in GNU make.
6 This function will evaluate inline makefile syntax and incorporate the
7 results into its internal database.\n";
9 open(MAKEFILE,"> $makefile");
11 print MAKEFILE <<'EOF';
17 X = $(eval $(value Y))
19 $(eval $(shell echo A = A))
27 &run_make_with_options($makefile, "", &get_logfile);
29 # Create the answer to what should be produced by this Makefile
32 &compare_output($answer,&get_logfile(1));
34 # Test to make sure defining variables when we have extra scope pushed works
37 $makefile2 = &get_tmpfile;
39 open(MAKEFILE,"> $makefile2");
41 print MAKEFILE <<'EOF';
46 $(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))
48 all: ; @echo A = $(A) B = $(B)
53 &run_make_with_options($makefile2, "", &get_logfile);
55 # Create the answer to what should be produced by this Makefile
56 $answer = "A = A B = B\n";
58 &compare_output($answer,&get_logfile(1));
60 # Test to make sure eval'ing inside conditionals works properly
62 $makefile3 = &get_tmpfile;
64 open(MAKEFILE,"> $makefile3");
66 print MAKEFILE <<'EOF';
83 &run_make_with_options($makefile3, "", &get_logfile);
85 &compare_output($answer,&get_logfile(1));
87 &run_make_with_options($makefile3, "BAR=1", &get_logfile);
88 $answer = "it\nworked\n";
89 &compare_output($answer,&get_logfile(1));
92 # TEST very recursive invocation of eval
94 $makefile3 = &get_tmpfile;
96 open(MAKEFILE,"> $makefile3");
98 print MAKEFILE <<'EOF';
99 ..9 := 0 1 2 3 4 5 6 7 8 9
100 rev=$(eval res:=)$(foreach word,$1,$(eval res:=${word} ${res}))${res}
101 a:=$(call rev,${..9})
102 all: ; @echo '[$(a)]'
108 &run_make_with_options($makefile3, "", &get_logfile);
109 $answer = "[ 9 8 7 6 5 4 3 2 1 0 ]\n";
110 &compare_output($answer,&get_logfile(1));
113 # TEST eval with no filename context.
114 # The trick here is that because EVAR is taken from the environment, it must
115 # be evaluated before every command is invoked. Make sure that works, when
116 # we have no file context for reading_file (bug # 6195)
118 $makefile4 = &get_tmpfile;
120 open(MAKEFILE,"> $makefile4");
122 print MAKEFILE <<'EOF';
123 EVAR = $(eval FOBAR = 1)
131 &run_make_with_options($makefile4, "", &get_logfile);
133 &compare_output($answer,&get_logfile(1));