Lines Matching +full:not +full:- +full:swapped
1 # $NetBSD: directive-include-guard.mk,v 1.19 2025/04/11 17:21:31 rillig Exp $
3 # Tests for multiple-inclusion guards in makefiles.
5 # A file that is guarded by a multiple-inclusion guard has one of the
14 # .if !target(guard-target)
19 # including it would not have any effect, not even on the special variable
23 # https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
30 # This is the canonical form of a variable-based multiple-inclusion guard.
31 CASES+= variable-ifndef
32 LINES.variable-ifndef= \
36 # expect: Parse_PushInput: variable-ifndef.tmp:1
37 # expect: Skipping 'variable-ifndef.tmp' because 'VARIABLE_IFNDEF' is defined
41 # Its content is skipped, therefore the syntax error is not detected.
42 CASES+= variable-ifndef-reuse
43 LINES.variable-ifndef-reuse= \
47 # expect: Parse_PushInput: variable-ifndef-reuse.tmp:1
48 # expect: Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined
52 CASES+= variable-ifndef-zero
53 LINES.variable-ifndef-zero= \
57 # expect: Parse_PushInput: variable-ifndef-zero.tmp:1
58 # expect: Parse_PushInput: variable-ifndef-zero.tmp:1
62 CASES+= variable-ifndef-one
63 LINES.variable-ifndef-one= \
66 # expect: Parse_PushInput: variable-ifndef-one.tmp:1
67 # expect: Parse_PushInput: variable-ifndef-one.tmp:1
69 # Comments and empty lines do not affect the multiple-inclusion guard.
84 # not commonly used.
85 CASES+= variable-if
86 LINES.variable-if= \
90 # expect: Parse_PushInput: variable-if.tmp:1
91 # expect: Skipping 'variable-if.tmp' because 'VARIABLE_IF' is defined
95 # Its content is skipped, therefore the syntax error is not detected.
96 CASES+= variable-if-reuse
97 LINES.variable-if-reuse= \
101 # expect: Parse_PushInput: variable-if-reuse.tmp:1
102 # expect: Skipping 'variable-if-reuse.tmp' because 'VARIABLE_IF' is defined
104 # Triple negation is so uncommon that it's not recognized, even though it has
106 CASES+= variable-if-triple-negation
107 LINES.variable-if-triple-negation= \
111 # expect: Parse_PushInput: variable-if-triple-negation.tmp:1
112 # expect: Parse_PushInput: variable-if-triple-negation.tmp:1
114 # If the guard variable is enclosed in spaces, it does not have an effect, as
115 # that form is not common in practice.
116 CASES+= variable-if-spaced
117 LINES.variable-if-spaced= \
121 # expect: Parse_PushInput: variable-if-spaced.tmp:1
122 # expect: Parse_PushInput: variable-if-spaced.tmp:1
124 # If the guard variable condition is enclosed in parentheses, it does not have
125 # an effect, as that form is not common in practice.
126 CASES+= variable-if-parenthesized
127 LINES.variable-if-parenthesized= \
131 # expect: Parse_PushInput: variable-if-parenthesized.tmp:1
132 # expect: Parse_PushInput: variable-if-parenthesized.tmp:1
134 # A conditional other than '.if' or '.ifndef' does not guard the file, even if
136 CASES+= variable-ifdef-negated
137 LINES.variable-ifdef-negated= \
141 # expect: Parse_PushInput: variable-ifdef-negated.tmp:1
142 # expect: Parse_PushInput: variable-ifdef-negated.tmp:1
145 CASES+= variable-name-mismatch
146 LINES.variable-name-mismatch= \
150 # expect: Parse_PushInput: variable-name-mismatch.tmp:1
151 # expect: Parse_PushInput: variable-name-mismatch.tmp:1
153 # If the guard variable condition is enclosed in parentheses, it does not have
154 # an effect, as that form is not common in practice.
155 CASES+= variable-ifndef-parenthesized
156 LINES.variable-ifndef-parenthesized= \
160 # expect: Parse_PushInput: variable-ifndef-parenthesized.tmp:1
161 # expect: Parse_PushInput: variable-ifndef-parenthesized.tmp:1
169 CASES+= variable-name-exclamation
170 LINES.variable-name-exclamation= \
174 # expect: Parse_PushInput: variable-name-exclamation.tmp:1
175 # expect: Parse_PushInput: variable-name-exclamation.tmp:1
180 # '!' is not supported in any place, though.
181 CASES+= variable-name-exclamation-middle
182 LINES.variable-name-exclamation-middle= \
186 # expect: Parse_PushInput: variable-name-exclamation-middle.tmp:1
187 # expect: Parse_PushInput: variable-name-exclamation-middle.tmp:1
192 # choice a bad idea, therefore these characters are not allowed in guard
194 CASES+= variable-name-parentheses
195 LINES.variable-name-parentheses= \
199 # expect: Parse_PushInput: variable-name-parentheses.tmp:1
200 # expect: Parse_PushInput: variable-name-parentheses.tmp:1
203 CASES+= variable-ifndef-plus
204 LINES.variable-ifndef-plus= \
209 # expect: Parse_PushInput: variable-ifndef-plus.tmp:1
210 # expect: Parse_PushInput: variable-ifndef-plus.tmp:1
213 CASES+= variable-if-plus
214 LINES.variable-if-plus= \
219 # expect: Parse_PushInput: variable-if-plus.tmp:1
220 # expect: Parse_PushInput: variable-if-plus.tmp:1
222 # The variable name in an '.ifndef' guard must be given directly, it must not
224 CASES+= variable-ifndef-indirect
225 LINES.variable-ifndef-indirect= \
229 # expect: Parse_PushInput: variable-ifndef-indirect.tmp:1
230 # expect: Parse_PushInput: variable-ifndef-indirect.tmp:1
232 # The variable name in an '.if' guard must be given directly, it must not
234 CASES+= variable-if-indirect
235 LINES.variable-if-indirect= \
239 # expect: Parse_PushInput: variable-if-indirect.tmp:1
240 # expect: Parse_PushInput: variable-if-indirect.tmp:1
246 CASES+= variable-assign-indirect
247 LINES.variable-assign-indirect= \
251 # expect: Parse_PushInput: variable-assign-indirect.tmp:1
252 # expect: Skipping 'variable-assign-indirect.tmp' because 'VARIABLE_ASSIGN_INDIRECT' is defined
256 CASES+= variable-assign-late
257 LINES.variable-assign-late= \
262 # expect: Parse_PushInput: variable-assign-late.tmp:1
263 # expect: Skipping 'variable-assign-late.tmp' because 'VARIABLE_ASSIGN_LATE' is defined
267 CASES+= variable-assign-nested
268 LINES.variable-assign-nested= \
276 # expect: Parse_PushInput: variable-assign-nested.tmp:1
277 # expect: Skipping 'variable-assign-nested.tmp' because 'VARIABLE_ASSIGN_NESTED' is defined
282 # top-level '.if/.endif' conditional can be determined reliably enough to
284 CASES+= variable-already-defined
285 LINES.variable-already-defined= \
290 # expect: Parse_PushInput: variable-already-defined.tmp:1
291 # expect: Skipping 'variable-already-defined.tmp' because 'VARIABLE_ALREADY_DEFINED' is defined
297 CASES+= variable-defined-then-undefined
298 LINES.variable-defined-then-undefined= \
302 UNDEF_BETWEEN.variable-defined-then-undefined= \
304 # expect: Parse_PushInput: variable-defined-then-undefined.tmp:1
305 # expect: Parse_PushInput: variable-defined-then-undefined.tmp:1
307 # The whole file content must be guarded by a single '.if' conditional, not by
309 # This case is not expected to occur in practice, as the two parts would
311 CASES+= variable-two-times
312 LINES.variable-two-times= \
319 # expect: Parse_PushInput: variable-two-times.tmp:1
320 # expect: Parse_PushInput: variable-two-times.tmp:1
327 # System-provided files typically start the guard names with '_'.
328 CASES+= variable-clash
329 LINES.variable-clash= \
330 ${LINES.variable-if}
331 # expect: Parse_PushInput: variable-clash.tmp:1
332 # expect: Skipping 'variable-clash.tmp' because 'VARIABLE_IF' is defined
336 CASES+= variable-swapped
337 LINES.variable-swapped= \
338 'SWAPPED=' \
339 '.ifndef SWAPPED' \
342 # expect: Parse_PushInput: variable-swapped.tmp:1
343 # expect: Parse_PushInput: variable-swapped.tmp:1
347 CASES+= variable-undef-between
348 LINES.variable-undef-between= \
352 UNDEF_BETWEEN.variable-undef-between= \
354 # expect: Parse_PushInput: variable-undef-between.tmp:1
355 # expect: Parse_PushInput: variable-undef-between.tmp:1
358 # time, the guard does not have an effect, and the file is included again.
359 CASES+= variable-undef-inside
360 LINES.variable-undef-inside= \
365 # expect: Parse_PushInput: variable-undef-inside.tmp:1
366 # expect: Parse_PushInput: variable-undef-inside.tmp:1
368 # If the file does not define the guard variable, the guard does not have an
370 CASES+= variable-not-defined
371 LINES.variable-not-defined= \
374 # expect: Parse_PushInput: variable-not-defined.tmp:1
375 # expect: Parse_PushInput: variable-not-defined.tmp:1
377 # The outermost '.if' must not have an '.elif' branch.
389 CASES+= elif-reuse
390 LINES.elif-reuse= \
395 # expect: Parse_PushInput: elif-reuse.tmp:1
396 # expect: Parse_PushInput: elif-reuse.tmp:1
398 # The outermost '.if' must not have an '.else' branch.
410 CASES+= else-reuse
411 LINES.else-reuse= \
416 # expect: Parse_PushInput: else-reuse.tmp:1
417 # expect: Parse_PushInput: else-reuse.tmp:1
421 CASES+= inner-if-elif-else
422 LINES.inner-if-elif-else= \
438 # expect: Parse_PushInput: inner-if-elif-else.tmp:1
439 # expect: Skipping 'inner-if-elif-else.tmp' because 'INNER_IF_ELIF_ELSE' is defined
458 CASES+= target-sys
459 LINES.target-sys= \
460 '.if !target(__<target-sys.tmp>__)' \
461 '__<target-sys.tmp>__: .NOTMAIN' \
463 # expect: Parse_PushInput: target-sys.tmp:1
464 # expect: Skipping 'target-sys.tmp' because '__<target-sys.tmp>__' is defined
469 # and once for determining the guard name. This double evaluation should not
472 CASES+= target-indirect
473 LINES.target-indirect= \
474 '.if !target($${target-indirect.tmp:L})' \
475 'target-indirect.tmp: .NOTMAIN' \
477 # expect: Parse_PushInput: target-indirect.tmp:1
478 # expect: Skipping 'target-indirect.tmp' because 'target-indirect.tmp' is defined
483 # This form does not work when the basename contains whitespace characters, as
484 # it is not possible to define a target with whitespace, not even by cheating.
485 CASES+= target-indirect-PARSEFILE
486 LINES.target-indirect-PARSEFILE= \
490 # expect: Parse_PushInput: target-indirect-PARSEFILE.tmp:1
491 # expect: Skipping 'target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is d…
495 CASES+= target-indirect-PARSEFILE2
496 LINES.target-indirect-PARSEFILE2= \
500 # expect: Parse_PushInput: target-indirect-PARSEFILE2.tmp:1
501 # expect: Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is…
504 # guard is the same as in the test case 'target-indirect-PARSEFILE', as the
505 # guard name only contains the basename but not the directory name. So even
507 CASES+= subdir/target-indirect-PARSEFILE
508 LINES.subdir/target-indirect-PARSEFILE= \
511 # expect: Parse_PushInput: subdir/target-indirect-PARSEFILE.tmp:1
512 # expect: Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp_…
516 CASES+= target-indirect-PARSEDIR-PARSEFILE
517 LINES.target-indirect-PARSEDIR-PARSEFILE= \
521 # expect: Parse_PushInput: target-indirect-PARSEDIR-PARSEFILE.tmp:1
522 # expect: Skipping 'target-indirect-PARSEDIR-PARSEFILE.tmp' because '__target-indirect-PARSEDIR-PAR…
528 CASES+= subdir/target-indirect-PARSEDIR-PARSEFILE
529 LINES.subdir/target-indirect-PARSEDIR-PARSEFILE= \
533 # expect: Parse_PushInput: subdir/target-indirect-PARSEDIR-PARSEFILE.tmp:1
534 # expect: Skipping 'subdir/target-indirect-PARSEDIR-PARSEFILE.tmp' because '__subdir/target-indirec…
538 # If the guard target is not defined when including the file the next time,
540 CASES+= target-unguarded
541 LINES.target-unguarded= \
542 '.if !target(target-unguarded)' \
544 # expect: Parse_PushInput: target-unguarded.tmp:1
545 # expect: Parse_PushInput: target-unguarded.tmp:1
548 CASES+= target-plus
549 LINES.target-plus= \
550 '.if !target(target-plus) && 1' \
551 'target-plus: .NOTMAIN' \
553 # expect: Parse_PushInput: target-plus.tmp:1
554 # expect: Parse_PushInput: target-plus.tmp:1
558 CASES+= target-already-defined
559 LINES.target-already-defined= \
560 '.if !target(target-already-defined)' \
561 'target-already-defined: .NOTMAIN' \
563 target-already-defined: .NOTMAIN
564 # expect: Parse_PushInput: target-already-defined.tmp:1
565 # expect: Skipping 'target-already-defined.tmp' because 'target-already-defined' is defined
575 # '\!target-name-exclamation' instead of '!target-name-exclamation'.
576 CASES+= target-name-exclamation
577 LINES.target-name-exclamation= \
578 '.if !target(!target-name-exclamation)' \
579 '\!target-name-exclamation: .NOTMAIN' \
581 # expect: Parse_PushInput: target-name-exclamation.tmp:1
582 # expect: Parse_PushInput: target-name-exclamation.tmp:1
584 # If the guard target name has leading spaces, it does not have an effect,
585 # as that form is not common in practice.
586 CASES+= target-name-leading-space
587 LINES.target-name-leading-space= \
588 '.if !target( target-name-leading-space)' \
589 'target-name-leading-space: .NOTMAIN' \
591 # expect: Parse_PushInput: target-name-leading-space.tmp:1
592 # expect: Parse_PushInput: target-name-leading-space.tmp:1
594 # If the guard target name has trailing spaces, it does not have an effect,
595 # as that form is not common in practice.
596 CASES+= target-name-trailing-space
597 LINES.target-name-trailing-space= \
598 '.if !target(target-name-trailing-space )' \
599 'target-name-trailing-space: .NOTMAIN' \
601 # expect: Parse_PushInput: target-name-trailing-space.tmp:1
602 # expect: Parse_PushInput: target-name-trailing-space.tmp:1
604 # If the guard target condition is enclosed in parentheses, it does not have
605 # an effect, as that form is not common in practice.
606 CASES+= target-call-parenthesized
607 LINES.target-call-parenthesized= \
608 '.if (!target(target-call-parenthesized))' \
609 'target-call-parenthesized: .NOTMAIN' \
611 # expect: Parse_PushInput: target-call-parenthesized.tmp:1
612 # expect: Parse_PushInput: target-call-parenthesized.tmp:1
636 _:= ${fname:H:N.:@dir@${:!mkdir -p ${dir}!}@}
638 .MAKEFLAGS: -dp
642 .MAKEFLAGS: -d0