]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - share/mk/atf.test.mk
MFC r334394:
[FreeBSD/stable/10.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 LDADD.${_T}+= -latf-c
34 USEPRIVATELIB+= atf-c
35 TEST_INTERFACE.${_T}= atf
36 .endfor
37 .endif
38
39 .if !empty(ATF_TESTS_CXX)
40 PROGS_CXX+= ${ATF_TESTS_CXX}
41 _TESTS+= ${ATF_TESTS_CXX}
42 .for _T in ${ATF_TESTS_CXX}
43 BINDIR.${_T}= ${TESTSDIR}
44 MAN.${_T}?= # empty
45 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
46 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
47 LDADD.${_T}+= -latf-c++ -latf-c
48 USEPRIVATELIB+= atf-c++
49 TEST_INTERFACE.${_T}= atf
50 .endfor
51 .endif
52
53 .if !empty(ATF_TESTS_SH)
54 SCRIPTS+= ${ATF_TESTS_SH}
55 _TESTS+= ${ATF_TESTS_SH}
56 .for _T in ${ATF_TESTS_SH}
57 SCRIPTSDIR_${_T}= ${TESTSDIR}
58 TEST_INTERFACE.${_T}= atf
59 CLEANFILES+= ${_T} ${_T}.tmp
60 # TODO(jmmv): It seems to me that this SED and SRC functionality should
61 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
62 # this proves to be useful within the tests.
63 ATF_TESTS_SH_SED_${_T}?= # empty
64 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
65 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
66         echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
67 .if empty(ATF_TESTS_SH_SED_${_T})
68         cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
69 .else
70         cat ${.ALLSRC:N*Makefile*} \
71             | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
72 .endif
73         chmod +x ${.TARGET}.tmp
74         mv ${.TARGET}.tmp ${.TARGET}
75 .endfor
76 .endif