configure: automatically define backend-specific constants 87/69287/17
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 30 May 2016 15:14:24 +0000 (17:14 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 1 Jun 2016 20:13:39 +0000 (22:13 +0200)
This commit moves previously explicitly specified DLOG_BACKEND_*
defines to be defined automatically by configure.

Change-Id: I1ed16036bd2214be75db6fdf3c5d12951e7d12e4

configure.ac
packaging/dlog.spec

index a515659..9f4d035 100755 (executable)
@@ -4,7 +4,6 @@
 AC_PREREQ(2.61)
 AC_INIT([dlog], [1.0], yk.yun@samsung.com)
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-AC_CONFIG_HEADERS([config.h:config.hin])
 
 # Init XO
 PLATFORM_INIT
@@ -15,43 +14,47 @@ AC_PROG_CC
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_LIBTOOL
 
-# check for libsystemd-journal
+# backend: journald
 AC_ARG_ENABLE(journal, AS_HELP_STRING([--enable-journal], [enable systemd journal]),
     [with_systemd_journal=yes],
     with_systemd_journal=no)
-
-#check for backends
-AC_ARG_ENABLE(pipe, AS_HELP_STRING([--enable-pipe], [enable pipe]),
-    [with_pipe=yes],
-    with_pipe=no)
-
-AC_ARG_ENABLE(kmsg, AS_HELP_STRING([--enable-kmsg], [enable kmsg]),
-    [with_kmsg=yes],
-    with_kmsg=no)
-
-AC_ARG_ENABLE(android_logger, AS_HELP_STRING([--enable-android-logger], [enable android logger]),
-    [with_android_logger=yes],
-    with_android_logger=no)
-
 if test "x$with_systemd_journal" != "xno"; then
        PKG_CHECK_MODULES(systemd_journal, [libsystemd-journal],
-               [AC_DEFINE(HAVE_SYSTEMD_JOURNAL, 1, [Define if systemd journal is available])
+               [AC_DEFINE(DLOG_BACKEND_JOURNAL, 1, [Define if systemd journal is selected])
                have_systemd_journal=yes],
-           have_systemd_journal=no)
+               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])
        fi
 fi
-AM_CONDITIONAL(HAVE_SYSTEMD_JOURNAL, [test "x$have_systemd_journal" = "xyes"])
-AM_CONDITIONAL(WITH_SYSTEMD_JOURNAL, [test "x$with_systemd_journal" = "xyes"])
+AM_CONDITIONAL(WITH_SYSTEMD_JOURNAL, [test "x$have_systemd_journal" = "xyes"])
+
+# backend: pipe
+AC_ARG_ENABLE(pipe, AS_HELP_STRING([--enable-pipe], [enable pipe (log to pipe fd received via unix socket)]),
+       [with_pipe=yes],
+       with_pipe=no)
+if test "x$with_pipe" = "xyes"; then
+       AC_DEFINE(DLOG_BACKEND_PIPE, 1, [Define if pipe backend is selected])
+fi
 AM_CONDITIONAL(WITH_PIPE, [test "x$with_pipe" = "xyes"])
-AM_CONDITIONAL(WITH_ANDROID_LOGGER, [test "x$with_android_logger" = "xyes"])
+
+# backend: kmsg (requires kernel patch)
+AC_ARG_ENABLE(kmsg, AS_HELP_STRING([--enable-kmsg], [enable kmsg (requires kmsg extension patch)]),
+       [with_kmsg=yes],
+       with_kmsg=no)
+if test "x$with_kmsg" = "xyes"; then
+       AC_DEFINE(DLOG_BACKEND_KMSG, 1, [Define if kmsg backend is selected])
+fi
 AM_CONDITIONAL(WITH_KMSG, [test "x$with_kmsg" = "xyes"])
 
-if test "x$have_systemd_journal" = "xyes" ; then
-       systemd_journal=systemd-journal
+# backend: android logger (requires kernel's CONFIG_ANDROID_LOGGER)
+AC_ARG_ENABLE(android_logger, AS_HELP_STRING([--enable-android-logger], [enable android logger (kernels CONFIG_ANDROID_LOGGER)]),
+       [with_android_logger=yes],
+       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])
 fi
-AC_SUBST(systemd_journal)
+AM_CONDITIONAL(WITH_ANDROID_LOGGER, [test "x$with_android_logger" = "xyes"])
 
 # check binary type for dlog debug mode
 AC_ARG_ENABLE([debug_mode],
@@ -99,6 +102,5 @@ PKG_CHECK_MODULES([CAPI_BASE_COMMON], [capi-base-common])
 AC_SUBST(TZ_SYS_ETC)
 
 # output files
-AC_CONFIG_FILES([Makefile dlog.pc]
-                               )
+AC_CONFIG_FILES([Makefile dlog.pc])
 AC_OUTPUT
index 3f388f8..10cf9a2 100755 (executable)
@@ -105,20 +105,7 @@ cp %{SOURCE102} .
                        --enable-debug_mode \
                        TZ_SYS_ETC=%{TZ_SYS_ETC}
 make %{?jobs:-j%jobs} \
-       CFLAGS+=-DTZ_SYS_ETC=\\\"%{TZ_SYS_ETC}\\\" \
-%if %{?backend_journal} == ON
-       CFLAGS+=-DDLOG_BACKEND_JOURNAL
-%endif
-%if %{?backend_kmsg} == ON
-       CFLAGS+=-DDLOG_BACKEND_KMSG
-%endif
-%if %{?backend_logger} == ON
-       CFLAGS+=-DDLOG_BACKEND_LOGGER
-%endif
-%if %{?backend_pipe} == ON
-       CFLAGS+=-DDLOG_BACKEND_PIPE
-%endif
-
+       CFLAGS+=-DTZ_SYS_ETC=\\\"%{TZ_SYS_ETC}\\\"
 
 %install
 rm -rf %{buildroot}