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
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{MAKETEST} = 1;
|
1999-09-14 02:03:19 +00:00
|
|
|
|
2006-03-10 02:20:45 +00:00
|
|
|
run_make_test('
|
1999-09-14 02:03:19 +00:00
|
|
|
foo := bletch garf
|
2006-03-10 02:20:45 +00:00
|
|
|
auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
|
|
|
|
av = $(foreach var, $(auto_var), $(origin $(var)) )
|
1999-09-14 02:03:19 +00:00
|
|
|
override WHITE := BLACK
|
2020-04-01 05:58:33 +00:00
|
|
|
.RECIPEPREFIX = >
|
1999-09-14 02:03:19 +00:00
|
|
|
all: auto
|
2020-04-01 05:58:33 +00:00
|
|
|
> @echo $(origin undefined)
|
|
|
|
> @echo $(origin CC)
|
|
|
|
> @echo $(origin MAKETEST)
|
|
|
|
> @echo $(origin MAKE)
|
|
|
|
> @echo $(origin foo)
|
|
|
|
> @echo $(origin CFLAGS)
|
|
|
|
> @echo $(origin WHITE)
|
|
|
|
> @echo $(origin @)
|
1999-09-14 02:03:19 +00:00
|
|
|
auto :
|
2020-04-01 05:58:33 +00:00
|
|
|
> @echo $(av)',
|
|
|
|
'-e WHITE=WHITE CFLAGS=',
|
|
|
|
'undefined default environment default file command line override automatic
|
1999-09-14 02:03:19 +00:00
|
|
|
undefined
|
|
|
|
default
|
|
|
|
environment
|
|
|
|
default
|
|
|
|
file
|
|
|
|
command line
|
|
|
|
override
|
2006-03-10 02:20:45 +00:00
|
|
|
automatic');
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
1;
|