]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/atf.test.mk
Merge branch 'releng/11.1' into releng-CDN/11.1
[FreeBSD/FreeBSD.git] / share / mk / atf.test.mk
1 # $FreeBSD$
2 #
3 # You must include bsd.test.mk instead of this file from your Makefile.
4 #
5 # Logic to build and install ATF test programs; i.e. test programs linked
6 # against the ATF libraries.
7
8 .if !target(__<bsd.test.mk>__)
9 .error atf.test.mk cannot be included directly.
10 .endif
11
12 # List of C, C++ and shell test programs to build.
13 #
14 # Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
15 # respectively, from bsd.prog.mk.  However, the build rules are tweaked to
16 # require the ATF libraries.
17 #
18 # Test programs registered in this manner are set to be installed into TESTSDIR
19 # (which should be overriden by the Makefile) and are not required to provide a
20 # manpage.
21 ATF_TESTS_C?=
22 ATF_TESTS_CXX?=
23 ATF_TESTS_SH?=
24
25 .if !empty(ATF_TESTS_C)
26 PROGS+= ${ATF_TESTS_C}
27 _TESTS+= ${ATF_TESTS_C}
28 .for _T in ${ATF_TESTS_C}
29 BINDIR.${_T}= ${TESTSDIR}
30 MAN.${_T}?= # empty
31 SRCS.${_T}?= ${_T}.c
32 DPADD.${_T}+= ${LIBATF_C}
33 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
34 LDADD.${_T}+= ${LDADD_atf_c}
35 .else
36 LDADD.${_T}+= ${LIBATF_C}
37 .endif
38 TEST_INTERFACE.${_T}= atf
39 .endfor
40 .endif
41
42 .if !empty(ATF_TESTS_CXX)
43 PROGS_CXX+= ${ATF_TESTS_CXX}
44 _TESTS+= ${ATF_TESTS_CXX}
45 .for _T in ${ATF_TESTS_CXX}
46 BINDIR.${_T}= ${TESTSDIR}
47 MAN.${_T}?= # empty
48 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
49 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
50 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
51 LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
52 .else
53 LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
54 .endif
55 TEST_INTERFACE.${_T}= atf
56 .endfor
57 .endif
58
59 .if !empty(ATF_TESTS_SH)
60 SCRIPTS+= ${ATF_TESTS_SH}
61 _TESTS+= ${ATF_TESTS_SH}
62 .for _T in ${ATF_TESTS_SH}
63 SCRIPTSDIR_${_T}= ${TESTSDIR}
64 TEST_INTERFACE.${_T}= atf
65 CLEANFILES+= ${_T} ${_T}.tmp
66 # TODO(jmmv): It seems to me that this SED and SRC functionality should
67 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
68 # this proves to be useful within the tests.
69 ATF_TESTS_SH_SED_${_T}?= # empty
70 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
71 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
72         echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
73 .if empty(ATF_TESTS_SH_SED_${_T})
74         cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
75 .else
76         cat ${.ALLSRC:N*Makefile*} \
77             | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
78 .endif
79         chmod +x ${.TARGET}.tmp
80         mv ${.TARGET}.tmp ${.TARGET}
81 .endfor
82 .endif