build-sys: support for disabling individual plugins, and the console.
[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 and enable extra compiler warnings if they are supported.
89 AC_ARG_ENABLE(extra-warnings,
90               [  --enable-extra-warnings         enable extra compiler warnings],
91               [extra_warnings=$enableval], [extra_warnings=auto])
92
93 WARNING_CFLAGS=""
94 warncflags="-Wall -Wextra"
95 if test "$extra_warnings" != "no"; then
96     save_CPPFLAGS="$CPPFLAGS"
97     for opt in $warncflags; do
98         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
99                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
100     done
101     CPPFLAGS="$save_CPPFLAGS"
102 fi
103
104 AC_SUBST(WARNING_CFLAGS)
105
106 # Check if DBUS was enabled.
107 AC_ARG_ENABLE(dbus,
108               [  --enable-dbus         enable D-BUS support],
109               [enable_dbus=$enableval], [enable_dbus=no])
110
111 if test "$enable_dbus" = "yes"; then
112     PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.70)
113
114     DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
115     AC_SUBST(DBUS_SESSION_DIR)
116 else
117     AC_MSG_NOTICE([D-Bus support is disabled.])
118 fi
119
120 if test "$enable_dbus" = "yes"; then
121     AC_DEFINE([DBUS_ENABLED], 1, [Enable D-BUS support ?])
122 fi
123
124 AM_CONDITIONAL(DBUS_ENABLED, [test "$enable_dbus" = "yes"])
125 AC_SUBST(DBUS_ENABLED)
126 AC_SUBST(DBUS_CFLAGS)
127 AC_SUBST(DBUS_LIBS)
128
129 # Check if PulseAudio mainloop support was enabled.
130 AC_ARG_ENABLE(pulse,
131               [  --enable-pulse        enable PulseAudio mainloop support],
132               [enable_pulse=$enableval], [enable_pulse=auto])
133
134 if test "$enable_pulse" != "no"; then
135     PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.22,
136                              [have_pulse=yes], [have_pulse=no])
137     if test "$have_pulse" = "no" -a "$enable_pulse" != "yes"; then
138         AC_MSG_ERROR([PulseAudio development libraries not found.])
139     else
140         enable_pulse="$have_pulse"
141     fi
142 else
143     AC_MSG_NOTICE([PulseAudio mainloop support is disabled.])
144 fi
145
146 if test "$enable_pulse" = "yes"; then
147     AC_DEFINE([PULSE_ENABLED], 1, [Enable PulseAudio mainloop support ?])
148 fi
149 AM_CONDITIONAL(PULSE_ENABLED, [test "$enable_pulse" = "yes"])
150 AC_SUBST(PULSE_ENABLED)
151 AC_SUBST(PULSE_CFLAGS)
152 AC_SUBST(PULSE_LIBS)
153
154 # Check if building murphy-console was enabled.
155 AC_ARG_ENABLE(console,
156               [  --enable-console        build Murphy console],
157               [enable_console=$enableval], [enable_console=auto])
158
159 if test "$enable_console" != "no"; then
160     AC_HAVE_LIBRARY([readline], [have_readline=yes], [have_readline=no])
161     if test "$have_readline" = "no" -a "$enable_console" = "yes"; then
162         AC_MSG_ERROR([Readline development libraries not found.])
163     else
164         enable_console="$have_readline"
165     fi
166 else
167     AC_MSG_NOTICE([Murphy console binary is disabled.])
168 fi
169
170 if test "$enable_console" = "yes"; then
171     AC_DEFINE([CONSOLE_ENABLED], 1, [Build Murphy console ?])
172     READLINE_CFLAGS=""
173     READLINE_LIBS="-lreadline"
174 fi
175 AM_CONDITIONAL(CONSOLE_ENABLED, [test "$enable_console" = "yes"])
176 AC_SUBST(CONSOLE_ENABLED)
177 AC_SUBST(READLINE_CFLAGS)
178 AC_SUBST(READLINE_LIBS)
179
180 # Set up murphy CFLAGS and LIBS.
181 MURPHY_CFLAGS="$GLIB_CFLAGS $DBUS_CFLAGS"
182 MURPHY_LIBS="$GLIB_LIBS $DBUS_LIBS"
183 AC_SUBST(MURPHY_CFLAGS)
184 AC_SUBST(MURPHY_LIBS)
185
186 # Add LIBDIR to config.h.
187 AC_MSG_CHECKING([libdir])
188 AC_MSG_RESULT([$libdir])
189 AC_SUBST(LIBDIR, [$libdir])
190
191 # Check which plugins should be disabled.
192 AC_ARG_WITH(disabled-plugins,
193             [  --with-disabled-plugins=<plugin-list> specify which plugins to disable],
194             [disabled_plugins=$withval],[disabled_plugins=none])
195
196
197 # Check which plugins should be built in.
198 AC_ARG_WITH(builtin-plugins,
199             [  --with-builtin-plugins=<plugin-list>  specify which plugins to link in],
200             [builtin_plugins=$withval],[builtin_plugins=all])
201
202 all_plugins=$(ls src/plugins/*.c 2>/dev/null | \
203               sed 's#src/plugins/plugin-##g;s#\.c$##g' | tr '\n' ' ')
204
205 case $builtin_plugins in
206     all)  builtin_plugins="$all_plugins";;
207     none) builtin_plugins="";;
208 esac
209
210 internal=""; it=""
211 external=""; et=""
212 disabled=""; dt=""
213 for plugin in $all_plugins; do 
214     type=external
215
216     for p in ${builtin_plugins//,/ }; do
217         if test "$plugin" = "$p"; then
218             type=internal
219         fi
220     done
221
222     for p in ${disabled_plugins//,/ }; do
223         if test "$plugin" = "$p"; then
224             type=disabled
225         fi
226     done
227
228     case $type in
229         internal) internal="$internal$it$plugin"; it=" ";;
230         external) external="$external$et$plugin"; et=" ";;
231         disabled) disabled="$disabled$dt$plugin"; dt=" ";;
232     esac
233 done
234
235 DISABLED_PLUGINS="$disabled"
236 INTERNAL_PLUGINS="$internal"
237 EXTERNAL_PLUGINS="$external"
238
239
240 function check_if_disabled() {
241     for p in $DISABLED_PLUGINS; do
242         if test "$1" = "$p"; then
243             return 0
244         fi
245     done
246
247     return 1
248 }
249
250 function check_if_internal() {
251     for p in $INTERNAL_PLUGINS; do
252         if test "$1" = "$p"; then
253             return 0
254         fi
255     done
256
257     return 1
258 }
259
260 AM_CONDITIONAL(DISABLED_PLUGIN_TEST,    [check_if_disabled test])
261 AM_CONDITIONAL(DISABLED_PLUGIN_DBUS,    [check_if_disabled dbus])
262 AM_CONDITIONAL(DISABLED_PLUGIN_GLIB,    [check_if_disabled glib])
263 AM_CONDITIONAL(DISABLED_PLUGIN_CONSOLE, [check_if_disabled console])
264
265 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,     [check_if_internal test])
266 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,     [check_if_internal dbus])
267 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,     [check_if_internal glib])
268 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE,  [check_if_internal console])
269
270 # Check for Check (unit test framework).
271 PKG_CHECK_MODULES(CHECK, 
272                   check >= 0.9.4,
273                   [has_check="yes"], [has_check="no"])
274 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
275
276 AC_SUBST(CHECK_CFLAGS)
277 AC_SUBST(CHECK_LIBS)
278
279 if test "x$has_check" = "xno"; then
280     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
281 fi
282
283 # Check for documentation tools
284 AC_ARG_WITH([documentation],
285             [AS_HELP_STRING([--with-documentation],
286                             [generate pdf, html and other doc files])],
287             [],
288             [with_documentation=auto]
289 )
290
291 AS_IF( [ test x$with_documentation = xno ],
292        [ has_doc_tools="no" ],
293        [ AC_PATH_TOOL([MRP_DOXYGEN], doxygen)
294          AC_PATH_TOOL([MRP_LYX], lyx)
295          AC_PATH_TOOL([MRP_INKSCAPE], inkscape)
296          AC_PATH_TOOL([MRP_PYTHON], python)
297          AC_PATH_TOOL([MRP_TOUCH], touch)
298          AC_PATH_TOOL([MRP_DBLATEX], dblatex)
299          AC_PATH_TOOL([MRP_XMLTO], xmlto)
300
301          AS_IF( [ test x$MRP_DOXYGEN = x -o x$MRP_LYX = x -o \
302                        x$MRP_INKSCAPE = x -o x$MRP_PYTHON = x -o \
303                        x$MRP_TOUCH = x],
304                 [ has_doc_tools="no";
305                   AC_MSG_WARN([Some essential doc-tool is missing]) ],
306                 [ has_doc_tools="yes";
307                   MRP_DOCINIT() ]
308          ) ]
309 )
310
311 AS_IF( [ test x$has_doc_tools == "xno" -o x$MRP_DBLATEX = x ],
312        [ can_make_pdfs="no";
313          AC_WARN([No PDF documentation will be generated]) ],
314        [ can_make_pdfs="yes"]
315 )
316
317 AS_IF([ test x$has_doc_tools == "xno" -o x$MRP_XMLTO = x ],
318       [ can_make_html="no";
319         AC_WARN([No HTML documentation will be generated]) ],
320       [ can_make_html="yes" ]
321 )
322
323
324 AM_CONDITIONAL(BUILD_DOCUMENTATION,  [ test x$has_doc_tools = "xyes" ])
325 AM_CONDITIONAL(BUILD_PDF_DOCUMENTS,  [ test x$can_make_pdfs = "xyes" ])
326 AM_CONDITIONAL(BUILD_HTML_DOCUMENTS, [ test x$can_make_html = "xyes" ])
327
328 AC_SUBST(MRP_DOCDIR, [`pwd`/doc])
329 AC_SUBST(MRP_FIGDIR, [$MRP_DOCDIR/common/figures])
330 AC_SUBST(MRP_MAKE_DOCRULES, [$MRP_DOCDIR/Makefile.rules])
331 AC_SUBST(MRP_DOCSCRIPT_DIR, [$MRP_DOCDIR/scripts])
332 AC_SUBST(MRP_ABNF, [$MRP_DOCSCRIPT_DIR/abnf.py])
333 AC_SUBST(MRP_DBLYXFIX, [$MRP_DOCSCRIPT_DIR/dblyxfix.py])
334 AC_SUBST(MRP_DOXML2DB, [$MRP_DOCSCRIPT_DIR/doxml2db.py])
335 AC_SUBST(MRP_DOXYDEPS, [$MRP_DOCSCRIPT_DIR/doxydeps.py])
336
337
338 # Shave by default.
339 SHAVE_INIT([build-aux], [enable])
340
341 # Create murphy symlink to src.
342 if test ! -L murphy; then
343     AC_MSG_NOTICE([Symlinking src to murphy...])
344     ln -s src murphy
345 fi
346
347 # Generate output.
348 AC_CONFIG_FILES([build-aux/shave
349                  build-aux/shave-libtool
350                  Makefile
351                  src/Makefile
352                  src/common/tests/Makefile
353                  src/core/tests/Makefile
354                  src/daemon/tests/Makefile
355                  src/common/murphy-common.pc
356                  src/common/murphy-dbus.pc
357                  src/common/murphy-pulse.pc
358                  src/core/murphy-core.pc
359                  src/murphy-db/Makefile
360                  src/murphy-db/mdb/Makefile
361                  src/murphy-db/mqi/Makefile
362                  src/murphy-db/mql/Makefile
363                  src/murphy-db/include/Makefile
364                  src/murphy-db/tests/Makefile
365                  doc/Makefile
366                  doc/plugin-developer-guide/Makefile
367                  doc/plugin-developer-guide/db/Makefile
368                  doc/plugin-developer-guide/doxml/Makefile
369                  ])
370 AC_OUTPUT
371
372
373 # Display the configuration.
374 echo "----- configuration -----"
375 echo "Extra C warnings flags: $WARNING_CFLAGS"
376 echo "D-Bus support: $enable_dbus"
377 echo "PulseAudio mainloop support: $enable_pulse"
378 echo "Murphy console plugin and client: $enable_console"
379 echo "Plugins:"
380 echo "  - linked-in:"
381 for plugin in ${INTERNAL_PLUGINS:-none}; do
382     echo "      $plugin"
383 done
384 echo "  - dynamic:"
385 for plugin in ${EXTERNAL_PLUGINS:-none}; do
386     echo "      $plugin"
387 done
388 echo "  - disabled:"
389 for plugin in ${DISABLED_PLUGINS:-none}; do
390     echo "      $plugin"
391 done