1999-09-14 02:03:19 +00:00
|
|
|
# -*-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";
|
|
|
|
|
2004-02-23 06:25:54 +00:00
|
|
|
# Set an environment variable
|
|
|
|
$ENV{MAKETEST} = 1;
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
open(MAKEFILE,"> $makefile");
|
|
|
|
|
|
|
|
print MAKEFILE <<EOF;
|
|
|
|
foo := bletch garf
|
2004-02-25 19:30:27 +00:00
|
|
|
auto_var = udef CC MAKETEST MAKE foo CFLAGS WHITE \@
|
1999-09-14 02:03:19 +00:00
|
|
|
av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
|
|
|
|
override WHITE := BLACK
|
|
|
|
all: auto
|
|
|
|
\t\@echo \$(origin undefined)
|
|
|
|
\t\@echo \$(origin CC)
|
2004-02-23 06:25:54 +00:00
|
|
|
\t\@echo \$(origin MAKETEST)
|
1999-09-14 02:03:19 +00:00
|
|
|
\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;
|