eb3d290f708604e61a8723cfed025b1614379c08
[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 AM_PROG_LEX
44 AC_SUBST(LEXLIB)
45
46 # Don't require ctags (we keep linker scripts and debug files in the repo now).
47 #AC_CHECK_PROG(CTAGS, ctags, "ctags")
48 #if test "$CTAGS" != "ctags" ; then
49 #   AC_MSG_ERROR([ctags is required])
50 #fi
51
52 if test "$LEX" != "flex" ; then
53    AC_MSG_ERROR([flex is required])
54 fi
55
56 if test "$YACC" != "bison -y" ; then
57    AC_MSG_ERROR([bison is required])
58 fi
59
60 # Checks for libraries.
61 AC_CHECK_LIB([dl], [dlopen dlclose dlsym dlerror])
62
63 # Checks for header files.
64 AC_PATH_X
65 AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/statvfs.h sys/vfs.h syslog.h unistd.h])
66
67 # Checks for typedefs, structures, and compiler characteristics.
68 AC_HEADER_STDBOOL
69 AC_C_INLINE
70 AC_TYPE_INT16_T
71 AC_TYPE_INT32_T
72 AC_TYPE_INT64_T
73 AC_TYPE_MODE_T
74 AC_TYPE_PID_T
75 AC_TYPE_SIZE_T
76 AC_TYPE_SSIZE_T
77 AC_CHECK_MEMBERS([struct stat.st_rdev])
78 AC_TYPE_UINT16_T
79 AC_TYPE_UINT32_T
80 AC_TYPE_UINT64_T
81 AC_TYPE_UINT8_T
82 AC_CHECK_TYPES([ptrdiff_t])
83
84 # Checks for library functions.
85 AC_FUNC_ERROR_AT_LINE
86 AC_HEADER_MAJOR
87 AC_FUNC_MALLOC
88 AC_FUNC_STRTOD
89 AC_CHECK_FUNCS([clock_gettime memmove memset regcomp strcasecmp strchr strdup strrchr strtol strtoul])
90
91 # Check for glib.
92 PKG_CHECK_MODULES(GLIB, glib-2.0)
93 AC_SUBST(GLIB_CFLAGS)
94 AC_SUBST(GLIB_LIBS)
95
96 # Check and enable extra compiler warnings if they are supported.
97 AC_ARG_ENABLE(extra-warnings,
98               [  --enable-extra-warnings enable extra compiler warnings],
99               [extra_warnings=$enableval], [extra_warnings=auto])
100
101 WARNING_CFLAGS=""
102 warncflags="-Wall -Wextra"
103 if test "$extra_warnings" != "no"; then
104     save_CPPFLAGS="$CPPFLAGS"
105     for opt in $warncflags; do
106         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
107                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
108     done
109     CPPFLAGS="$save_CPPFLAGS"
110 fi
111
112 AC_SUBST(WARNING_CFLAGS)
113
114 # Check if potentially GPL bits are allowed to be enabled.
115 AC_ARG_ENABLE(gpl,
116               [  --enable-gpl            enable linking against GPL code],
117               [enable_gpl=$enableval], [enable_gpl=no])
118
119 # Check if DBUS was enabled.
120 AC_ARG_ENABLE(dbus,
121               [  --enable-dbus           enable D-BUS support],
122               [enable_dbus=$enableval], [enable_dbus=no])
123
124 if test "$enable_dbus" = "yes"; then
125     if test "$enable_gpl" = "no"; then
126         AC_MSG_ERROR([D-Bus support requires the --enable-gpl option.])
127     fi
128     PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.70)
129
130     DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
131     AC_SUBST(DBUS_SESSION_DIR)
132 else
133     AC_MSG_NOTICE([D-Bus support is disabled.])
134 fi
135
136 if test "$enable_dbus" = "yes"; then
137     AC_DEFINE([DBUS_ENABLED], 1, [Enable D-BUS support ?])
138 fi
139
140 AM_CONDITIONAL(DBUS_ENABLED, [test "$enable_dbus" = "yes"])
141 AC_SUBST(DBUS_ENABLED)
142 AC_SUBST(DBUS_CFLAGS)
143 AC_SUBST(DBUS_LIBS)
144
145 # Check if PulseAudio mainloop support was enabled.
146 AC_ARG_ENABLE(pulse,
147               [  --enable-pulse          enable PulseAudio mainloop support],
148               [enable_pulse=$enableval], [enable_pulse=auto])
149
150 if test "$enable_pulse" != "no"; then
151     PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.22,
152                              [have_pulse=yes], [have_pulse=no])
153     if test "$have_pulse" = "no" -a "$enable_pulse" != "yes"; then
154         AC_MSG_ERROR([PulseAudio development libraries not found.])
155     fi
156
157     if test "$enable_gpl" = "no"; then
158         if test "$enable_pulse" = "yes"; then
159            AC_MSG_ERROR([PulseAudio support requires the --enable-gpl option.])
160         else
161            enable_pulse="no"
162         fi
163     else
164         enable_pulse="$have_pulse"
165     fi
166 else
167     AC_MSG_NOTICE([PulseAudio mainloop support is disabled.])
168 fi
169
170 if test "$enable_pulse" = "yes"; then
171     AC_DEFINE([PULSE_ENABLED], 1, [Enable PulseAudio mainloop support ?])
172 fi
173 AM_CONDITIONAL(PULSE_ENABLED, [test "$enable_pulse" = "yes"])
174 AC_SUBST(PULSE_ENABLED)
175 AC_SUBST(PULSE_CFLAGS)
176 AC_SUBST(PULSE_LIBS)
177
178 # Check if EFL/ecore mainloop support was enabled.
179 AC_ARG_ENABLE(ecore,
180               [  --enable-ecore          enable EFL/ecore mainloop support],
181               [enable_ecore=$enableval], [enable_ecore=auto])
182
183 if test "$enable_ecore" != "no"; then
184     PKG_CHECK_MODULES(ECORE, ecore >= 0.9.22,
185                       [have_ecore=yes], [have_ecore=no])
186     if test "$have_ecore" = "no" -a "$enable_ecore" != "yes"; then
187         AC_MSG_ERROR([EFL/ecore development libraries not found.])
188     fi
189
190     enable_ecore="$have_ecore"
191 else
192     AC_MSG_NOTICE([EFL/ecore mainloop support is disabled.])
193 fi
194
195 if test "$enable_ecore" = "yes"; then
196     AC_DEFINE([ECORE_ENABLED], 1, [Enable EFL/ecore mainloop support ?])
197 fi
198 AM_CONDITIONAL(ECORE_ENABLED, [test "$enable_ecore" = "yes"])
199 AC_SUBST(ECORE_ENABLED)
200 AC_SUBST(ECORE_CFLAGS)
201 AC_SUBST(ECORE_LIBS)
202
203 # Check if building murphy-console was enabled.
204 AC_ARG_ENABLE(console,
205               [  --enable-console        build Murphy console],
206               [enable_console=$enableval], [enable_console=auto])
207
208 if test "$enable_console" != "no"; then
209     AC_HAVE_LIBRARY([readline], [have_readline=yes], [have_readline=no])
210     if test "$have_readline" = "no" -a "$enable_console" = "yes"; then
211         AC_MSG_ERROR([Readline development libraries not found.])
212     fi
213
214     if test "$enable_gpl" = "no"; then
215         if test "$enable_console" = "yes"; then
216            AC_MSG_ERROR([Console support requires the --enable-gpl option.])
217         else
218            enable_console="no"
219         fi
220     else
221         enable_console="$have_readline"
222     fi
223 else
224     AC_MSG_NOTICE([Murphy console binary is disabled.])
225 fi
226
227 if test "$enable_console" = "yes"; then
228     AC_DEFINE([CONSOLE_ENABLED], 1, [Build Murphy console ?])
229     READLINE_CFLAGS=""
230     READLINE_LIBS="-lreadline"
231 fi
232 AM_CONDITIONAL(CONSOLE_ENABLED, [test "$enable_console" = "yes"])
233 AC_SUBST(CONSOLE_ENABLED)
234 AC_SUBST(READLINE_CFLAGS)
235 AC_SUBST(READLINE_LIBS)
236
237 # Set up murphy CFLAGS and LIBS.
238 MURPHY_CFLAGS="$GLIB_CFLAGS $DBUS_CFLAGS"
239 MURPHY_LIBS="$GLIB_LIBS $DBUS_LIBS"
240 AC_SUBST(MURPHY_CFLAGS)
241 AC_SUBST(MURPHY_LIBS)
242
243 # Add LIBDIR to config.h.
244 AC_MSG_CHECKING([libdir])
245 AC_MSG_RESULT([$libdir])
246 AC_SUBST(LIBDIR, [$libdir])
247
248 # Check which plugins should be disabled.
249 AC_ARG_WITH(disabled-plugins,
250             [  --with-disabled-plugins=<plugin-list> specify which plugins to disable],
251             [disabled_plugins=$withval],[disabled_plugins=none])
252
253 # Check which plugins should be compiled as standalone DSOs.
254 AC_ARG_WITH(dynamic-plugins,
255             [  --with-dynamic-plugins=<plugin-list>  specify which plugins compile as DSOs],
256             [dynamic_plugins=$withval],[dynamic_plugins=none])
257
258 all_plugins=$(ls src/plugins/*.c 2>/dev/null | \
259               sed 's#src/plugins/plugin-##g;s#\.c$##g' | tr '\n' ' ')
260
261 case dynamic_plugins in
262     all)  dynamic_plugins="$all_plugins";;
263     none) dynamic_plugins="";;
264 esac
265
266 internal=""; it=""
267 external=""; et=""
268 disabled=""; dt=""
269 for plugin in $all_plugins; do 
270     type=internal
271
272     for p in ${dynamic_plugins//,/ }; do
273         if test "$plugin" = "$p"; then
274             type=external
275         fi
276     done
277
278     for p in ${disabled_plugins//,/ }; do
279         if test "$plugin" = "$p"; then
280             type=disabled
281         fi
282     done
283
284     case $type in
285         internal) internal="$internal$it$plugin"; it=" ";;
286         external) external="$external$et$plugin"; et=" ";;
287         disabled) disabled="$disabled$dt$plugin"; dt=" ";;
288     esac
289 done
290
291 DISABLED_PLUGINS="$disabled"
292 INTERNAL_PLUGINS="$internal"
293 EXTERNAL_PLUGINS="$external"
294
295
296 function check_if_disabled() {
297     for p in $DISABLED_PLUGINS; do
298         if test "$1" = "$p"; then
299             return 0
300         fi
301     done
302
303     return 1
304 }
305
306 function check_if_internal() {
307     for p in $INTERNAL_PLUGINS; do
308         if test "$1" = "$p"; then
309             return 0
310         fi
311     done
312
313     return 1
314 }
315
316 AM_CONDITIONAL(DISABLED_PLUGIN_TEST,    [check_if_disabled test])
317 AM_CONDITIONAL(DISABLED_PLUGIN_DBUS,    [check_if_disabled dbus])
318 AM_CONDITIONAL(DISABLED_PLUGIN_GLIB,    [check_if_disabled glib])
319 AM_CONDITIONAL(DISABLED_PLUGIN_CONSOLE, [check_if_disabled console])
320 AM_CONDITIONAL(DISABLED_PLUGIN_SIGNALLING, [check_if_disabled signalling])
321
322 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,     [check_if_internal test])
323 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,     [check_if_internal dbus])
324 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,     [check_if_internal glib])
325 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE,  [check_if_internal console])
326 AM_CONDITIONAL(BUILTIN_PLUGIN_SIGNALLING, [check_if_internal signalling])
327
328 # Check for Check (unit test framework).
329 PKG_CHECK_MODULES(CHECK, 
330                   check >= 0.9.4,
331                   [has_check="yes"], [has_check="no"])
332 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
333
334 AC_SUBST(CHECK_CFLAGS)
335 AC_SUBST(CHECK_LIBS)
336
337 if test "x$has_check" = "xno"; then
338     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
339 fi
340
341 # Check for documentation tools
342 AC_ARG_WITH([documentation],
343             [AS_HELP_STRING([--with-documentation],
344                             [generate pdf, html and other doc files])],
345             [],
346             [with_documentation=auto]
347 )
348
349 AS_IF( [ test x$with_documentation = xno ],
350        [ has_doc_tools="no" ],
351        [ AC_PATH_TOOL([MRP_DOXYGEN], doxygen)
352          AC_PATH_TOOL([MRP_LYX], lyx)
353          AC_PATH_TOOL([MRP_INKSCAPE], inkscape)
354          AC_PATH_TOOL([MRP_PYTHON], python)
355          AC_PATH_TOOL([MRP_TOUCH], touch)
356          AC_PATH_TOOL([MRP_DBLATEX], dblatex)
357          AC_PATH_TOOL([MRP_XMLTO], xmlto)
358
359          AS_IF( [ test x$MRP_DOXYGEN = x -o x$MRP_LYX = x -o \
360                        x$MRP_INKSCAPE = x -o x$MRP_PYTHON = x -o \
361                        x$MRP_TOUCH = x],
362                 [ has_doc_tools="no";
363                   AC_MSG_WARN([Some essential doc-tool is missing]) ],
364                 [ has_doc_tools="yes";
365                   MRP_DOCINIT() ]
366          ) ]
367 )
368
369 AS_IF( [ test x$has_doc_tools == "xno" -o x$MRP_DBLATEX = x ],
370        [ can_make_pdfs="no";
371          AC_WARN([No PDF documentation will be generated]) ],
372        [ can_make_pdfs="yes"]
373 )
374
375 AS_IF([ test x$has_doc_tools == "xno" -o x$MRP_XMLTO = x ],
376       [ can_make_html="no";
377         AC_WARN([No HTML documentation will be generated]) ],
378       [ can_make_html="yes" ]
379 )
380
381
382 AM_CONDITIONAL(BUILD_DOCUMENTATION,  [ test x$has_doc_tools = "xyes" ])
383 AM_CONDITIONAL(BUILD_PDF_DOCUMENTS,  [ test x$can_make_pdfs = "xyes" ])
384 AM_CONDITIONAL(BUILD_HTML_DOCUMENTS, [ test x$can_make_html = "xyes" ])
385
386 AC_SUBST(MRP_DOCDIR, [`pwd`/doc])
387 AC_SUBST(MRP_FIGDIR, [$MRP_DOCDIR/common/figures])
388 AC_SUBST(MRP_MAKE_DOCRULES, [$MRP_DOCDIR/Makefile.rules])
389 AC_SUBST(MRP_DOCSCRIPT_DIR, [$MRP_DOCDIR/scripts])
390 AC_SUBST(MRP_ABNF, [$MRP_DOCSCRIPT_DIR/abnf.py])
391 AC_SUBST(MRP_DBLYXFIX, [$MRP_DOCSCRIPT_DIR/dblyxfix.py])
392 AC_SUBST(MRP_DOXML2DB, [$MRP_DOCSCRIPT_DIR/doxml2db.py])
393 AC_SUBST(MRP_DOXYDEPS, [$MRP_DOCSCRIPT_DIR/doxydeps.py])
394
395
396 # Shave by default.
397 SHAVE_INIT([build-aux], [enable])
398
399 # Create murphy symlink to src.
400 if test ! -L murphy; then
401     AC_MSG_NOTICE([Symlinking src to murphy...])
402     ln -s src murphy
403 fi
404
405 # Generate output.
406 AC_CONFIG_FILES([build-aux/shave
407                  build-aux/shave-libtool
408                  Makefile
409                  src/Makefile
410                  src/common/tests/Makefile
411                  src/core/tests/Makefile
412                  src/daemon/tests/Makefile
413                  src/plugins/tests/Makefile
414                  src/common/murphy-common.pc
415                  src/common/murphy-dbus.pc
416                  src/common/murphy-pulse.pc
417                  src/common/murphy-ecore.pc
418                  src/core/murphy-core.pc
419                  src/murphy-db/Makefile
420                  src/murphy-db/mdb/Makefile
421                  src/murphy-db/mqi/Makefile
422                  src/murphy-db/mql/Makefile
423                  src/murphy-db/include/Makefile
424                  src/murphy-db/tests/Makefile
425                  src/resolver/murphy-resolver.pc
426                  src/resolver/tests/Makefile
427                  src/resource/murphy-resource.pc
428                  doc/Makefile
429                  doc/plugin-developer-guide/Makefile
430                  doc/plugin-developer-guide/db/Makefile
431                  doc/plugin-developer-guide/doxml/Makefile
432                  ])
433 AC_OUTPUT
434
435
436 # Display the configuration.
437 echo "----- configuration -----"
438 echo "Extra C warnings flags: $WARNING_CFLAGS"
439 echo "D-Bus support: $enable_dbus"
440 echo "PulseAudio mainloop support: $enable_pulse"
441 echo "EFL/ecore mainloop support: $enable_ecore"
442 echo "Murphy console plugin and client: $enable_console"
443 echo "Plugins:"
444 echo "  - linked-in:"
445 for plugin in ${INTERNAL_PLUGINS:-none}; do
446     echo "      $plugin"
447 done
448 echo "  - dynamic:"
449 for plugin in ${EXTERNAL_PLUGINS:-none}; do
450     echo "      $plugin"
451 done
452 echo "  - disabled:"
453 for plugin in ${DISABLED_PLUGINS:-none}; do
454     echo "      $plugin"
455 done