6 AM_INIT_AUTOMAKE(dbus, 0.10)
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=$USE_MAINTAINER_MODE)
31 AC_ARG_ENABLE(asserts, [ --enable-asserts include assertion checks],enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
32 AC_ARG_ENABLE(checks, [ --enable-checks include sanity checks on public API],enable_checks=$enableval,enable_checks=yes)
33 AC_ARG_ENABLE(docs, [ --enable-docs build documentation (requires Doxygen and jade)],enable_docs=$enableval,enable_docs=auto)
34 AC_ARG_ENABLE(gcov, [ --enable-gcov compile with coverage profiling instrumentation (gcc only)],enable_gcov=$enableval,enable_gcov=no)
36 AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use])
37 AC_ARG_WITH(init-scripts, [ --with-init-scripts=[redhat] Style of init scripts to install])
38 AC_ARG_WITH(session-socket-dir, [ --with-session-socket-dir=[dirname] Where to put sockets for the per-login-session message bus])
39 AC_ARG_WITH(test-socket-dir, [ --with-test-socket-dir=[dirname] Where to put sockets for make check])
40 AC_ARG_WITH(system-pid-file, [ --with-system-pid-file=[pidfile] PID file for systemwide daemon])
41 AC_ARG_WITH(system-socket, [ --with-system-socket=[filename] UNIX domain socket for systemwide daemon])
43 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
44 dnl and also some stuff in the test/ subdir
45 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
46 if test x$enable_tests = xyes; then
47 AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
50 if test x$enable_verbose_mode = xyes; then
51 AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
53 if test x$enable_asserts = xno; then
54 AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
56 if test x$enable_checks = xno; then
57 AC_DEFINE(DBUS_DISABLE_CHECKS,1,[Disable public API sanity checking])
60 #### gcc warning flags
62 if test "x$GCC" = "xyes"; then
65 *[\ \ ]-Wall[\ \ ]*) ;;
66 *) CFLAGS="$CFLAGS -Wall" ;;
70 *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
71 *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
75 *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
76 *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
80 *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
81 *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
85 *[\ \ ]-Wnested-externs[\ \ ]*) ;;
86 *) CFLAGS="$CFLAGS -Wnested-externs" ;;
90 *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
91 *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
95 *[\ \ ]-Wcast-align[\ \ ]*) ;;
96 *) CFLAGS="$CFLAGS -Wcast-align" ;;
100 *[\ \ ]-Wsign-compare[\ \ ]*) ;;
101 *) CFLAGS="$CFLAGS -Wsign-compare" ;;
104 if test "x$enable_ansi" = "xyes"; then
106 *[\ \ ]-ansi[\ \ ]*) ;;
107 *) CFLAGS="$CFLAGS -ansi" ;;
111 *[\ \ ]-pedantic[\ \ ]*) ;;
112 *) CFLAGS="$CFLAGS -pedantic" ;;
115 if test x$enable_gcov = xyes; then
117 *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
118 *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
121 *[\ \ ]-ftest-coverage[\ \ ]*) ;;
122 *) CFLAGS="$CFLAGS -ftest-coverage" ;;
125 ## remove optimization
126 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
130 if test x$enable_gcov = xyes; then
131 AC_MSG_ERROR([--enable-gcov can only be used with gcc])
136 # let ourselves use our own unstable API
137 CPPFLAGS="-DDBUS_API_SUBJECT_TO_CHANGE=1 $CPPFLAGS"
138 # compress spaces in flags
139 CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`
140 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ +/ /g'`
141 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ +/ /g'`
144 if test x$enable_gcov = xyes; then
145 ## so that config.h changes when you toggle gcov support
146 AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
148 AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
152 AC_CHECK_SIZEOF(char)
153 AC_CHECK_SIZEOF(short)
154 AC_CHECK_SIZEOF(long)
156 AC_CHECK_SIZEOF(void *)
157 AC_CHECK_SIZEOF(long long)
158 AC_CHECK_SIZEOF(__int64)
160 ### See what our 64 bit type is called
161 AC_MSG_CHECKING([64-bit integer type])
166 dbusint64_constant='(val)'
167 dbusuint64_constant='(val)'
171 dbusint64_constant='(val##L)'
172 dbusuint64_constant='(val##UL)'
174 $ac_cv_sizeof_long_long)
175 dbusint64='long long'
176 dbusint64_constant='(val##LL)'
177 dbusuint64_constant='(val##ULL)'
179 $ac_cv_sizeof___int64)
181 dbusint64_constant='(val##i64)'
182 dbusuint64_constant='(val##ui64)'
186 if test -z "$dbusint64" ; then
187 DBUS_INT64_TYPE="no_int64_type_detected"
190 DBUS_UINT64_CONSTANT=
191 AC_MSG_RESULT([none found])
193 DBUS_INT64_TYPE="$dbusint64"
195 DBUS_INT64_CONSTANT="$dbusint64_constant"
196 DBUS_UINT64_CONSTANT="$dbusuint64_constant"
197 AC_MSG_RESULT($DBUS_INT64_TYPE)
200 AC_SUBST(DBUS_INT64_TYPE)
201 AC_SUBST(DBUS_INT64_CONSTANT)
202 AC_SUBST(DBUS_UINT64_CONSTANT)
203 AC_SUBST(DBUS_HAVE_INT64)
208 #### Various functions
209 AC_CHECK_LIB(socket,socket)
210 AC_CHECK_LIB(nsl,gethostbyname)
212 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist)
214 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
216 AC_CACHE_CHECK([for posix getpwnam_r],
217 ac_cv_func_posix_getpwnam_r,
223 struct passwd pwd, *pwptr = &pwd;
226 error = getpwnam_r ("", &pwd, buffer,
227 sizeof (buffer), &pwptr);
228 return (error < 0 && errno == ENOSYS)
231 [ac_cv_func_posix_getpwnam_r=yes],
232 [ac_cv_func_posix_getpwnam_r=no])])
233 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
234 AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
235 [Have POSIX function getpwnam_r])
237 AC_CACHE_CHECK([for nonposix getpwnam_r],
238 ac_cv_func_nonposix_getpwnam_r,
239 [AC_TRY_LINK([#include <pwd.h>],
242 getpwnam_r ("", &pwd, buffer,
244 [ac_cv_func_nonposix_getpwnam_r=yes],
245 [ac_cv_func_nonposix_getpwnam_r=no])])
246 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
247 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
248 [Have non-POSIX function getpwnam_r])
252 dnl check for writev header and writev function so we're
253 dnl good to go if HAVE_WRITEV gets defined.
254 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
256 dnl check for flavours of varargs macros (test from GLib)
257 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
259 int a(int p1, int p2, int p3);
260 #define call_a(...) a(1,__VA_ARGS__)
262 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
263 AC_MSG_RESULT($dbus_have_iso_c_varargs)
265 AC_MSG_CHECKING(for GNUC varargs macros)
267 int a(int p1, int p2, int p3);
268 #define call_a(params...) a(1,params)
270 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
271 AC_MSG_RESULT($dbus_have_gnuc_varargs)
273 dnl Output varargs tests
274 if test x$dbus_have_iso_c_varargs = xyes; then
275 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
277 if test x$dbus_have_gnuc_varargs = xyes; then
278 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
281 dnl Check for various credentials.
282 AC_MSG_CHECKING(for struct cmsgcred)
284 #include <sys/types.h>
285 #include <sys/socket.h>
287 struct cmsgcred cred;
290 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
291 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
293 if test x$dbus_have_struct_cmsgcred = xyes; then
294 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
298 #### Sort out XML library
301 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
302 [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
305 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
307 # see what we want to use
308 dbus_use_libxml=false
310 if test x$with_xml = xexpat; then
312 if ! $have_expat ; then
313 AC_MSG_ERROR([Explicitly requested expat but expat not found])
315 elif test x$with_xml = xlibxml; then
317 if ! $have_libxml ; then
318 AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
321 ### expat is the default because libxml can't currently survive
322 ### our brutal OOM-handling unit test setup.
323 ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
324 if $have_expat ; then
327 elif $have_libxml ; then
331 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
335 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
336 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
338 if $dbus_use_expat; then
342 if $dbus_use_libxml; then
343 XML_LIBS=$LIBXML_LIBS
344 XML_CFLAGS=$LIBXML_CFLAGS
347 #### Set up final flags
350 AC_SUBST(DBUS_CLIENT_CFLAGS)
351 AC_SUBST(DBUS_CLIENT_LIBS)
353 DBUS_BUS_CFLAGS=$XML_CFLAGS
354 DBUS_BUS_LIBS=$XML_LIBS
355 AC_SUBST(DBUS_BUS_CFLAGS)
356 AC_SUBST(DBUS_BUS_LIBS)
360 AC_SUBST(DBUS_TEST_CFLAGS)
361 AC_SUBST(DBUS_TEST_LIBS)
364 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
365 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
367 if test x$have_glib = xno ; then
368 AC_MSG_WARN([GLib development libraries not found])
371 if test x$enable_glib = xyes; then
372 if test x$have_glib = xno; then
373 AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
377 if test x$enable_glib = xno; then
381 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
382 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
385 AC_SUBST(DBUS_GLIB_CFLAGS)
386 AC_SUBST(DBUS_GLIB_LIBS)
387 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
391 AC_MSG_CHECKING([for qglobal.h])
392 if test -n "$QTDIR" -a -f "$QTDIR/include/qglobal.h"; then
394 DBUS_QT_CXXFLAGS="-I$QTDIR/include"
396 for dir in "${prefix}/include/qt" "/usr/include/qt-3.1" "/usr/include/qt3" "/usr/include/qt" "/usr/lib/qt/include"; do
397 if test -f "$dir/qglobal.h"; then
399 DBUS_QT_CXXFLAGS="-I$dir"
403 if test x"$have_qt" = x"yes"; then
404 AC_MSG_RESULT([found])
406 AC_MSG_RESULT([not found])
409 dnl linking to kdecore will give us a bit of help from libtool
410 if (! kde-config >& /dev/null); then
413 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
414 if test -z $kdelibs -o ! -f $kdelibs/libkdecore.la; then
417 DBUS_QT_LIBS="$kdelibs/libkdecore.la"
421 if test x$have_qt = xno ; then
422 AC_MSG_WARN([Qt development libraries not found])
425 if test x$enable_qt = xyes; then
426 if test x$have_qt = xno; then
427 AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
431 if test x$enable_qt = xno; then
435 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
438 AC_SUBST(DBUS_QT_CXXFLAGS)
439 AC_SUBST(DBUS_QT_LIBS)
443 AC_PATH_PROG(DOXYGEN, doxygen, no)
444 AC_PATH_PROG(DB2HTML, db2html, no)
446 AC_MSG_CHECKING([whether to build documentation])
448 if test x$DOXYGEN = xno -o x$DB2HTML = xno ; then
454 if test x$enable_docs = xauto ; then
455 if test x$have_docs_tools = xno ; then
462 if test x$enable_docs = xyes; then
463 if test x$have_docs_tools = xno; then
464 AC_MSG_ERROR([Building docs explicitly required, but Doxygen or db2html not found])
468 AM_CONDITIONAL(DBUS_DOCS_ENABLED, test x$enable_docs = xyes)
471 #### find the actual value for $prefix that we'll end up with
472 ## (I know this is broken and should be done in the Makefile, but
473 ## that's a major pain and almost nobody actually seems to care)
475 if test "x$prefix" = "xNONE"; then
476 REAL_PREFIX=$ac_default_prefix
481 #### Have to go $localstatedir->$prefix/var->/usr/local/var
482 #### someone please fix this a better way...
483 LOCALSTATEDIR_TMP="$localstatedir"
486 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
488 AC_SUBST(EXPANDED_LOCALSTATEDIR)
490 SYSCONFDIR_TMP="$sysconfdir"
493 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
495 AC_SUBST(EXPANDED_SYSCONFDIR)
500 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
502 AC_SUBST(EXPANDED_BINDIR)
504 #### Check our operating system
505 operating_system=unknown
506 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
507 operating_system=redhat
510 #### Sort out init scripts
512 if test x$with_init_scripts = x; then
513 if test xredhat = x$operating_system ; then
514 with_init_scripts=redhat
516 with_init_scripts=none
520 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
523 ##### Set up location for system bus socket
524 if ! test -z "$with_system_socket"; then
525 DBUS_SYSTEM_SOCKET=$with_system_socket
527 DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
530 AC_SUBST(DBUS_SYSTEM_SOCKET)
532 #### Set up the pid file
533 if ! test -z "$with_system_pid_file"; then
534 DBUS_SYSTEM_PID_FILE=$with_system_pid_file
535 elif test x$operating_system = xredhat ; then
536 DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
538 DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
541 AC_SUBST(DBUS_SYSTEM_PID_FILE)
543 #### Tell tests where to find certain stuff in builddir
544 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
546 AC_DEFUN(TEST_PATH, [
547 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
548 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
549 [Full path to test file test/$2 in builddir])
553 TEST_PATH(SERVICE_DIR, data/valid-service-files)
554 TEST_PATH(SERVICE_BINARY, test-service)
555 TEST_PATH(EXIT_BINARY, test-exit)
556 TEST_PATH(SEGFAULT_BINARY, test-segfault)
557 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
559 #### Find socket directories
560 if ! test -z "$TMPDIR" ; then
561 DEFAULT_SOCKET_DIR=$TMPDIR
562 elif ! test -z "$TEMP" ; then
563 DEFAULT_SOCKET_DIR=$TEMP
564 elif ! test -z "$TMP" ; then
565 DEFAULT_SOCKET_DIR=$TMP
567 DEFAULT_SOCKET_DIR=/tmp
570 if ! test -z "$with_test_socket_dir" ; then
571 TEST_SOCKET_DIR="$with_test_socket_dir"
573 TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
575 AC_SUBST(TEST_SOCKET_DIR)
577 if ! test -z "$with_session_socket_dir" ; then
578 DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
580 DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
582 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
592 dbus/dbus-arch-deps.h
601 test/data/valid-config-files/debug-allow-all.conf
602 test/data/valid-config-files/debug-allow-all-sha1.conf
603 test/data/valid-service-files/debug-echo.service
604 test/data/valid-service-files/debug-segfault.service
607 dnl ==========================================================================
613 source code location: ${srcdir}
616 cppflags: ${CPPFLAGS}
617 cxxflags: ${CXXFLAGS}
621 Maintainer mode: ${USE_MAINTAINER_MODE}
622 gcc coverage profiling: ${enable_gcov}
623 Building unit tests: ${enable_tests}
624 Building verbose mode: ${enable_verbose_mode}
625 Building assertions: ${enable_asserts}
626 Building checks: ${enable_checks}
627 Building Qt bindings: ${have_qt}
628 Building GLib bindings: ${have_glib}
629 Building documentation: ${enable_docs}
630 Using XML parser: ${with_xml}
631 Init scripts style: ${with_init_scripts}
632 System bus socket: ${DBUS_SYSTEM_SOCKET}
633 System bus PID file: ${DBUS_SYSTEM_PID_FILE}
634 Session bus socket dir: ${DBUS_SESSION_SOCKET_DIR}
635 'make check' socket dir: ${TEST_SOCKET_DIR}
638 if test x$enable_tests = xyes; then
639 echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
641 if test x$enable_tests = xyes -a x$enable_asserts = xno; then
642 echo "NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)"
644 if test x$enable_gcov = xyes; then
645 echo "NOTE: building with coverage profiling is definitely for developers only."
647 if test x$enable_verbose_mode = xyes; then
648 echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
650 if test x$enable_asserts = xyes; then
651 echo "NOTE: building with assertions increases library size and decreases performance."
653 if test x$enable_checks = xno; then
654 echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-BUS, but will slightly decrease D-BUS library size and _very_ slightly improve performance."