6 AM_INIT_AUTOMAKE(dbus, 0.9)
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])
36 AC_ARG_WITH(session-socket-dir, [ --with-session-socket-dir=[dirname] Where to put sockets for the per-login-session message bus])
37 AC_ARG_WITH(test-socket-dir, [ --with-test-socket-dir=[dirname] Where to put sockets for make check])
38 AC_ARG_WITH(system-pid-file, [ --with-system-pid-file=[pidfile] PID file for systemwide daemon])
39 AC_ARG_WITH(system-socket, [ --with-system-socket=[filename] UNIX domain socket for systemwide daemon])
41 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
42 dnl and also some stuff in the test/ subdir
43 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
44 if test x$enable_tests = xyes; then
45 AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
48 if test x$enable_verbose_mode = xyes; then
49 AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
51 if test x$enable_asserts = xno; then
52 AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
55 #### gcc warning flags
57 if test "x$GCC" = "xyes"; then
60 *[\ \ ]-Wall[\ \ ]*) ;;
61 *) CFLAGS="$CFLAGS -Wall" ;;
65 *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
66 *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
70 *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
71 *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
75 *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
76 *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
80 *[\ \ ]-Wnested-externs[\ \ ]*) ;;
81 *) CFLAGS="$CFLAGS -Wnested-externs" ;;
85 *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
86 *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
90 *[\ \ ]-Wcast-align[\ \ ]*) ;;
91 *) CFLAGS="$CFLAGS -Wcast-align" ;;
95 *[\ \ ]-Wsign-compare[\ \ ]*) ;;
96 *) CFLAGS="$CFLAGS -Wsign-compare" ;;
99 if test "x$enable_ansi" = "xyes"; then
101 *[\ \ ]-ansi[\ \ ]*) ;;
102 *) CFLAGS="$CFLAGS -ansi" ;;
106 *[\ \ ]-pedantic[\ \ ]*) ;;
107 *) CFLAGS="$CFLAGS -pedantic" ;;
110 if test x$enable_gcov = xyes; then
112 *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
113 *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
116 *[\ \ ]-ftest-coverage[\ \ ]*) ;;
117 *) CFLAGS="$CFLAGS -ftest-coverage" ;;
120 ## remove optimization
121 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
125 if test x$enable_gcov = xyes; then
126 AC_MSG_ERROR([--enable-gcov can only be used with gcc])
130 # compress spaces in cflags
131 CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`
133 if test x$enable_gcov = xyes; then
134 ## so that config.h changes when you toggle gcov support
135 AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
137 AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
141 AC_CHECK_SIZEOF(char)
142 AC_CHECK_SIZEOF(short)
143 AC_CHECK_SIZEOF(long)
145 AC_CHECK_SIZEOF(void *)
146 AC_CHECK_SIZEOF(long long)
147 AC_CHECK_SIZEOF(__int64)
149 ### this is only used in decode-gcov.c right now
157 $ac_cv_sizeof_long_long)
158 dbusint64='long long'
160 $ac_cv_sizeof___int64)
165 AC_DEFINE_UNQUOTED(DBUS_INT64_TYPE, $dbusint64, [64-bit integer type])
170 #### Various functions
171 AC_CHECK_LIB(socket,socket)
172 AC_CHECK_LIB(nsl,gethostbyname)
174 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist)
176 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
178 AC_CACHE_CHECK([for posix getpwnam_r],
179 ac_cv_func_posix_getpwnam_r,
185 struct passwd pwd, *pwptr = &pwd;
188 error = getpwnam_r ("", &pwd, buffer,
189 sizeof (buffer), &pwptr);
190 return (error < 0 && errno == ENOSYS)
193 [ac_cv_func_posix_getpwnam_r=yes],
194 [ac_cv_func_posix_getpwnam_r=no])])
195 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
196 AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
197 [Have POSIX function getpwnam_r])
199 AC_CACHE_CHECK([for nonposix getpwnam_r],
200 ac_cv_func_nonposix_getpwnam_r,
201 [AC_TRY_LINK([#include <pwd.h>],
204 getpwnam_r ("", &pwd, buffer,
206 [ac_cv_func_nonposix_getpwnam_r=yes],
207 [ac_cv_func_nonposix_getpwnam_r=no])])
208 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
209 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
210 [Have non-POSIX function getpwnam_r])
214 dnl check for writev header and writev function so we're
215 dnl good to go if HAVE_WRITEV gets defined.
216 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
218 dnl check for flavours of varargs macros (test from GLib)
219 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
221 int a(int p1, int p2, int p3);
222 #define call_a(...) a(1,__VA_ARGS__)
224 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
225 AC_MSG_RESULT($dbus_have_iso_c_varargs)
227 AC_MSG_CHECKING(for GNUC varargs macros)
229 int a(int p1, int p2, int p3);
230 #define call_a(params...) a(1,params)
232 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
233 AC_MSG_RESULT($dbus_have_gnuc_varargs)
235 dnl Output varargs tests
236 if test x$dbus_have_iso_c_varargs = xyes; then
237 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
239 if test x$dbus_have_gnuc_varargs = xyes; then
240 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
243 dnl Check for various credentials.
244 AC_MSG_CHECKING(for struct cmsgcred)
246 #include <sys/types.h>
247 #include <sys/socket.h>
249 struct cmsgcred cred;
252 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
253 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
255 if test x$dbus_have_struct_cmsgcred = xyes; then
256 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
260 #### Sort out XML library
263 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
264 [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
267 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
269 # see what we want to use
270 dbus_use_libxml=false
272 if test x$with_xml = xexpat; then
274 if ! $have_expat ; then
275 AC_MSG_ERROR([Explicitly requested expat but expat not found])
277 elif test x$with_xml = xlibxml; then
279 if ! $have_libxml ; then
280 AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
283 ### expat is the default because libxml can't currently survive
284 ### our brutal OOM-handling unit test setup.
285 ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
286 if $have_expat ; then
289 elif $have_libxml ; then
293 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
297 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
298 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
300 if $dbus_use_expat; then
304 if $dbus_use_libxml; then
305 XML_LIBS=$LIBXML_LIBS
306 XML_CFLAGS=$LIBXML_CFLAGS
309 #### Set up final flags
312 AC_SUBST(DBUS_CLIENT_CFLAGS)
313 AC_SUBST(DBUS_CLIENT_LIBS)
315 DBUS_BUS_CFLAGS=$XML_CFLAGS
316 DBUS_BUS_LIBS=$XML_LIBS
317 AC_SUBST(DBUS_BUS_CFLAGS)
318 AC_SUBST(DBUS_BUS_LIBS)
322 AC_SUBST(DBUS_TEST_CFLAGS)
323 AC_SUBST(DBUS_TEST_LIBS)
326 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
327 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
329 if test x$have_glib = xno ; then
330 AC_MSG_WARN([GLib development libraries not found])
333 if test x$enable_glib = xyes; then
334 if test x$have_glib = xno; then
335 AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
339 if test x$enable_glib = xno; then
343 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
344 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
347 AC_SUBST(DBUS_GLIB_CFLAGS)
348 AC_SUBST(DBUS_GLIB_LIBS)
349 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
353 AC_MSG_CHECKING([for qglobal.h])
354 if test -n "$QTDIR" -a -f "$QTDIR/include/qglobal.h"; then
356 DBUS_QT_CXXFLAGS="-I$QTDIR/include"
358 for dir in "${prefix}/include/qt" "/usr/include/qt-3.1" "/usr/include/qt3" "/usr/include/qt" "/usr/lib/qt/include"; do
359 if test -f "$dir/qglobal.h"; then
361 DBUS_QT_CXXFLAGS="-I$dir"
365 if test x"$have_qt" = x"yes"; then
366 AC_MSG_RESULT([found])
368 AC_MSG_RESULT([not found])
371 dnl linking to kdecore will give us a bit of help from libtool
372 if (! kde-config >& /dev/null); then
375 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
376 if test -z $kdelibs -o ! -f $kdelibs/libkdecore.la; then
379 DBUS_QT_LIBS="$kdelibs/libkdecore.la"
383 if test x$have_qt = xno ; then
384 AC_MSG_WARN([Qt development libraries not found])
387 if test x$enable_qt = xyes; then
388 if test x$have_qt = xno; then
389 AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
393 if test x$enable_qt = xno; then
397 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
400 AC_SUBST(DBUS_QT_CXXFLAGS)
401 AC_SUBST(DBUS_QT_LIBS)
403 #### find the actual value for $prefix that we'll end up with
404 ## (I know this is broken and should be done in the Makefile, but
405 ## that's a major pain and almost nobody actually seems to care)
407 if test "x$prefix" = "xNONE"; then
408 REAL_PREFIX=$ac_default_prefix
413 #### Have to go $localstatedir->$prefix/var->/usr/local/var
414 #### someone please fix this a better way...
415 LOCALSTATEDIR_TMP="$localstatedir"
418 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
420 AC_SUBST(EXPANDED_LOCALSTATEDIR)
422 SYSCONFDIR_TMP="$sysconfdir"
425 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
427 AC_SUBST(EXPANDED_SYSCONFDIR)
432 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
434 AC_SUBST(EXPANDED_BINDIR)
436 #### Check our operating system
437 operating_system=unknown
438 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
439 operating_system=redhat
442 #### Sort out init scripts
444 if test x$with_init_scripts = x; then
445 if test xredhat = x$operating_system ; then
446 with_init_scripts=redhat
448 with_init_scripts=none
452 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
455 ##### Set up location for system bus socket
456 if ! test -z "$with_system_socket"; then
457 DBUS_SYSTEM_SOCKET=$with_system_socket
459 DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
462 AC_SUBST(DBUS_SYSTEM_SOCKET)
464 #### Set up the pid file
465 if ! test -z "$with_system_pid_file"; then
466 DBUS_SYSTEM_PID_FILE=$with_system_pid_file
467 elif test x$operating_system = xredhat ; then
468 DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
470 DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
473 AC_SUBST(DBUS_SYSTEM_PID_FILE)
475 #### Tell tests where to find certain stuff in builddir
476 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
478 AC_DEFUN(TEST_PATH, [
479 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
480 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
481 [Full path to test file test/$2 in builddir])
485 TEST_PATH(SERVICE_DIR, data/valid-service-files)
486 TEST_PATH(SERVICE_BINARY, test-service)
487 TEST_PATH(EXIT_BINARY, test-exit)
488 TEST_PATH(SEGFAULT_BINARY, test-segfault)
489 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
491 #### Find socket directories
492 if ! test -z "$TMPDIR" ; then
493 DEFAULT_SOCKET_DIR=$TMPDIR
494 elif ! test -z "$TEMP" ; then
495 DEFAULT_SOCKET_DIR=$TEMP
496 elif ! test -z "$TMP" ; then
497 DEFAULT_SOCKET_DIR=$TMP
499 DEFAULT_SOCKET_DIR=/tmp
502 if ! test -z "$with_test_socket_dir" ; then
503 TEST_SOCKET_DIR="$with_test_socket_dir"
505 TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
507 AC_SUBST(TEST_SOCKET_DIR)
509 if ! test -z "$with_session_socket_dir" ; then
510 DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
512 DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
514 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
532 test/data/valid-config-files/debug-allow-all.conf
533 test/data/valid-config-files/debug-allow-all-sha1.conf
534 test/data/valid-service-files/debug-echo.service
535 test/data/valid-service-files/debug-segfault.service
538 dnl ==========================================================================
544 source code location: ${srcdir}
548 Maintainer mode: ${USE_MAINTAINER_MODE}
549 gcc coverage profiling: ${enable_gcov}
550 Building unit tests: ${enable_tests}
551 Building verbose mode: ${enable_verbose_mode}
552 Building assertions: ${enable_asserts}
553 Building Qt bindings: ${have_qt}
554 Building GLib bindings: ${have_glib}
555 Using XML parser: ${with_xml}
556 Init scripts style: ${with_init_scripts}
557 System bus socket: ${DBUS_SYSTEM_SOCKET}
558 System bus PID file: ${DBUS_SYSTEM_PID_FILE}
559 Session bus socket dir: ${DBUS_SESSION_SOCKET_DIR}
560 'make check' socket dir: ${TEST_SOCKET_DIR}
563 if test x$enable_tests = xyes; then
564 echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
566 if test x$enable_gcov = xyes; then
567 echo "NOTE: building with coverage profiling is definitely for developers only."
569 if test x$enable_verbose_mode = xyes; then
570 echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and may cause a slight performance decrease, but aids debugging."
572 if test x$enable_asserts = xyes; then
573 echo "NOTE: building with assertions increases library size, but will help a lot when tracking down bugs in software using D-BUS."