1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | $description = "Test the origin function.";
|
---|
4 |
|
---|
5 | $details = "This is a test of the origin function in gnu make.
|
---|
6 | This function will report on where a variable was
|
---|
7 | defined 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 | # On WIN32 systems, HOME is meaningless. SystemRoot should be defined
|
---|
19 | # though. With DJGPP, HOME is not guaranteed to be defined. Use DJDIR
|
---|
20 | # instead.
|
---|
21 | #
|
---|
22 | $homevar = (($port_type eq 'Windows') ? "SystemRoot"
|
---|
23 | : (($port_type eq 'DOS') ? "DJDIR"
|
---|
24 | : "HOME"));
|
---|
25 |
|
---|
26 | open(MAKEFILE,"> $makefile");
|
---|
27 |
|
---|
28 | print MAKEFILE <<EOF;
|
---|
29 | foo := bletch garf
|
---|
30 | auto_var = udef CC $homevar MAKE foo CFLAGS WHITE \@
|
---|
31 | av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
|
---|
32 | override WHITE := BLACK
|
---|
33 | all: auto
|
---|
34 | \t\@echo \$(origin undefined)
|
---|
35 | \t\@echo \$(origin CC)
|
---|
36 | \t\@echo \$(origin $homevar)
|
---|
37 | \t\@echo \$(origin MAKE)
|
---|
38 | \t\@echo \$(origin foo)
|
---|
39 | \t\@echo \$(origin CFLAGS)
|
---|
40 | \t\@echo \$(origin WHITE)
|
---|
41 | \t\@echo \$(origin \@)
|
---|
42 | auto :
|
---|
43 | \t\@echo \$(av)
|
---|
44 | EOF
|
---|
45 |
|
---|
46 | close(MAKEFILE);
|
---|
47 |
|
---|
48 | &run_make_with_options($makefile,
|
---|
49 | "-e WHITE=WHITE CFLAGS=",
|
---|
50 | &get_logfile);
|
---|
51 |
|
---|
52 | # Create the answer to what should be produced by this Makefile
|
---|
53 | $answer = "undefined default environment default file command line override automatic
|
---|
54 | undefined
|
---|
55 | default
|
---|
56 | environment
|
---|
57 | default
|
---|
58 | file
|
---|
59 | command line
|
---|
60 | override
|
---|
61 | automatic\n";
|
---|
62 |
|
---|
63 |
|
---|
64 | &compare_output($answer,&get_logfile(1));
|
---|
65 |
|
---|
66 | 1;
|
---|