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