summaryrefslogtreecommitdiff
path: root/tests/scripts/functions/origin
blob: 49e6f38e78238c6ab7c6abeaabeccc7880333d76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#                                                                    -*-perl-*-

$description = "Test the origin function.";

$details = "This is a test of the origin function in gnu make.
This function will report on where a variable was
defined per the following list:

'undefined'            never defined
'default'              default definition
'environment'          environment var without -e
'environment override' environment var with    -e
'file'                 defined in makefile
'command line'         defined on the command line
'override'             defined by override in makefile
'automatic'            Automatic variable\n";

# Set an environment variable
$extraENV{MAKETEST} = 1;

open(MAKEFILE,"> $makefile");

print MAKEFILE <<EOF;
foo := bletch garf
auto_var = udef CC MAKETEST MAKE foo CFLAGS WHITE \@
av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
override WHITE := BLACK
all: auto
\t\@echo \$(origin undefined)
\t\@echo \$(origin CC)
\t\@echo \$(origin MAKETEST)
\t\@echo \$(origin MAKE)
\t\@echo \$(origin foo)
\t\@echo \$(origin CFLAGS)
\t\@echo \$(origin WHITE)
\t\@echo \$(origin \@)
auto :
\t\@echo \$(av)
EOF

close(MAKEFILE);

&run_make_with_options($makefile,
                      "-e WHITE=WHITE CFLAGS=",
                      &get_logfile);

# Create the answer to what should be produced by this Makefile
$answer = "undefined default environment default file command line override automatic
undefined
default
environment
default
file
command line
override
automatic\n";


&compare_output($answer,&get_logfile(1));

1;