configure: Allow exactly one backend to be selected 31/69331/16
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 30 May 2016 15:15:00 +0000 (17:15 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 1 Jun 2016 20:13:39 +0000 (22:13 +0200)
Change-Id: Iae4e84b2a7b66727725f3ec11c7db07cb98f5371

configure.ac

index 9f4d035..79d1046 100755 (executable)
@@ -14,6 +14,8 @@ AC_PROG_CC
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_LIBTOOL
 
+__dlog_backends_selected=0
+
 # backend: journald
 AC_ARG_ENABLE(journal, AS_HELP_STRING([--enable-journal], [enable systemd journal]),
     [with_systemd_journal=yes],
@@ -25,6 +27,8 @@ if test "x$with_systemd_journal" != "xno"; then
                have_systemd_journal=no)
        if test "x$have_systemd_journal" = "xno" -a "x$with_systemd_journal" = "xyes"; then
                AC_MSG_ERROR([systemd journal requested but libraries not found])
+       else
+               __dlog_backends_selected=$(($__dlog_backends_selected + 1))
        fi
 fi
 AM_CONDITIONAL(WITH_SYSTEMD_JOURNAL, [test "x$have_systemd_journal" = "xyes"])
@@ -35,6 +39,7 @@ AC_ARG_ENABLE(pipe, AS_HELP_STRING([--enable-pipe], [enable pipe (log to pipe fd
        with_pipe=no)
 if test "x$with_pipe" = "xyes"; then
        AC_DEFINE(DLOG_BACKEND_PIPE, 1, [Define if pipe backend is selected])
+       __dlog_backends_selected=$(($__dlog_backends_selected + 1))
 fi
 AM_CONDITIONAL(WITH_PIPE, [test "x$with_pipe" = "xyes"])
 
@@ -44,6 +49,7 @@ AC_ARG_ENABLE(kmsg, AS_HELP_STRING([--enable-kmsg], [enable kmsg (requires kmsg
        with_kmsg=no)
 if test "x$with_kmsg" = "xyes"; then
        AC_DEFINE(DLOG_BACKEND_KMSG, 1, [Define if kmsg backend is selected])
+       __dlog_backends_selected=$(($__dlog_backends_selected + 1))
 fi
 AM_CONDITIONAL(WITH_KMSG, [test "x$with_kmsg" = "xyes"])
 
@@ -53,9 +59,14 @@ AC_ARG_ENABLE(android_logger, AS_HELP_STRING([--enable-android-logger], [enable
        with_android_logger=no)
 if test "x$with_android_logger" = "xyes"; then
        AC_DEFINE(DLOG_BACKEND_LOGGER, 1, [Define if (legacy) android logger backend is selected])
+       __dlog_backends_selected=$(($__dlog_backends_selected + 1))
 fi
 AM_CONDITIONAL(WITH_ANDROID_LOGGER, [test "x$with_android_logger" = "xyes"])
 
+if test $__dlog_backends_selected -ne 1; then
+       AC_MSG_ERROR([Exactly one backend needs to be selected.])
+fi
+
 # check binary type for dlog debug mode
 AC_ARG_ENABLE([debug_mode],
        AS_HELP_STRING([--enable-debug_mode Turn on debug_mode]),