From b8a28fad544799a78bc8f59183c0638362b1484a Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 4 Dec 2018 09:21:18 +0100 Subject: [PATCH 1/4] buildsys: handle ac_cv_cunit as a true cache-val MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ac_cv_-prefix variables are supposed to be settable from the command line, à-la: ./configure ac_cv_foo=no The canonical way of doing so is to use AC_CACHE_VAL() or AC_CACHE_CHECK(). The latter is to be preferred in our case, as it handles printing the message for us. Signed-off-by: "Yann E. MORIN" --- configure.ac | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 4001400..54f9d4f 100644 --- a/configure.ac +++ b/configure.ac @@ -128,20 +128,18 @@ if test x"$libiscsi_cv_HAVE_LINUX_ISER" = x"yes"; then fi AM_CONDITIONAL([HAVE_LINUX_ISER], [test $libiscsi_cv_HAVE_LINUX_ISER = yes]) -AC_MSG_CHECKING(whether libcunit is available) -ac_save_CFLAGS="$CFLAGS" -ac_save_LIBS="$LIBS" -CFLAGS="$CFLAGS $GLIB_CFLAGS" -LIBS="$GLIB_LIBS $LIBS -lcunit" -AC_TRY_LINK([ -#include -], [], [ac_cv_have_cunit=yes], [ac_cv_have_cunit=no]) -CFLAGS="$ac_save_CFLAGS" -LIBS="$ac_save_LIBS" -if test "$ac_cv_have_cunit" = yes ; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) +AC_CACHE_CHECK([whether libcunit is available], + [ac_cv_have_cunit], + [ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS -lcunit" + AC_TRY_LINK([ + #include + ], [], [ac_cv_have_cunit=yes], [ac_cv_have_cunit=no]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS"]) +if ! test "$ac_cv_have_cunit" = yes ; then AC_MSG_NOTICE(You need libcunit to build the test suite.) AC_MSG_NOTICE(The scsi/iscsi test suite will not be built.) fi From fb2e460df9598a3f478036f1e95c7b39de4c3853 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 4 Dec 2018 08:30:09 +0100 Subject: [PATCH 2/4] buildsys: add option to enable/disable building tests When doing cross-compilation, the tests are meant to be run on the target. However, they are currently not installed, so it does not make sense to build tehm to start with. Additionally, when doing a system for production, those tests are not needed anyway. Add a configure option to disable building the tests altogether. Signed-off-by: "Yann E. MORIN" --- Makefile.am | 5 ++++- configure.ac | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7d8164a..60fe178 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,8 @@ # Generic definitions -SUBDIRS = lib doc utils test-tool tests examples +SUBDIRS = lib doc utils test-tool examples +if BUILD_TESTS +SUBDIRS += tests +endif ACLOCAL_AMFLAGS =-I m4 AUTOMAKE_OPTIONS = foreign subdir-objects diff --git a/configure.ac b/configure.ac index 54f9d4f..69cefd5 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,14 @@ AC_ARG_ENABLE([manpages], AM_CONDITIONAL(BUILD_MANPAGES, [expr "$ENABLE_MANPAGES" : yes > /dev/null 2>&1]) +AC_ARG_ENABLE([tests], + [AC_HELP_STRING([--enable-tests], + [Enable building tests])], + [ENABLE_TESTS=$enableval], + [ENABLE_TESTS=yes]) +AM_CONDITIONAL([BUILD_TESTS], + [expr "$ENABLE_TESTS" : yes > /dev/null 2>&1]) + AC_CONFIG_HEADER(config.h) AC_CHECK_LIB([gcrypt], [gcry_control]) From eec4954986dc3f9345169268e902c1c996adfb90 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 4 Dec 2018 08:34:35 +0100 Subject: [PATCH 3/4] buildsys: add option to enable/disable build of test-tool When doing a production system, the production environment has been pre-validated (with this test-toll or by other means), so the teest-tool is not needed in production. Add a configure option to disable building test-tool. Signed-off-by: "Yann E. MORIN" --- Makefile.am | 5 ++++- configure.ac | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 60fe178..be70526 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,8 @@ # Generic definitions -SUBDIRS = lib doc utils test-tool examples +SUBDIRS = lib doc utils examples +if BUILD_TEST_TOOL +SUBDIRS += test-tool +endif if BUILD_TESTS SUBDIRS += tests endif diff --git a/configure.ac b/configure.ac index 69cefd5..b95a5d8 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,14 @@ AC_ARG_ENABLE([manpages], AM_CONDITIONAL(BUILD_MANPAGES, [expr "$ENABLE_MANPAGES" : yes > /dev/null 2>&1]) +AC_ARG_ENABLE([test_tool], + [AC_HELP_STRING([--enable-test-tool], + [Enable building test-tool (to test a remote server)])], + [ENABLE_TEST_TOOL=$enableval], + [ENABLE_TEST_TOOL=yes]) +AM_CONDITIONAL([BUILD_TEST_TOOL], + [expr "$ENABLE_TEST_TOOL" : yes > /dev/null 2>&1]) + AC_ARG_ENABLE([tests], [AC_HELP_STRING([--enable-tests], [Enable building tests])], From a8d54cc82da8553753ceaafc9beeb7863e2f6741 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Tue, 4 Dec 2018 10:47:34 +0100 Subject: [PATCH 4/4] buildsys: add option to enable/disable building the examples In a production system, the examples are not needed. Add a configure option to disable building the examples. Signed-off-by: "Yann E. MORIN" --- Makefile.am | 5 ++++- configure.ac | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index be70526..6bc419f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,14 @@ # Generic definitions -SUBDIRS = lib doc utils examples +SUBDIRS = lib doc utils if BUILD_TEST_TOOL SUBDIRS += test-tool endif if BUILD_TESTS SUBDIRS += tests endif +if BUILD_EXAMPLES +SUBDIRS += examples +endif ACLOCAL_AMFLAGS =-I m4 AUTOMAKE_OPTIONS = foreign subdir-objects diff --git a/configure.ac b/configure.ac index b95a5d8..5fe1deb 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,14 @@ AC_ARG_ENABLE([tests], AM_CONDITIONAL([BUILD_TESTS], [expr "$ENABLE_TESTS" : yes > /dev/null 2>&1]) +AC_ARG_ENABLE([examples], + [AC_HELP_STRING([--enable-examples], + [Enable building examples])], + [ENABLE_EXAMPLES=$enableval], + [ENABLE_EXAMPLES=yes]) +AM_CONDITIONAL([BUILD_EXAMPLES], + [expr "$ENABLE_EXAMPLES" : yes > /dev/null 2>&1]) + AC_CONFIG_HEADER(config.h) AC_CHECK_LIB([gcrypt], [gcry_control])