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