3 $description = "Test proper behavior of MAKEFLAGS";
7 # Normal flags aren't prefixed with "-"
9 all: ; @echo /$(MAKEFLAGS)/
13 # Long arguments mean everything is prefixed with "-"
15 all: ; @echo /$(MAKEFLAGS)/
17 '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: update target 'all' due to: target does not exist
18 echo /erR --trace --no-print-directory/
19 /erR --trace --no-print-directory/");
22 # Recursive invocations of make should accumulate MAKEFLAGS values.
28 > @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
29 > @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
31 > @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
32 > @$(MAKE) -f #MAKEFILE# print
34 > @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
35 .PHONY: all jump print
37 '--no-print-directory',
38 'all: MAKEFLAGS= --no-print-directory
39 jump Works: MAKEFLAGS=e --no-print-directory
40 print Works: MAKEFLAGS=e --no-print-directory');
42 # Ensure MAKEFLAGS updates are handled immediately rather than later
48 $(info MAKEFLAGS=$(MAKEFLAGS))
49 $(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
51 $(info MAKEFLAGS=$(MAKEFLAGS))
52 $(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
54 all: ; @echo 'MAKEFLAGS=$(MAKEFLAGS)' "\$$MAKEFLAGS=$$MAKEFLAGS"
56 '-I- -Ifoo', 'MAKEFLAGS= -I- -Ifoo
58 MAKEFLAGS= -I- -Ifoo -Ibar
60 MAKEFLAGS= -I- -Ifoo -Ibar $MAKEFLAGS= -I- -Ifoo -Ibar');
65 # Test that command line switches are all present in MAKEFLAGS.
70 @opts = ('i', 'k', 'n', 'q', 'r', 's', 'w', 'd');
71 exists $FEATURES{'check-symlink'} and push @opts, 'L';
76 all:; $(info makeflags='$(MAKEFLAGS)')
77 !, "-$opt", "/makeflags='B$opt'/");
80 # Switches which carry arguments.
81 @opts = (' -I/tmp', ' -Onone', ' --debug=b', ' -l2.5');
85 all:; $(info makeflags='$(MAKEFLAGS)')
86 !, "$opt", "/makeflags='B$opt'/");
89 # Long options which take no arguments.
91 @opts = (' --no-print-directory', ' --warn-undefined-variables', ' --trace');
95 all:; $(info makeflags='$(MAKEFLAGS)')
96 !, "$opt", "/makeflags='B$opt'/");
99 # Test that make filters out duplicates.
100 # Each option is specified in the makefile, env and on the command line.
101 @opts = (' -I/tmp', ' -Onone', ' --debug=b', ' -l2.5');
102 $ENV{'MAKEFLAGS'} = $opt;
103 for my $opt (@opts) {
106 all:; \$(info makeflags='\$(MAKEFLAGS)')
107 ", "$opt", "/makeflags='B$opt'/");
110 # Test that make filters out duplicates.
111 # Each option is specified in the makefile, env and on the command line.
112 # decode_switches reallocates when the number of parameters in sl->list exceeds 5.
113 # This test exercises the realloc branch.
114 $ENV{'MAKEFLAGS'} = '-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2';
116 MAKEFLAGS:=B -I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2
117 all:; $(info makeflags='$(MAKEFLAGS)')
119 '-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6',
120 "/makeflags='B -I1 -I2 -I3 -I4 -I5 -I6 -l2.5 -Onone --debug=b'/");
122 # A mix of multiple flags from env, the makefile and command line.
123 # Skip -L since it's not available everywhere
124 $ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables --trace';
126 MAKEFLAGS:=iknqrswd -I/tmp -I/tmp -Onone -Onone -l2.5 -l2.5
127 all:; $(info makeflags='$(MAKEFLAGS)')
129 '-Onone -l2.5 -l2.5 -Onone -I/tmp -iknqrswd -i -n -s -k -I/tmp',
130 "/makeflags='Bdiknqrsw -I/tmp -l2.5 -Onone --trace --warn-undefined-variables'/");
132 # Verify MAKEFLAGS are all available to shell functions
133 $ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables';
135 MAKEFLAGS := iknqrsw -I/tmp -I/tmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
136 XX := $(shell echo "$$MAKEFLAGS")
137 all:; $(info makeflags='$(XX)')
139 '-Onone -l2.5 -l2.5 -Onone -I/tmp -iknqrs -i -n -s -k -I/tmp',
140 "makeflags='iknqrsw -I/tmp -I/tmp -Onone -Onone -l2.5 -l2.5 --no-print-directory'");
142 # Verify that command line arguments are included in MAKEFLAGS
144 all: ; @echo $(MAKEFLAGS)
146 '-e FOO=bar -r -R', 'erR -- FOO=bar');
148 # Long arguments mean everything is prefixed with "-"
150 all: ; @echo /$(MAKEFLAGS)/
152 '--no-print-directory -e -r -R --trace FOO=bar',
153 "#MAKEFILE#:2: update target 'all' due to: target does not exist
154 echo /erR --trace --no-print-directory -- FOO=bar/
155 /erR --trace --no-print-directory -- FOO=bar/");