From d21ad441bf94e7a61015c6a7599f8901281e8fbb Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 6 Jan 2013 11:28:07 -0800 Subject: [PATCH] Add check for libcunit and only build the test suite if libcunit is available --- Makefile.am | 4 ++++ configure.ac | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Makefile.am b/Makefile.am index 83047e6..296f5e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -163,6 +163,10 @@ bin_iscsi_test_SOURCES = test-tool/iscsi-test.c \ test-tool/1144_persistent_reserve_access_check_eaar.c \ test-tool/1145_persistent_reserve_access_check_wear.c +endif + + +if ISCSITEST # libiscsi test tool using cunit noinst_PROGRAMS += bin/iscsi-test-cu diff --git a/configure.ac b/configure.ac index f40b890..b6fe383 100644 --- a/configure.ac +++ b/configure.ac @@ -81,5 +81,35 @@ else fi AM_CONDITIONAL(PROGRAMS, [test "$ac_cv_have_popt" = 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_RUN([ +/* + * Just see if we can compile/link with libcunit + */ +#include + +int main(int argc, const char *argv[]) +{ + return 0; +} +], ac_cv_have_cunit=yes, ac_cv_have_cunit=no, + [echo $ac_n "compile with CUNIT. Assuming OK... $ac_c" + ac_cv_have_cunit=yes]) +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_MSG_NOTICE(You need libcunit to build the test suite.) + AC_MSG_NOTICE(The scsi/iscsi test suite will not be built.) +fi +AM_CONDITIONAL(ISCSITEST, [test "$ac_cv_have_cunit" = yes]) + + AC_CONFIG_FILES(Makefile) AC_OUTPUT