xref: /freebsd/contrib/bmake/unit-tests/meta-cmd-cmp.mk (revision 1323ec571215a77ddd21294f0871979d5ad6b992)
1# $NetBSD: meta-cmd-cmp.mk,v 1.6 2022/03/02 19:32:15 sjg Exp $
2#
3# Tests META_MODE command line comparison
4#
5
6.MAIN: all
7
8.MAKE.MODE= meta verbose silent=yes curdirok=yes nofilemon
9tf:= .${.PARSEFILE:R}
10
11.if ${.TARGETS:Nall} == ""
12all: prep one two change1 change2 filter0 filter1 filter2 filter3 post
13
14CLEANFILES= ${tf}*
15
16prep post: .PHONY
17	@rm -f ${CLEANFILES}
18
19.endif
20
21FLAGS?=
22FLAGS2?=
23
24tests= ${tf}.cmp ${tf}.nocmp ${tf}.cmp2
25filter_tests= ${tf}.filter
26
27${tf}.cmp:
28	@echo FLAGS=${FLAGS:Uempty} > $@
29
30${tf}.nocmp: .NOMETA_CMP
31	@echo FLAGS=${FLAGS:Uempty} > $@
32
33# a line containing ${.OODATE} will not be compared
34# this allows the trick below
35${tf}.cmp2:
36	@echo FLAGS2=${FLAGS2:Uempty} > $@
37	@echo This line not compared FLAGS=${FLAGS:Uempty} ${.OODATE:MNOMETA_CMP}
38
39COMPILER_WRAPPERS= ccache distcc icecc
40WRAPPER?= ccache
41.ifdef WITH_CMP_FILTER
42.MAKE.META.CMP_FILTER+= ${COMPILER_WRAPPERS:S,^,N,}
43.endif
44.ifdef WITH_LOCAL_CMP_FILTER
45# local variable
46${tf}.filter: .MAKE.META.CMP_FILTER= ${COMPILER_WRAPPERS:S,^,N,}
47.endif
48
49${tf}.filter:
50	@echo ${WRAPPER} cc -c foo.c > $@
51
52# these do the same
53one two: .PHONY
54	@echo $@:
55	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} ${tests}
56
57change1: .PHONY
58	@echo $@:
59	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} FLAGS=changed ${tests}
60
61change2: .PHONY
62	@echo $@:
63	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} FLAGS2=changed ${tests}
64
65filter0: .PHONY
66	@echo $@:
67	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} ${filter_tests}
68
69filter1: .PHONY
70	@echo $@:
71	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} WRAPPER= ${filter_tests}
72
73filter2: .PHONY
74	@echo $@:
75	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} -DWITH_CMP_FILTER \
76		WRAPPER=distcc ${filter_tests}
77
78filter3: .PHONY
79	@echo $@:
80	@${.MAKE} -dM -r -C ${.CURDIR} -f ${MAKEFILE} -DWITH_LOCAL_CMP_FILTER \
81		WRAPPER=icecc ${filter_tests}
82
83# don't let gcov mess up the results
84.MAKE.META.IGNORE_PATTERNS+= *.gcda
85