configure: Allow exactly one backend to be selected
[platform/core/system/dlog.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.61)
5 AC_INIT([dlog], [1.0], yk.yun@samsung.com)
6 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
7
8 # Init XO
9 PLATFORM_INIT
10
11 # Checks for programs.
12 dnl AC_PROG_CXX
13 AC_PROG_CC
14 AC_PROG_GCC_TRADITIONAL
15 AC_PROG_LIBTOOL
16
17 __dlog_backends_selected=0
18
19 # backend: journald
20 AC_ARG_ENABLE(journal, AS_HELP_STRING([--enable-journal], [enable systemd journal]),
21     [with_systemd_journal=yes],
22     with_systemd_journal=no)
23 if test "x$with_systemd_journal" != "xno"; then
24         PKG_CHECK_MODULES(systemd_journal, [libsystemd-journal],
25                 [AC_DEFINE(DLOG_BACKEND_JOURNAL, 1, [Define if systemd journal is selected])
26                 have_systemd_journal=yes],
27                 have_systemd_journal=no)
28         if test "x$have_systemd_journal" = "xno" -a "x$with_systemd_journal" = "xyes"; then
29                 AC_MSG_ERROR([systemd journal requested but libraries not found])
30         else
31                 __dlog_backends_selected=$(($__dlog_backends_selected + 1))
32         fi
33 fi
34 AM_CONDITIONAL(WITH_SYSTEMD_JOURNAL, [test "x$have_systemd_journal" = "xyes"])
35
36 # backend: pipe
37 AC_ARG_ENABLE(pipe, AS_HELP_STRING([--enable-pipe], [enable pipe (log to pipe fd received via unix socket)]),
38         [with_pipe=yes],
39         with_pipe=no)
40 if test "x$with_pipe" = "xyes"; then
41         AC_DEFINE(DLOG_BACKEND_PIPE, 1, [Define if pipe backend is selected])
42         __dlog_backends_selected=$(($__dlog_backends_selected + 1))
43 fi
44 AM_CONDITIONAL(WITH_PIPE, [test "x$with_pipe" = "xyes"])
45
46 # backend: kmsg (requires kernel patch)
47 AC_ARG_ENABLE(kmsg, AS_HELP_STRING([--enable-kmsg], [enable kmsg (requires kmsg extension patch)]),
48         [with_kmsg=yes],
49         with_kmsg=no)
50 if test "x$with_kmsg" = "xyes"; then
51         AC_DEFINE(DLOG_BACKEND_KMSG, 1, [Define if kmsg backend is selected])
52         __dlog_backends_selected=$(($__dlog_backends_selected + 1))
53 fi
54 AM_CONDITIONAL(WITH_KMSG, [test "x$with_kmsg" = "xyes"])
55
56 # backend: android logger (requires kernel's CONFIG_ANDROID_LOGGER)
57 AC_ARG_ENABLE(android_logger, AS_HELP_STRING([--enable-android-logger], [enable android logger (kernels CONFIG_ANDROID_LOGGER)]),
58         [with_android_logger=yes],
59         with_android_logger=no)
60 if test "x$with_android_logger" = "xyes"; then
61         AC_DEFINE(DLOG_BACKEND_LOGGER, 1, [Define if (legacy) android logger backend is selected])
62         __dlog_backends_selected=$(($__dlog_backends_selected + 1))
63 fi
64 AM_CONDITIONAL(WITH_ANDROID_LOGGER, [test "x$with_android_logger" = "xyes"])
65
66 if test $__dlog_backends_selected -ne 1; then
67         AC_MSG_ERROR([Exactly one backend needs to be selected.])
68 fi
69
70 # check binary type for dlog debug mode
71 AC_ARG_ENABLE([debug_mode],
72         AS_HELP_STRING([--enable-debug_mode Turn on debug_mode]),
73                 [debug_mode=yes],
74                 debug_mode=no)
75 if test "x$debug_mode" = "xyes" ; then
76         DEBUG_CFLAGS+=" -DDLOG_DEBUG_ENABLE"
77 fi
78 AC_ARG_ENABLE([debug_enable],
79         AS_HELP_STRING([--enable-debug_enable Turn on debug_enable]),
80                 [debug_enable=yes],
81             debug_enable=no)
82 # check for fatal_on
83 AC_ARG_ENABLE([fatal_on],
84         AS_HELP_STRING([--enable-fatal_on Turn on fatal assertion]),
85                 [fatal_on=yes],
86             fatal_on=no)
87 if test "x$fatal_on" = "xyes" ; then
88         DEBUG_CFLAGS+=" -DFATAL_ON"
89 fi
90 AC_SUBST(DEBUG_CFLAGS)
91 # Checks for libraries.
92 # Checks for header files.
93 AC_HEADER_STDC
94 AC_CHECK_HEADERS([stdlib.h unistd.h ])
95
96 # Checks for typedefs, structures, and compiler characteristics.
97 AC_HEADER_STDBOOL
98 AC_C_CONST
99 AC_C_INLINE
100 AC_STRUCT_TM
101 AC_TYPE_PID_T
102 AC_TYPE_SIZE_T
103 AC_TYPE_SSIZE_T
104
105 # Checks for library functions.
106 AC_FUNC_MALLOC
107 AC_FUNC_STAT
108 AC_CHECK_FUNCS([memset])
109
110 PKG_PROG_PKG_CONFIG
111 PKG_CHECK_MODULES([CAPI_BASE_COMMON], [capi-base-common])
112
113 AC_SUBST(TZ_SYS_ETC)
114
115 # output files
116 AC_CONFIG_FILES([Makefile dlog.pc])
117 AC_OUTPUT