summaryrefslogtreecommitdiffstats
path: root/build/pymake/tests/automatic-variables.mk
blob: 5302c08ead3ef13619857a0e0464364c9ac521e7 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$(shell \
mkdir -p src/subd; \
mkdir subd; \
touch dummy; \
sleep 2; \
touch subd/test.out src/subd/test.in2; \
sleep 2; \
touch subd/test.out2 src/subd/test.in; \
sleep 2; \
touch subd/host_test.out subd/host_test.out2; \
sleep 2; \
touch host_prog; \
)

VPATH = src

all: prog host_prog prog dir/
	test "$@" = "all"
	test "$<" = "prog"
	test "$^" = "prog host_prog dir"
	test "$?" = "prog host_prog dir"
	test "$+" = "prog host_prog prog dir"
	test "$(@D)" = "."
	test "$(@F)" = "all"
	test "$(<D)" = "."
	test "$(<F)" = "prog"
	test "$(^D)" = ". . ."
	test "$(^F)" = "prog host_prog dir"
	test "$(?D)" = ". . ."
	test "$(?F)" = "prog host_prog dir"
	test "$(+D)" = ". . . ."
	test "$(+F)" = "prog host_prog prog dir"
	@echo TEST-PASS

dir/:
	test "$@" = "dir"
	test "$<" = ""
	test "$^" = ""
	test "$(@D)" = "."
	test "$(@F)" = "dir"
	mkdir $@

prog: subd/test.out subd/test.out2
	test "$@" = "prog"
	test "$<" = "subd/test.out"
	test "$^" = "subd/test.out subd/test.out2" # ^
	test "$?" = "subd/test.out subd/test.out2" # ?
	cat $<
	test "$$(cat $<)" = "remade"
	test "$$(cat $(word 2,$^))" = ""

host_prog: subd/host_test.out subd/host_test.out2
	@echo TEST-FAIL No need to remake

%.out: %.in dummy
	test "$@" = "subd/test.out"
	test "$*" = "subd/test"              # *
	test "$<" = "src/subd/test.in"       # <
	test "$^" = "src/subd/test.in dummy" # ^
	test "$?" = "src/subd/test.in"       # ?
	test "$+" = "src/subd/test.in dummy" # +
	test "$(@D)" = "subd"
	test "$(@F)" = "test.out"
	test "$(*D)" = "subd"
	test "$(*F)" = "test"
	test "$(<D)" = "src/subd"
	test "$(<F)" = "test.in"
	test "$(^D)" = "src/subd ."          # ^D
	test "$(^F)" = "test.in dummy"
	test "$(?D)" = "src/subd"
	test "$(?F)" = "test.in"
	test "$(+D)" = "src/subd ."          # +D
	test "$(+F)" = "test.in dummy"
	printf "remade" >$@

%.out2: %.in2 dummy
	@echo TEST_FAIL No need to remake

.PHONY: all