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