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