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