1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | # Updated 6.16.93 variable "MAKE" is default was environment override
|
---|
4 | # For make 3.63 and above
|
---|
5 |
|
---|
6 | $description = "The following test creates a makefile to verify
|
---|
7 | test the foreach function.";
|
---|
8 |
|
---|
9 | $details = "This is a test of the foreach function in gnu make.
|
---|
10 | This function starts with a space separated list of
|
---|
11 | names and a variable. Each name in the list is subsituted
|
---|
12 | into the variable and the given text evaluated. The general
|
---|
13 | form of the command is $(foreach var,$list,$text). Several
|
---|
14 | types of foreach loops are tested\n";
|
---|
15 |
|
---|
16 |
|
---|
17 | open(MAKEFILE,"> $makefile");
|
---|
18 |
|
---|
19 | # The Contents of the MAKEFILE ...
|
---|
20 |
|
---|
21 | # On WIN32 systems, the user's path is found in %Path% ($Path)
|
---|
22 | #
|
---|
23 | $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH");
|
---|
24 |
|
---|
25 | print MAKEFILE <<EOF;
|
---|
26 | foo = bletch null \@ garf
|
---|
27 | null :=
|
---|
28 | space = ' '
|
---|
29 | auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ <
|
---|
30 | av = \$(foreach var, \$(auto_var), \$(origin \$(var)) )
|
---|
31 | override WHITE := BLACK
|
---|
32 | for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) )
|
---|
33 | fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) )
|
---|
34 | all: auto for2
|
---|
35 | auto :
|
---|
36 | \t\@echo \$(av)
|
---|
37 | for2:
|
---|
38 | \t\@echo \$(fe)
|
---|
39 | EOF
|
---|
40 |
|
---|
41 | close(MAKEFILE);
|
---|
42 |
|
---|
43 | &run_make_with_options($makefile,
|
---|
44 | "-e WHITE=WHITE CFLAGS=",
|
---|
45 | &get_logfile);
|
---|
46 |
|
---|
47 | # Create the answer to what should be produced by this Makefile
|
---|
48 | $answer = "undefined file default file environment default file command line override automatic automatic
|
---|
49 | foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o\n";
|
---|
50 |
|
---|
51 | &compare_output($answer,&get_logfile(1));
|
---|
52 |
|
---|
53 | 1;
|
---|