Merge branch 'documentation'
[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 for low-level DBUS libs.
89 PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.70)
90 AC_SUBST(DBUS_CFLAGS)
91 AC_SUBST(DBUS_LIBS)
92
93 DBUS_SESSION_DIR="`pkg-config --variable session_bus_services_dir dbus-1`"
94 AC_SUBST(DBUS_SESSION_DIR)
95
96
97 # Check and enable extra compiler warnings if they are supported.
98 AC_ARG_ENABLE(extra-warnings,
99               [  --enable-extra-warnings         enable extra compiler warnings],
100               [extra_warnings=$enableval], [extra_warnings=auto])
101
102 WARNING_CFLAGS=""
103 warncflags="-Wall -Wextra"
104 if test "$extra_warnings" != "no"; then
105     save_CPPFLAGS="$CPPFLAGS"
106     for opt in $warncflags; do
107         AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
108                           [WARNING_CFLAGS="$WARNING_CFLAGS $opt"])
109     done
110     CPPFLAGS="$save_CPPFLAGS"
111 fi
112
113 AC_SUBST(WARNING_CFLAGS)
114
115
116 # Set up murphy CFLAGS and LIBS.
117 MURPHY_CFLAGS="$GLIB_CFLAGS $DBUS_CFLAGS"
118 MURPHY_LIBS="$GLIB_LIBS $DBUS_LIBS"
119 AC_SUBST(MURPHY_CFLAGS)
120 AC_SUBST(MURPHY_LIBS)
121
122 # Add LIBDIR to config.h.
123 AC_MSG_CHECKING([libdir])
124 AC_MSG_RESULT([$libdir])
125 AC_SUBST(LIBDIR, [$libdir])
126
127
128 # Check which plugins should be built in.
129 AC_ARG_WITH(builtin-plugins,
130             [  --with-builtin-plugins=<plugin-list>  specify which plugins to link in],
131             [builtin_plugins=$withval],[builtin_plugins=all])
132
133 all_plugins=$(ls src/plugins/*.c 2>/dev/null | \
134               sed 's#src/plugins/plugin-##g;s#\.c$##g' | tr '\n' ' ')
135
136 case $builtin_plugins in
137     all)  builtin_plugins="$all_plugins";;
138     none) builtin_plugins="";;
139 esac
140
141 internal=""; it=""
142 external=""; et=""
143 for plugin in $all_plugins; do 
144     type=external
145
146     for p in ${builtin_plugins//,/ }; do
147         if test "$plugin" = "$p"; then
148             internal="$internal$it$plugin"
149             type=internal
150             it=" "
151         fi
152     done
153
154     if test "$type" = "external"; then
155         external="$external$et$plugin"
156         et=" "
157     fi
158 done
159
160 INTERNAL_PLUGINS="$internal"
161 EXTERNAL_PLUGINS="$external"
162
163 function check_if_internal() {
164     for p in $INTERNAL_PLUGINS; do
165         if test "$1" = "$p"; then
166             return 0
167         fi
168     done
169
170     return 1
171 }
172
173 AM_CONDITIONAL(BUILTIN_PLUGIN_TEST,    [check_if_internal test])
174 AM_CONDITIONAL(BUILTIN_PLUGIN_DBUS,    [check_if_internal dbus])
175 AM_CONDITIONAL(BUILTIN_PLUGIN_GLIB,    [check_if_internal glib])
176 AM_CONDITIONAL(BUILTIN_PLUGIN_CONSOLE, [check_if_internal console])
177
178 # Check for Check (unit test framework).
179 PKG_CHECK_MODULES(CHECK, 
180                   check >= 0.9.4,
181                   [has_check="yes"], [has_check="no"])
182 AM_CONDITIONAL(HAVE_CHECK, test "x$has_check" = "xyes")
183
184 AC_SUBST(CHECK_CFLAGS)
185 AC_SUBST(CHECK_LIBS)
186
187 if test "x$has_check" = "xno"; then
188     AC_MSG_WARN([Check framework not found, unit tests are DISABLED.])
189 fi
190
191 # Check for documentation tools
192 AC_ARG_WITH([documentation],
193             [AS_HELP_STRING([--with-documentation],
194                             [generate pdf, html and other doc files])],
195             [],
196             [with_documentation=auto]
197 )
198
199 AS_IF( [ test x$with_documentation = xno ],
200        [ has_doc_tools="no" ],
201        [ AC_PATH_TOOL([MRP_DOXYGEN], doxygen)
202          AC_PATH_TOOL([MRP_LYX], lyx)
203          AC_PATH_TOOL([MRP_INKSCAPE], inkscape)
204          AC_PATH_TOOL([MRP_PYTHON], python)
205          AC_PATH_TOOL([MRP_TOUCH], touch)
206          AC_PATH_TOOL([MRP_DBLATEX], dblatex)
207          AC_PATH_TOOL([MRP_XMLTO], xmlto)
208
209          AS_IF( [ test x$MRP_DOXYGEN = x -o x$MRP_LYX = x -o \
210                        x$MRP_INKSCAPE = x -o x$MRP_PYTHON = x -o \
211                        x$MRP_TOUCH = x],
212                 [ has_doc_tools="no";
213                   AC_MSG_WARN([Some essential doc-tool is missing]) ],
214                 [ has_doc_tools="yes";
215                   MRP_DOCINIT() ]
216          ) ]
217 )
218
219 AS_IF( [ test x$has_doc_tools == "xno" -o x$MRP_DBLATEX = x ],
220        [ can_make_pdfs="no";
221          AC_WARN([No PDF documentation will be generated]) ],
222        [ can_make_pdfs="yes"]
223 )
224
225 AS_IF([ test x$has_doc_tools == "xno" -o x$MRP_XMLTO = x ],
226       [ can_make_html="no";
227         AC_WARN([No HTML documentation will be generated]) ],
228       [ can_make_html="yes" ]
229 )
230
231
232 AM_CONDITIONAL(BUILD_DOCUMENTATION,  [ test x$has_doc_tools = "xyes" ])
233 AM_CONDITIONAL(BUILD_PDF_DOCUMENTS,  [ test x$can_make_pdfs = "xyes" ])
234 AM_CONDITIONAL(BUILD_HTML_DOCUMENTS, [ test x$can_make_html = "xyes" ])
235
236 AC_SUBST(MRP_DOCDIR, [`pwd`/doc])
237 AC_SUBST(MRP_FIGDIR, [$MRP_DOCDIR/common/figures])
238 AC_SUBST(MRP_MAKE_DOCRULES, [$MRP_DOCDIR/Makefile.rules])
239 AC_SUBST(MRP_DOCSCRIPT_DIR, [$MRP_DOCDIR/scripts])
240 AC_SUBST(MRP_ABNF, [$MRP_DOCSCRIPT_DIR/abnf.py])
241 AC_SUBST(MRP_DBLYXFIX, [$MRP_DOCSCRIPT_DIR/dblyxfix.py])
242 AC_SUBST(MRP_DOXML2DB, [$MRP_DOCSCRIPT_DIR/doxml2db.py])
243 AC_SUBST(MRP_DOXYDEPS, [$MRP_DOCSCRIPT_DIR/doxydeps.py])
244
245
246 # Shave by default.
247 SHAVE_INIT([build-aux], [enable])
248
249 # Create murphy symlink to src.
250 if test ! -L murphy; then
251     AC_MSG_NOTICE([Symlinking src to murphy...])
252     ln -s src murphy
253 fi
254
255 # Generate output.
256 AC_CONFIG_FILES([build-aux/shave
257                  build-aux/shave-libtool
258                  Makefile
259                  src/Makefile
260                  src/common/tests/Makefile
261                  src/core/tests/Makefile
262                  src/daemon/tests/Makefile
263                  src/common/murphy-common.pc
264                  src/core/murphy-core.pc
265                  src/murphy-db/Makefile
266                  src/murphy-db/mdb/Makefile
267                  src/murphy-db/mqi/Makefile
268                  src/murphy-db/mql/Makefile
269                  src/murphy-db/include/Makefile
270                  src/murphy-db/tests/Makefile
271                  doc/Makefile
272                  doc/plugin-developer-guide/Makefile
273                  doc/plugin-developer-guide/db/Makefile
274                  doc/plugin-developer-guide/doxml/Makefile
275                  ])
276 AC_OUTPUT
277
278
279 # Display the configuration.
280 echo "----- configuration -----"
281 echo "Extra C warnings flags: $WARNING_CFLAGS"
282 echo "Plugins:"
283 echo "  - linked-in:"
284 for plugin in ${INTERNAL_PLUGINS:-none}; do
285     echo "      $plugin"
286 done
287
288 echo "  - dynamic:"
289 for plugin in ${EXTERNAL_PLUGINS:-none}; do
290     echo "      $plugin"
291 done