1#                                                                    -*-perl-*-
2
3$description = "Test the origin function.";
4
5$details = "This is a test of the origin function in gnu make.
6This function will report on where a variable was
7defined per the following list:
8
9'undefined'            never defined
10'default'              default definition
11'environment'          environment var without -e
12'environment override' environment var with    -e
13'file'                 defined in makefile
14'command line'         defined on the command line
15'override'             defined by override in makefile
16'automatic'            Automatic variable\n";
17
18# Set an environment variable
19$extraENV{MAKETEST} = 1;
20
21run_make_test('
22foo := bletch garf
23auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
24av = $(foreach var, $(auto_var), $(origin $(var)) )
25override WHITE := BLACK
26all: auto
27	@echo $(origin undefined)
28	@echo $(origin CC)
29	@echo $(origin MAKETEST)
30	@echo $(origin MAKE)
31	@echo $(origin foo)
32	@echo $(origin CFLAGS)
33	@echo $(origin WHITE)
34	@echo $(origin @)
35auto :
36	@echo $(av)',
37	      '-e WHITE=WHITE CFLAGS=',
38	      'undefined default environment default file command line override automatic
39undefined
40default
41environment
42default
43file
44command line
45override
46automatic');
47
48# Reset an environment variable
49delete $extraENV{MAKETEST};
50
511;
52