6 AM_INIT_AUTOMAKE(dbus, 0.6)
8 AM_CONFIG_HEADER(config.h)
11 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
13 GETTEXT_PACKAGE=dbus-1
14 AC_SUBST(GETTEXT_PACKAGE)
15 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
17 ## must come before we use the $USE_MAINTAINER_MODE variable later
26 AC_ARG_ENABLE(qt, [ --enable-qt enable Qt-friendly client library],enable_qt=$enableval,enable_qt=auto)
27 AC_ARG_ENABLE(glib, [ --enable-glib enable GLib-friendly client library],enable_glib=$enableval,enable_glib=auto)
28 AC_ARG_ENABLE(tests, [ --enable-tests enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
29 AC_ARG_ENABLE(ansi, [ --enable-ansi enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
30 AC_ARG_ENABLE(verbose-mode, [ --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=yes)
31 AC_ARG_ENABLE(asserts, [ --enable-asserts include assertion checks],enable_asserts=$enableval,enable_asserts=yes)
32 AC_ARG_ENABLE(gcov, [ --enable-gcov compile with coverage profiling instrumentation (gcc only)],enable_gcov=$enableval,enable_gcov=no)
34 AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use])
35 AC_ARG_WITH(init-scripts, [ --with-init-scripts=[redhat] Style of init scripts to install])
37 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
38 dnl and also some stuff in the test/ subdir
39 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
40 if test x$enable_tests = xyes; then
41 AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
44 if test x$enable_verbose_mode = xyes; then
45 AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
47 if test x$enable_asserts = xno; then
48 AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
51 #### gcc warning flags
53 if test "x$GCC" = "xyes"; then
56 *[\ \ ]-Wall[\ \ ]*) ;;
57 *) CFLAGS="$CFLAGS -Wall" ;;
61 *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
62 *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
66 *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
67 *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
71 *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
72 *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
76 *[\ \ ]-Wnested-externs[\ \ ]*) ;;
77 *) CFLAGS="$CFLAGS -Wnested-externs" ;;
81 *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
82 *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
86 *[\ \ ]-Wcast-align[\ \ ]*) ;;
87 *) CFLAGS="$CFLAGS -Wcast-align" ;;
91 *[\ \ ]-Wsign-compare[\ \ ]*) ;;
92 *) CFLAGS="$CFLAGS -Wsign-compare" ;;
95 if test "x$enable_ansi" = "xyes"; then
97 *[\ \ ]-ansi[\ \ ]*) ;;
98 *) CFLAGS="$CFLAGS -ansi" ;;
102 *[\ \ ]-pedantic[\ \ ]*) ;;
103 *) CFLAGS="$CFLAGS -pedantic" ;;
106 if test x$enable_gcov = xyes; then
108 *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
109 *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
112 *[\ \ ]-ftest-coverage[\ \ ]*) ;;
113 *) CFLAGS="$CFLAGS -ftest-coverage" ;;
116 ## remove optimization
117 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
121 if test x$enable_gcov = xyes; then
122 AC_MSG_ERROR([--enable-gcov can only be used with gcc])
126 if test x$enable_gcov = xyes; then
127 ## so that config.h changes when you toggle gcov support
128 AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
130 AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
134 AC_CHECK_SIZEOF(char)
135 AC_CHECK_SIZEOF(short)
136 AC_CHECK_SIZEOF(long)
138 AC_CHECK_SIZEOF(void *)
139 AC_CHECK_SIZEOF(long long)
140 AC_CHECK_SIZEOF(__int64)
142 ### this is only used in decode-gcov.c right now
150 $ac_cv_sizeof_long_long)
151 dbusint64='long long'
153 $ac_cv_sizeof___int64)
158 AC_DEFINE_UNQUOTED(DBUS_INT64_TYPE, $dbusint64, [64-bit integer type])
163 AC_CHECK_LIB(socket,socket)
164 AC_CHECK_LIB(nsl,gethostbyname)
166 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist)
168 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
170 AC_CACHE_CHECK([for posix getpwnam_r],
171 ac_cv_func_posix_getpwnam_r,
177 struct passwd pwd, *pwptr = &pwd;
180 error = getpwnam_r ("", &pwd, buffer,
181 sizeof (buffer), &pwptr);
182 return (error < 0 && errno == ENOSYS)
185 [ac_cv_func_posix_getpwnam_r=yes],
186 [ac_cv_func_posix_getpwnam_r=no])])
187 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
188 AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
189 [Have POSIX function getpwnam_r])
191 AC_CACHE_CHECK([for nonposix getpwnam_r],
192 ac_cv_func_nonposix_getpwnam_r,
193 [AC_TRY_LINK([#include <pwd.h>],
196 getpwnam_r ("", &pwd, buffer,
198 [ac_cv_func_nonposix_getpwnam_r=yes],
199 [ac_cv_func_nonposix_getpwnam_r=no])])
200 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
201 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
202 [Have non-POSIX function getpwnam_r])
206 dnl check for writev header and writev function so we're
207 dnl good to go if HAVE_WRITEV gets defined.
208 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
210 dnl check for flavours of varargs macros (test from GLib)
211 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
213 int a(int p1, int p2, int p3);
214 #define call_a(...) a(1,__VA_ARGS__)
216 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
217 AC_MSG_RESULT($dbus_have_iso_c_varargs)
219 AC_MSG_CHECKING(for GNUC varargs macros)
221 int a(int p1, int p2, int p3);
222 #define call_a(params...) a(1,params)
224 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
225 AC_MSG_RESULT($dbus_have_gnuc_varargs)
227 dnl Output varargs tests
228 if test x$dbus_have_iso_c_varargs = xyes; then
229 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
231 if test x$dbus_have_gnuc_varargs = xyes; then
232 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
235 dnl Check for various credentials.
236 AC_MSG_CHECKING(for struct cmsgcred)
238 #include <sys/types.h>
239 #include <sys/socket.h>
241 struct cmsgcred cred;
244 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
245 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
247 if test x$dbus_have_struct_cmsgcred = xyes; then
248 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
252 #### Sort out XML library
255 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
256 [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
259 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
261 # see what we want to use
262 dbus_use_libxml=false
264 if test x$with_xml = xexpat; then
266 if ! $have_expat ; then
267 AC_MSG_ERROR([Explicitly requested expat but expat not found])
269 elif test x$with_xml = xlibxml; then
271 if ! $have_libxml ; then
272 AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
275 ### expat is the default because libxml can't currently survive
276 ### our brutal OOM-handling unit test setup.
277 ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
278 if $have_expat ; then
281 elif $have_libxml ; then
285 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
289 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
290 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
292 if $dbus_use_expat; then
296 if $dbus_use_libxml; then
297 XML_LIBS=$LIBXML_LIBS
298 XML_CFLAGS=$LIBXML_CFLAGS
301 #### Set up final flags
304 AC_SUBST(DBUS_CLIENT_CFLAGS)
305 AC_SUBST(DBUS_CLIENT_LIBS)
307 DBUS_BUS_CFLAGS=$XML_CFLAGS
308 DBUS_BUS_LIBS=$XML_LIBS
309 AC_SUBST(DBUS_BUS_CFLAGS)
310 AC_SUBST(DBUS_BUS_LIBS)
314 AC_SUBST(DBUS_TEST_CFLAGS)
315 AC_SUBST(DBUS_TEST_LIBS)
318 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
319 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
321 if test x$have_glib = xno ; then
322 AC_MSG_WARN([GLib development libraries not found])
325 if test x$enable_glib = xyes; then
326 if test x$have_glib = xno; then
327 AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
331 if test x$enable_glib = xno; then
335 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
336 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
339 AC_SUBST(DBUS_GLIB_CFLAGS)
340 AC_SUBST(DBUS_GLIB_LIBS)
341 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
345 if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
347 DBUS_QT_CXXFLAGS=-I$QTDIR/include
350 dnl linking to kdecore will give us a bit of help from libtool
351 if (! kde-config >& /dev/null); then
354 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
355 if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
358 DBUS_QT_LIBS=$kdelibs/libkdecore.la
362 if test x$have_qt = xno ; then
363 AC_MSG_WARN([Qt development libraries not found])
366 if test x$enable_qt = xyes; then
367 if test x$have_qt = xno; then
368 AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
372 if test x$enable_qt = xno; then
376 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
379 AC_SUBST(DBUS_QT_CXXFLAGS)
380 AC_SUBST(DBUS_QT_LIBS)
382 ##### Set up location for system bus socket
383 ## name of socket relative to localstatedir
384 DBUS_SYSTEM_SOCKET=run/dbus/system_bus_socket
385 AC_SUBST(DBUS_SYSTEM_SOCKET)
387 #### find the actual value for $prefix that we'll end up with
389 if test "x$prefix" = "xNONE"; then
390 REAL_PREFIX=$ac_default_prefix
395 #### Have to go $localstatedir->$prefix/var->/usr/local/var
396 #### someone please fix this a better way...
397 LOCALSTATEDIR_TMP="$localstatedir"
400 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
402 AC_SUBST(EXPANDED_LOCALSTATEDIR)
404 SYSCONFDIR_TMP="$sysconfdir"
407 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
409 AC_SUBST(EXPANDED_SYSCONFDIR)
414 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
416 AC_SUBST(EXPANDED_BINDIR)
418 #### Sort out init scripts
420 if test x$with_init_scripts = x; then
421 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
422 with_init_scripts=redhat
424 with_init_scripts=none
428 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
430 #### Tell tests where to find certain stuff in builddir
431 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
433 AC_DEFUN(TEST_PATH, [
434 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
435 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
436 [Full path to test file test/$2 in builddir])
440 TEST_PATH(SERVICE_DIR, data/valid-service-files)
441 TEST_PATH(SERVICE_BINARY, test-service)
442 TEST_PATH(EXIT_BINARY, test-exit)
443 TEST_PATH(SEGFAULT_BINARY, test-segfault)
444 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
460 test/data/valid-config-files/debug-allow-all.conf
461 test/data/valid-service-files/debug-echo.service
464 dnl ==========================================================================
470 source code location: ${srcdir}
474 Maintainer mode: ${USE_MAINTAINER_MODE}
475 gcc coverage profiling: ${enable_gcov}
476 Building unit tests: ${enable_tests}
477 Building verbose mode: ${enable_verbose_mode}
478 Building assertions: ${enable_asserts}
479 Building Qt bindings: ${have_qt}
480 Building GLib bindings: ${have_glib}
481 Using XML parser: ${with_xml}
482 System bus socket: ${EXPANDED_LOCALSTATEDIR}/${DBUS_SYSTEM_SOCKET}
483 Init scripts style: ${with_init_scripts}
486 if test x$enable_tests = xyes; then
487 echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
489 if test x$enable_gcov = xyes; then
490 echo "NOTE: building with coverage profiling is definitely for developers only."
492 if test x$enable_verbose_mode = xyes; then
493 echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and may cause a slight performance decrease, but aids debugging."
495 if test x$enable_asserts = xyes; then
496 echo "NOTE: building with assertions increases library size, but will help a lot when tracking down bugs in software using D-BUS."