1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/bin/sh
# 01.06.2005 Volker Quetschke
# Tests for dmake function macros. (issue 36027, issue 37053)
: ${DMAKEPROG:=dmake}
file1="mymakefile.mk"
tmpfiles="$file1"
trap '{ echo "trapped signal - removing temporary files" ; rm -rf $tmpfiles ; }' 1 2 3 15
trap 'rm -rf $tmpfiles' 1 2 3 15
# Remember to quote variables in generated makefiles( $ -> \$ ).
cat > $file1 <<EOT
# Testing function macros
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce
TEST1:=a b c
all:
@echo \$\$(and ...) section
test "::" = ":\$(and \$(nil) \$(nil) ):"
test ":t:" = ":\$(and a b ):"
test "::" = ":\$(and \$(nil) \
\$(nil) ):"
test "::" = ":\$(and \
):"
@echo -e \n\$\$(assign ...) section
test ":A:" = ":\$(assign A := B ):"
test "\$(A)" = "B"
test ":A:" = ":\$(assign A\
:= C ):"
test "\$(A)" = "C"
@echo -e \n\$\$(echo ...) section
test ":123:" = ":\$(echo 123 ):"
test ":123:" = ":\$(echo 123 ):"
test ":123:" = ":\$(echo\
123 ):"
test ":123:" = ":\$(echo \
123 ):"
@echo -e \n\$\$(eq ...) section
test ":true:" = ":\$(eq,1,1 true false):"
test ":true:" = ":\$(eq,1,1\
true false):"
# These tests need to use a shell
+@echo -e '\n\$\$(foreach ...) section'
+test ":[a] [b] [c]:" = ":\$(foreach,i,\$(TEST1) [\$i]):"
+test ":[a] [b] [c]:" = ":\$(foreach,i,\$(TEST1) [\$i]):"
+test ":[a] [b] [c]:" = ":\$(foreach,i,\$(TEST1) [\$i] ):"
+test ":[a] [b] [c]:" = ":\$(foreach,i,\$(TEST1) \
[\$i] ):"
@echo -e \n\$\$(nil ...) section
test "::" = ":\$(nil abc):"
# Fails with syntax error
test "::" = ":\$(nil \
):"
@echo -e \n\$\$(not ...) section
test "::" = ":\$(not abc):"
test ":t:" = ":\$(not \$(NULL)):"
test ":t:" = ":\$(not ):"
test ":t:" = ":\$(not \
):"
@echo -e \n\$\$(null ...) section
test ":true:" = ":\$(null, true false):"
test ":false:" = ":\$(null,a true false):"
test ":false:" = ":\$(null,a true false ):"
test ":false:" = ":\$(null,a \
true false ):"
test ":true:" = ":\$(null, \
true false ):"
@echo -e \n\$\$(or ...) section
test "::" = ":\$(or \$(nil) \$(nil) ):"
test ":t:" = ":\$(or a \$(nil) ):"
test "::" = ":\$(or \$(nil) \
\$(nil) ):"
test "::" = ":\$(or \
):"
EOT
${DMAKEPROG} -r -f $file1
result=$?
test $result -eq 0 && echo "Success - Cleaning up" && rm -f ${tmpfiles}
test $result -ne 0 && echo "Failure!"
exit $result
|