summaryrefslogtreecommitdiff
path: root/dmake/tests/function_macros-2
blob: c17501f2aa5d441c79e8220860d00fae4f2f8ee4 (plain)
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
#!/bin/sh

# 01.06.2005 Volker Quetschke
# Tests for dmake function macros - part 2.
# (issue 36027, issue 37053, issue 37491)

: ${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
PAT:=Z

all:
	+@echo -e '\n\$\$(shell ...) section'
	+test ":123:" = ":\$(shell echo 123  ):"
	+test ":123:" = ":\$(shell   \
     echo 123  ):"
	+test ":123:" = ":\$(shell echo \
     123  ):"

	+@echo -e '\n\$\$(sort ...) section'
	+test ":a b c:" = ":\$(sort c  a b   ):"
	+test ":a b c:" = ":\$(sort\
     c  a b   ):"
	+test ":a b c:" = ":\$(sort   c \
    a b   ):"

	+@echo -e '\n\$\$(strip ...) section'
	+test ":c a b:" = ":\$(strip    c   a b   ):"
	+test ":c a b:" = ":\$(strip    c \
     a b   ):"

	+@echo -e '\n\$\$(subst ...) section' 
	+test ":aZbZc:" = ":\$(subst,\$(SPACECHAR),\$(PAT) \$(TEST1)):"
	+test ":aZbZc:" = ":\$(subst,%Z*Z%,\$(PAT) \$(TEST1:s/ /%Z*Z%/)):"
	+test ":aZbZc:" = ":\$(subst,Y,\$(PAT)       aYbYc         ):"
	+test ":aZbZc:" = ":{\$(subst,Y,Z       aYbYc         )}:"
# Undefined
#	+test ":Should error out:BUG:\$(subst, ,\$(PAT) \$(TEST1)):"

	+@echo -e '\n\$\$(uniq ...) section'
	+test ":a b c:" = ":\$(uniq    c   a b c ):"
	+test ":a b c:" = ":\$(uniq    c   \
     a b c ):"

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