1 1.4 rillig # $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $ 2 1.1 sjg # 3 1.1 sjg # Tests for the :On variable modifier, which returns the words, sorted in 4 1.1 sjg # ascending numeric order. 5 1.1 sjg 6 1.2 rillig # This list contains only 32-bit numbers since the make code needs to conform 7 1.2 rillig # to C90, which does not provide integer types larger than 32 bit. It uses 8 1.2 rillig # 'long long' by default, but that type is overridable if necessary. 9 1.2 rillig # To get 53-bit integers even in C90, it would be possible to switch to 10 1.2 rillig # 'double' instead, but that would allow floating-point numbers as well, which 11 1.2 rillig # is out of scope for this variable modifier. 12 1.2 rillig NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G 13 1.1 sjg 14 1.2 rillig .if ${NUMBERS:On} != "-2G -3m -42 1 3 5 7 42 1k 5K 1M" 15 1.1 sjg . error ${NUMBERS:On} 16 1.1 sjg .endif 17 1.1 sjg 18 1.2 rillig .if ${NUMBERS:Orn} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G" 19 1.1 sjg . error ${NUMBERS:Orn} 20 1.1 sjg .endif 21 1.1 sjg 22 1.2 rillig # Both ':Onr' and ':Orn' have the same effect. 23 1.2 rillig .if ${NUMBERS:Onr} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G" 24 1.2 rillig . error ${NUMBERS:Onr} 25 1.2 rillig .endif 26 1.2 rillig 27 1.4 rillig # If there are several numbers that have the same integer value, they are 28 1.4 rillig # returned in unspecified order. 29 1.4 rillig SAME_VALUE:= ${:U 79 80 0x0050 81 :On} 30 1.4 rillig .if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81" 31 1.4 rillig . error ${SAME_VALUE} 32 1.2 rillig .endif 33 1.2 rillig 34 1.4 rillig # Hexadecimal and octal numbers are supported as well. 35 1.4 rillig OCTAL= 0 010 0x7 9 36 1.4 rillig .if ${OCTAL:On} != "0 0x7 010 9" 37 1.4 rillig . error ${OCTAL:On} 38 1.2 rillig .endif 39 1.2 rillig 40 1.1 sjg all: 41