For some builds, e.g. inside a minimal buildroot image, we may not want the
tests to be built. Add an option --disable-tests to configure to disable
building the tests.
Signed-off-by: Christopher Obbard <
christoph...@linaro.org>
---
Makefile.am | 9 ++++++++-
configure.ac | 12 +++++++++++-
tools/tests/Makefile.am | 3 +++
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index bb97df255dfb9c8a145eba3ed8dcc58ab9bd124b..160d211c3f12d14cf7a136e0dd36e21fa5f0673a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,8 +369,15 @@ clean-local-completion-pycache:
check-valgrind-local: $(GEN_VERSION_H)
+SUBDIRS = .
+
# Tests depend on libraries being built - start with "."
-SUBDIRS = . tools/tests
+if BUILD_TESTS
+SUBDIRS += tools/tests
+endif
+
+# Include the tests always for distribution
+EXTRA_DIST = tools/tests
FORCE:
diff --git a/
configure.ac b/
configure.ac
index 36fc8d55e4190766871b8f9b5ea5bbaff5e24dde..6bfc1ec295666137bf2fff00608f296ba67b4336 100644
--- a/
configure.ac
+++ b/
configure.ac
@@ -281,6 +281,12 @@ AS_IF([test "x$enable_completion" != "xno"],
])
AM_CONDITIONAL([COMPLETION], [test "x$enable_completion" != "xno"])
+AC_ARG_ENABLE([tests],
+ [AS_HELP_STRING([--disable-tests], [Disable building tests])],
+ [], [enable_tests=yes])
+
+AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" != "xno"])
+
AX_VALGRIND_DFLT(memcheck, on)
AX_VALGRIND_DFLT(helgrind, off)
AX_VALGRIND_DFLT(drd, off)
@@ -290,10 +296,14 @@ AX_VALGRIND_CHECK
# ------------------------------------------------------------------------------
AC_CONFIG_FILES([
Makefile
- tools/tests/Makefile
libebgenv.pc
])
+# Only configure tools/tests/Makefile if tests are enabled
+if test "x$enable_tests" != "xno"; then
+ AC_CONFIG_FILES([tools/tests/Makefile])
+fi
+
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE_NAME $VERSION
diff --git a/tools/tests/Makefile.am b/tools/tests/Makefile.am
index d3fa5368c99f0b484fbb6fd57b848c581957aaef..7e3ac1e74b3456950033daa2586e60bea5913e0b 100644
--- a/tools/tests/Makefile.am
+++ b/tools/tests/Makefile.am
@@ -11,6 +11,7 @@
#
# SPDX-License-Identifier: GPL-2.0-only
#
+if BUILD_TESTS
OBJCOPY ?= objcopy
@@ -110,3 +111,5 @@ test_fat_LDADD = $(FAT_TESTLIB) $(LIBCHECK_LIBS)
TESTS = $(check_PROGRAMS)
@VALGRIND_CHECK_RULES@
+
+endif
---
base-commit: 452020920b3fe00ae0e2dc9d06f103107ded15c4
change-id: 20250224-wip-obbardc-disable-tests-fd6857b8ee49
Best regards,
--
Christopher Obbard <
christoph...@linaro.org>