freebsd-dev/share/mk/bsd.test.mk
Julio Merino ada17d7bde Ensure files are created during the build when using bsd.subdir.mk.
When FILES is defined in a Makefile that _also_ includes bsd.subdir.mk, the
build of the files (if any) was not properly triggered during the build
stage.  This was because bsd.files.mk did not define the buildfiles target
if it was already defined... and bsd.subdir.mk defined this target on its
own, thus causing a conflict.

Fix this by unconditionally defining buildfiles from bsd.files.mk; this is
safe because nothing else in the tree needs to redefine this and because the
target itself contains no commands: all it does is define dependencies.
Also ensure that bsd.files.mk is always pulled in by bsd.test.mk regardless
of what bsd.prog.mk does.

These fixes allow "make installworld" to run cleanly on a system with
read-only src and obj trees.

This is "make tinderbox" clean.

Reviewed by:	imp
Obtained from:	jilles
2014-06-09 14:36:49 +00:00

89 lines
2.4 KiB
Makefile

# $FreeBSD$
#
# Generic build infrastructure for test programs.
#
# This is the only public file that should be included by Makefiles when
# tests are to be built. All other *.test.mk files are internal and not
# to be included directly.
.include <bsd.init.mk>
__<bsd.test.mk>__:
# List of subdirectories containing tests into which to recurse. This has the
# same semantics as SUBDIR at build-time. However, the directories listed here
# get registered into the run-time test suite definitions so that the test
# engines know to recurse into these directories.
#
# In other words: list here any directories that contain test programs but use
# SUBDIR for directories that may contain helper binaries and/or data files.
TESTS_SUBDIRS?=
# If defined, indicates that the tests built by the Makefile are not part of
# the FreeBSD Test Suite. The implication of this is that the tests won't be
# installed under /usr/tests/ and that Kyua won't be able to run them.
#NOT_FOR_TEST_SUITE=
# List of variables to pass to the tests at run-time via the environment.
TESTS_ENV?=
# Ordered list of directories to construct the PATH for the tests.
TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
# List of all tests being built. The various *.test.mk modules extend this
# variable as needed.
_TESTS=
# Pull in the definitions of all supported test interfaces.
.include <atf.test.mk>
.include <plain.test.mk>
.include <tap.test.mk>
.if !empty(TESTS_SUBDIRS)
SUBDIR+= ${TESTS_SUBDIRS}
.endif
# it is rare for test cases to have man pages
.if !defined(MAN)
MAN=
.endif
# tell progs.mk we might want to install things
PROG_VARS+= BINDIR
PROGS_TARGETS+= install
.if !defined(NOT_FOR_TEST_SUITE)
.include <suite.test.mk>
.endif
.if !target(realtest)
realtest: .PHONY
@echo "$@ not defined; skipping"
.endif
test: .PHONY
.ORDER: beforetest realtest
test: beforetest realtest
.if target(aftertest)
.ORDER: realtest aftertest
test: aftertest
.endif
.if !empty(SUBDIR)
.include <bsd.subdir.mk>
.endif
.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
.include <bsd.progs.mk>
.endif
.include <bsd.files.mk>
.include <bsd.obj.mk>