plugins: added dbus core plugin.
[profile/ivi/murphy.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.59)
5
6 AC_INIT([murphy],
7         m4_esyscmd([build-aux/git-version-gen .tarball-version]),
8         [krisztian.litkey at intel.com])
9
10 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_SRCDIR([src])
12 AC_CONFIG_HEADER([src/config.h])
13 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
14
15 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
16
17 m4_define(version_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`)
18 m4_define(version_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`)
19 m4_define(version_patch, `echo $VERSION | cut -d. -f3 | cut -d- -f1`)
20
21 AC_SUBST(VERSION)
22 AC_SUBST(VERSION_MAJOR, version_major)
23 AC_SUBST(VERSION_MINOR, version_minor)
24 AC_SUBST(VERSION_PATCH, version_patch)
25 AC_SUBST(VERSION_FULL, version_major.version_minor.version_patch)
26
27 MURPHY_VERSION_INFO="0:0:0"
28 AC_SUBST(MURPHY_VERSION_INFO)
29
30 # Disable static libraries.
31 AC_DISABLE_STATIC
32
33 # Checks for programs.
34 AC_PROG_CC
35 AC_PROG_CC_C99
36 AC_PROG_AWK
37 AC_PROG_INSTALL
38 AM_PROG_CC_C_O
39 AM_PROG_LIBTOOL
40
41 # Checks for libraries.
42 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
43
44 # Checks for header files.
45 AC_PATH_X
46 AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/statvfs.h sys/vfs.h syslog.h unistd.h])
47
48 # Checks for typedefs, structures, and compiler characteristics.
49 AC_HEADER_STDBOOL
50 AC_C_INLINE
51 AC_TYPE_INT16_T
52 AC_TYPE_INT32_T
53 AC_TYPE_INT64_T
54 AC_TYPE_MODE_T
55 AC_TYPE_PID_T
56 AC_TYPE_SIZE_T
57 AC_TYPE_SSIZE_T
58 AC_CHECK_MEMBERS([struct stat.st_rdev])
59 AC_TYPE_UINT16_T
60 AC_TYPE_UINT32_T
61 AC_TYPE_UINT64_T
62 AC_TYPE_UINT8_T
63 AC_CHECK_TYPES([ptrdiff_t])
64
65 # Checks for library functions.
66 AC_FUNC_ERROR_AT_LINE
67 AC_HEADER_MAJOR
68 AC_FUNC_MALLOC
69 AC_FUNC_STRTOD
70 AC_CHECK_FUNCS([clock_gettime memmove memset regcomp strcasecmp strchr strdup strrchr strtol strtoul])
71
72 # Check for glib.
73 PKG_CHECK_MODULES(GLIB, glib-2.0)
74 AC_SUBST(GLIB_CFLAGS)
75 AC_SUBST(GLIB_LIBS)
76
77 # Check for low-level DBUS libs.
78 PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.70 dbus-1 >= 0.70)
79 AC_SUBST(DBUS_CFLAGS)
80 AC_SUBST(DBUS_LIBS)
81
82 DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
83 AC_SUBST(DBUS_SESSION_DIR)
84
85 # Check and enable extra compiler warnings if they are supported.
86 AC_ARG_ENABLE(extra-warnings,
87               [  --enable-extra-warnings         enable extra compiler warnings],
88               [extra_warnings=$enableval], [extra_warnings=auto])
89
90 WARNING_CFLAGS=""
91 warncflags="-Wall -Wextra"
92 if test "$extra_warnings" != "no"; then
93     save_CPPFLAGS="$CPPFLAGS"
94     for opt in $warncflags; do
95         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
96                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
97     done
98     CPPFLAGS="$save_CPPFLAGS"
99 fi
100
101 AC_SUBST(WARNING_CFLAGS)
102
103
104 MURPHY_CFLAGS="$GLIB_CFLAGS $DBUS_CFLAGS"
105 MURPHY_LIBS="$GLIB_LIBS $DBUS_LIBS"
106 AC_SUBST(MURPHY_CFLAGS)
107 AC_SUBST(MURPHY_LIBS)
108
109 # Check which plugins should be built in.
110 AC_ARG_WITH(builtin-plugins,
111             [  --with-builtin-plugins=<plugin-list>  specify which plugins to link in],
112             [builtin_plugins=$withval],[builtin_plugins=all])
113
114 all_plugins=$(ls src/plugins/*.c 2>/dev/null | \
115               sed 's#src/plugins/plugin-##g;s#\.c$##g' | tr '\n' ' ')
116
117 case $builtin_plugins in
118     all)  builtin_plugins="$all_plugins";;
119     none) builtin_plugins="";;
120 esac
121
122 internal=""; it=""
123 external=""; et=""
124 for plugin in $all_plugins; do 
125     type=external
126
127     for p in ${builtin_plugins//,/ }; do
128         if test "$plugin" = "$p"; then
129             internal="$internal$it$plugin"
130             type=internal
131             it=" "
132         fi
133     done
134
135     if test "$type" = "external"; then
136         external="$external$et$plugin"
137         et=" "
138     fi
139 done
140
141 INTERNAL_PLUGINS="$internal"
142 EXTERNAL_PLUGINS="$external"
143
144 function check_if_internal() {
145     for p in $INTERNAL_PLUGINS; do
146         if test "$1" = "$p"; then
147             return 0
148         fi
149     done
150
151     return 1
152 }
153
154 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,    [check_if_internal test])
155 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,    [check_if_internal dbus])
156 #AM_CONDITIONAL(BUILTIN_PLUGIN_STORAGE, [check_if_internal storage])
157 #AM_CONDITIONAL(BUILTIN_PLUGIN_SYSFS,   [check_if_internal sysfs  ])
158 #AM_CONDITIONAL(BUILTIN_PLUGIN_DISPLAY, [check_if_internal display])
159 #AM_CONDITIONAL(BUILTIN_PLUGIN_NETWORK, [check_if_internal network])
160 #AM_CONDITIONAL(BUILTIN_PLUGIN_BATTERY, [check_if_internal battery])
161 #AM_CONDITIONAL(BUILTIN_PLUGIN_XFS,     [check_if_internal xfs])
162
163 # Check for Check (unit test framework).
164 PKG_CHECK_MODULES(CHECK, 
165                   check >= 0.9.4,
166                   [has_check="yes"], [has_check="no"])
167 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
168
169 if test "x$has_check" = "xno"; then
170     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
171 fi
172
173 # Shave by default.
174 SHAVE_INIT([build-aux], [enable])
175
176 # Create murphy symlink to src.
177 if test ! -L murphy; then
178     AC_MSG_NOTICE([Symlinking src to murphy...])
179     ln -s src murphy
180 fi
181
182 # Generate output.
183 AC_CONFIG_FILES([build-aux/shave
184                  build-aux/shave-libtool
185                  Makefile
186                  src/Makefile
187                  src/common/Makefile
188                  src/common/tests/Makefile
189                  src/core/Makefile
190                  src/core/tests/Makefile
191                  src/daemon/Makefile
192                  src/daemon/tests/Makefile
193                  src/plugins/Makefile
194                  ])
195 AC_OUTPUT
196
197 # Display the configuration.
198 echo "----- configuration -----"
199 echo "Extra C warnings flags: $WARNING_CFLAGS"
200 echo "Plugins:"
201 echo "  - linked-in:"
202 for plugin in ${INTERNAL_PLUGINS:-none}; do
203     echo "      $plugin"
204 done
205
206 echo "  - dynamic:"
207 for plugin in ${EXTERNAL_PLUGINS:-none}; do
208     echo "      $plugin"
209 done