1 1.8 rillig # $NetBSD: varmod-order.mk,v 1.8 2022/01/15 12:35:18 rillig Exp $ 2 1.1 rillig # 3 1.6 rillig # Tests for the :O variable modifier and its variants, which either sort the 4 1.6 rillig # words of the value or shuffle them. 5 1.1 rillig 6 1.7 rillig WORDS= one two three four five six seven eight nine ten 7 1.7 rillig NUMBERS= 8 5 4 9 1 7 6 10 3 2 # in English alphabetical order 8 1.3 rillig 9 1.7 rillig .if ${WORDS:O} != "eight five four nine one seven six ten three two" 10 1.7 rillig . error ${WORDS:O} 11 1.3 rillig .endif 12 1.1 rillig 13 1.4 rillig # Unknown modifier "OX" 14 1.7 rillig _:= ${WORDS:OX} 15 1.4 rillig 16 1.4 rillig # Unknown modifier "OxXX" 17 1.7 rillig _:= ${WORDS:OxXX} 18 1.4 rillig 19 1.6 rillig # Missing closing brace, to cover the error handling code. 20 1.7 rillig _:= ${WORDS:O 21 1.6 rillig _:= ${NUMBERS:On 22 1.6 rillig _:= ${NUMBERS:Onr 23 1.6 rillig 24 1.6 rillig # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be 25 1.6 rillig # combined. 26 1.6 rillig # 27 1.8 rillig # expect: make: Bad modifier ":Oxn" for variable "NUMBERS" 28 1.6 rillig # expect+1: Malformed conditional (${NUMBERS:Oxn}) 29 1.6 rillig .if ${NUMBERS:Oxn} 30 1.6 rillig . error 31 1.6 rillig .else 32 1.6 rillig . error 33 1.6 rillig .endif 34 1.6 rillig 35 1.6 rillig # Extra characters after ':On' are detected and diagnosed. 36 1.6 rillig # TODO: Add line number information to the "Bad modifier" diagnostic. 37 1.6 rillig # 38 1.8 rillig # expect: make: Bad modifier ":On_typo" for variable "NUMBERS" 39 1.6 rillig .if ${NUMBERS:On_typo} 40 1.6 rillig . error 41 1.6 rillig .else 42 1.6 rillig . error 43 1.6 rillig .endif 44 1.6 rillig 45 1.6 rillig # Extra characters after ':Onr' are detected and diagnosed. 46 1.6 rillig # 47 1.8 rillig # expect: make: Bad modifier ":Onr_typo" for variable "NUMBERS" 48 1.6 rillig .if ${NUMBERS:Onr_typo} 49 1.6 rillig . error 50 1.6 rillig .else 51 1.6 rillig . error 52 1.6 rillig .endif 53 1.6 rillig 54 1.6 rillig # Extra characters after ':Orn' are detected and diagnosed. 55 1.6 rillig # 56 1.8 rillig # expect: make: Bad modifier ":Orn_typo" for variable "NUMBERS" 57 1.6 rillig .if ${NUMBERS:Orn_typo} 58 1.6 rillig . error 59 1.6 rillig .else 60 1.6 rillig . error 61 1.6 rillig .endif 62 1.6 rillig 63 1.6 rillig # Repeating the 'n' is not supported. In the typical use cases, the sorting 64 1.6 rillig # criteria are fixed, not computed, therefore allowing this redundancy does 65 1.6 rillig # not make sense. 66 1.6 rillig # 67 1.8 rillig # expect: make: Bad modifier ":Onn" for variable "NUMBERS" 68 1.6 rillig .if ${NUMBERS:Onn} 69 1.6 rillig . error 70 1.6 rillig .else 71 1.6 rillig . error 72 1.6 rillig .endif 73 1.6 rillig 74 1.6 rillig # Repeating the 'r' is not supported as well, for the same reasons as above. 75 1.6 rillig # 76 1.8 rillig # expect: make: Bad modifier ":Onrr" for variable "NUMBERS" 77 1.6 rillig .if ${NUMBERS:Onrr} 78 1.6 rillig . error 79 1.6 rillig .else 80 1.6 rillig . error 81 1.6 rillig .endif 82 1.6 rillig 83 1.6 rillig # Repeating the 'r' is not supported as well, for the same reasons as above. 84 1.6 rillig # 85 1.8 rillig # expect: make: Bad modifier ":Orrn" for variable "NUMBERS" 86 1.6 rillig .if ${NUMBERS:Orrn} 87 1.6 rillig . error 88 1.6 rillig .else 89 1.6 rillig . error 90 1.6 rillig .endif 91 1.6 rillig 92 1.1 rillig all: 93