From e4fefe520d58547935b2c4147dd6b712b9047c1e Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Tue, 11 Oct 2016 22:48:42 +0200 Subject: build: check for test dependencies properly --- Makefile.am | 4 +-- configure.ac | 85 ++++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/Makefile.am b/Makefile.am index bcfc2ac..25098d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -243,7 +243,7 @@ MAINTAINERCLEANFILES += \ $(dist_man_MANS) \ $(NULL) -if USE_RONN +if BUILD_MANPAGE blogc.1: man/blogc.1.ronn $(AM_V_GEN)$(RONN) \ @@ -655,7 +655,7 @@ TESTS = \ ## Helpers: dist-srpm -if USE_RPMBUILD +if BUILD_SRPM dist-srpm: blogc.spec dist-xz $(RPMBUILD) \ --define "_srcrpmdir $(top_builddir)" \ diff --git a/configure.ac b/configure.ac index 55e860b..2886527 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ AS_IF([test "x$have_rpmbuild" = "xyes"], , [ AC_MSG_ERROR([rpmbuild requested but not found]) ]) ]) -AM_CONDITIONAL([USE_RPMBUILD], [test "x$ac_cv_path_rpmbuild" != "x"]) +AM_CONDITIONAL([BUILD_SRPM], [test "x$ac_cv_path_rpmbuild" != "x"]) RPMBUILD="$ac_cv_path_rpmbuild" AC_SUBST(RPMBUILD) @@ -61,7 +61,7 @@ AS_IF([test "x$have_ronn" = "xyes"], , [ AC_MSG_ERROR([ronn requested but not found]) ]) ]) -AM_CONDITIONAL([USE_RONN], [test "x$have_ronn" = "xyes"]) +AM_CONDITIONAL([BUILD_MANPAGE], [test "x$have_ronn" = "xyes"]) RONN="$ac_cv_path_ronn" AC_SUBST(RONN) @@ -84,10 +84,40 @@ AM_CONDITIONAL([USE_VALGRIND], [test "x$have_valgrind" = "xyes"]) VALGRIND="$ac_cv_path_valgrind" AC_SUBST(VALGRIND) +GIT_RECEIVER="disabled" +AC_ARG_ENABLE([git-receiver], AS_HELP_STRING([--enable-git-receiver], + [build blogc-git-receiver tool])) +AS_IF([test "x$enable_git_receiver" = "xyes"], [ + AC_CHECK_HEADERS([sys/types.h sys/stat.h sys/wait.h time.h libgen.h unistd.h errno.h dirent.h], [ + GIT_RECEIVER="enabled" + have_git_receiver=yes + ], [ + AC_MSG_ERROR([blogc-git-receiver tool requested but required headers not found]) + ]) +]) +AM_CONDITIONAL([BUILD_GIT_RECEIVER], [test "x$have_git_receiver" = "xyes"]) + +RUNSERVER="disabled" +AC_ARG_ENABLE([runserver], AS_HELP_STRING([--enable-runserver], + [build blogc-runserver tool])) +AS_IF([test "x$enable_runserver" = "xyes"], [ + AC_CHECK_HEADERS([signal.h limits.h fcntl.h unistd.h sys/stat.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h],, [ + AC_MSG_ERROR([blogc-runserver tool requested but required headers not found]) + ]) + AX_PTHREAD([], [ + AC_MSG_ERROR([blogc-runserver tool requested but pthread is not supported]) + ]) + RUNSERVER="enabled" + have_runserver=yes +]) +AM_CONDITIONAL([BUILD_RUNSERVER], [test "x$have_runserver" = "xyes"]) + TESTS="disabled" AC_ARG_ENABLE([tests], AS_HELP_STRING([--disable-tests], [disable unit tests, ignoring presence of cmocka])) AS_IF([test "x$enable_tests" != "xno"], [ + TESTS="enabled" + have_tests=yes PKG_CHECK_MODULES([CMOCKA], [cmocka], [ AC_MSG_CHECKING([whether the linker supports -wrap]) save_LDFLAGS="$LDFLAGS" @@ -99,7 +129,6 @@ AS_IF([test "x$enable_tests" != "xno"], [ [exit(1);] ]) ], [ - TESTS="enabled" have_cmocka=yes ], [ have_cmocka=no @@ -111,41 +140,35 @@ AS_IF([test "x$enable_tests" != "xno"], [ ], [ have_cmocka=no ]) -]) -AS_IF([test "x$have_cmocka" = "xyes"], , [ - AS_IF([test "x$enable_tests" = "xyes"], [ - AC_MSG_ERROR([unit tests requested but cmocka not found]) - ]) -]) -AM_CONDITIONAL([USE_CMOCKA], [test "x$have_cmocka" = "xyes"]) - -GIT_RECEIVER="disabled" -AC_ARG_ENABLE([git-receiver], AS_HELP_STRING([--enable-git-receiver], - [build blogc-git-receiver tool])) -AS_IF([test "x$enable_git_receiver" = "xyes"], [ - AC_CHECK_HEADERS([sys/types.h sys/stat.h sys/wait.h time.h libgen.h unistd.h errno.h dirent.h], [ - GIT_RECEIVER="enabled" - have_git_receiver=yes + AC_PATH_PROG([git], [git]) + AC_PATH_PROG([tee], [tee]) + AC_PATH_PROG([tar], [tar]) + AS_IF([test "x$ac_cv_path_git" = "x" -o "x$ac_cv_path_tee" = "x" -o "x$ac_cv_path_tar" = "x"], [ + have_bgr_deps=no ], [ - AC_MSG_ERROR([blogc-git-receiver tool requested but required headers not found]) + have_bgr_deps=yes ]) +], [ + have_tests=no ]) -AM_CONDITIONAL([BUILD_GIT_RECEIVER], [test "x$have_git_receiver" = "xyes"]) -RUNSERVER="disabled" -AC_ARG_ENABLE([runserver], AS_HELP_STRING([--enable-runserver], - [build blogc-runserver tool])) -AS_IF([test "x$enable_runserver" = "xyes"], [ - AC_CHECK_HEADERS([signal.h limits.h fcntl.h unistd.h sys/stat.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h],, [ - AC_MSG_ERROR([blogc-runserver tool requested but required headers not found]) +AS_IF([test "x$have_tests" = "xyes"], [ + AS_IF([test "x$have_cmocka" = "xyes"], [ + TESTS="${TESTS} +cmocka" + ], [ + AC_MSG_ERROR([unit tests requested but cmocka not found]) ]) - AX_PTHREAD([], [ - AC_MSG_ERROR([blogc-runserver tool requested but pthread is not supported]) + AS_IF([test "x$have_bgr_deps" = "xyes"], [ + TESTS="${TESTS} +blogc-git-receiver" + ], [ + AS_IF([test "x$have_git_receiver" = "xyes"], [ + AC_MSG_ERROR([unit tests requested for blogc-git-receiver but git, tar and tee not found]) + ]) ]) - RUNSERVER="enabled" - have_runserver=yes ]) -AM_CONDITIONAL([BUILD_RUNSERVER], [test "x$have_runserver" = "xyes"]) +AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" = "xyes"]) +AM_CONDITIONAL([USE_CMOCKA], [test "x$have_cmocka" = "xyes"]) +AM_CONDITIONAL([USE_BGR_DEPS], [test "x$have_bgr_deps" = "xyes"]) AC_CHECK_HEADERS([sys/stat.h time.h]) -- cgit v1.2.3-18-g5258