Release 1.2.24
[platform/upstream/dbus.git] / configure.in
1 dnl -*- mode: m4 -*-
2 AC_PREREQ(2.52)
3
4 m4_define([dbus_major_version], [1])
5 m4_define([dbus_minor_version], [2])
6 m4_define([dbus_micro_version], [24])
7 m4_define([dbus_version],
8           [dbus_major_version.dbus_minor_version.dbus_micro_version])
9 AC_INIT(dbus, [dbus_version])
10
11 AC_CANONICAL_HOST
12
13 AM_INIT_AUTOMAKE([1.9 tar-ustar])
14 AM_CONFIG_HEADER(config.h)
15
16 # Honor aclocal flags
17 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
18
19 GETTEXT_PACKAGE=dbus-1
20 AC_SUBST(GETTEXT_PACKAGE)
21 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
22
23  ## must come before we use the $USE_MAINTAINER_MODE variable later
24 AM_MAINTAINER_MODE
25
26 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
27
28 # libtool versioning - this applies to libdbus
29 #
30 # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
31 #
32
33 ## increment if the interface has additions, changes, removals.
34 LT_CURRENT=7
35
36 ## increment any time the source changes; set to
37 ##  0 if you increment CURRENT
38 LT_REVISION=0
39
40 ## increment if any interfaces have been added; set to 0
41 ## if any interfaces have been changed or removed. removal has
42 ## precedence over adding, so set to 0 if both happened.
43 LT_AGE=4
44
45 AC_SUBST(LT_CURRENT)
46 AC_SUBST(LT_REVISION)
47 AC_SUBST(LT_AGE)
48
49 DBUS_MAJOR_VERSION=dbus_major_version
50 DBUS_MINOR_VERSION=dbus_minor_version
51 DBUS_MICRO_VERSION=dbus_micro_version
52 DBUS_VERSION=dbus_major_version.dbus_minor_version.dbus_micro_version
53
54 AC_SUBST(DBUS_MAJOR_VERSION)
55 AC_SUBST(DBUS_MINOR_VERSION)
56 AC_SUBST(DBUS_MICRO_VERSION)
57 AC_SUBST(DBUS_VERSION)
58
59 AC_PROG_CC
60 AM_PROG_CC_C_O
61 AC_PROG_CXX
62 AC_ISC_POSIX
63 AC_HEADER_STDC
64 AC_C_INLINE
65 AM_PROG_LIBTOOL
66
67 AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
68 AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
69 AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
70 AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
71 AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes)
72 AC_ARG_ENABLE(xml-docs, AS_HELP_STRING([--enable-xml-docs],[build XML documentation (requires xmlto)]),enable_xml_docs=$enableval,enable_xml_docs=auto)
73 AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGEN documentation (requires Doxygen)]),enable_doxygen_docs=$enableval,enable_doxygen_docs=auto)
74 AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no)
75 AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
76 AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto)
77 AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon support for SELinux]),enable_libaudit=$enableval,enable_libaudit=auto)
78 AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto)
79 AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify support (linux only)]),enable_inotify=$enableval,enable_inotify=auto)
80 AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto)
81 AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto)
82 AC_ARG_ENABLE(userdb-cache, AS_HELP_STRING([--enable-userdb-cache],[build with userdb-cache support]),enable_userdb_cache=$enableval,enable_userdb_cache=yes)
83
84 AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use]))
85 AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install]))
86 AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus]))
87 AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check]))
88 AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon]))
89 AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon]))
90 AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip]))
91 AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner]))
92 AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
93 AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
94
95 AC_DEFINE(DBUS_UNIX,1,[dbus on unix])
96
97 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files 
98 dnl and also some stuff in the test/ subdir
99 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
100 if test x$enable_tests = xyes; then
101     AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
102 fi
103
104 if test x$enable_verbose_mode = xyes; then
105     AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
106 fi
107
108 if test x$enable_asserts = xno; then
109     AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
110     AC_DEFINE(G_DISABLE_ASSERT,1,[Disable GLib assertion macros])
111     R_DYNAMIC_LDFLAG=""
112 else
113     # -rdynamic is needed for glibc's backtrace_symbols to work.
114     # No clue how much overhead this adds, but it's useful 
115     # to do this on any assertion failure,
116     # so for now it's enabled anytime asserts are (currently not
117     # in production builds).
118
119     # To get -rdynamic you pass -export-dynamic to libtool.
120     AC_DEFINE(DBUS_BUILT_R_DYNAMIC,1,[whether -export-dynamic was passed to libtool])
121     R_DYNAMIC_LDFLAG=-export-dynamic
122 fi
123 AC_SUBST(R_DYNAMIC_LDFLAG)
124
125 if test x$enable_checks = xno; then
126     AC_DEFINE(DBUS_DISABLE_CHECKS,1,[Disable public API sanity checking])
127     AC_DEFINE(G_DISABLE_CHECKS,1,[Disable GLib public API sanity checking])
128 fi
129
130 if test x$enable_userdb_cache = xyes; then
131     AC_DEFINE(DBUS_ENABLE_USERDB_CACHE,1,[Build with caching of user data])
132 fi
133
134 if test x$enable_gcov = xyes; then
135      ## so that config.h changes when you toggle gcov support
136      AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
137
138      AC_MSG_CHECKING([for gcc 3.3 version of gcov file format])
139      have_gcc33_gcov=no
140      AC_RUN_IFELSE( [AC_LANG_PROGRAM( , [[ if (__GNUC__ >=3 && __GNUC_MINOR__ >= 3) exit (0); else exit (1); ]])],  
141                    have_gcc33_gcov=yes)
142      if test x$have_gcc33_gcov = xyes ; then
143          AC_DEFINE_UNQUOTED(DBUS_HAVE_GCC33_GCOV, 1, [Defined if we have gcc 3.3 and thus the new gcov format])
144      fi
145      AC_MSG_RESULT($have_gcc33_gcov)
146 fi
147 AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
148
149 # glibc21.m4 serial 3
150 dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
151 dnl This file is free software; the Free Software Foundation
152 dnl gives unlimited permission to copy and/or distribute it,
153 dnl with or without modifications, as long as this notice is preserved.
154
155 # Test for the GNU C Library, version 2.1 or newer.
156 # From Bruno Haible.
157
158 AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
159   ac_cv_gnu_library_2_1,
160   [AC_EGREP_CPP([Lucky GNU user],
161     [
162 #include <features.h>
163 #ifdef __GNU_LIBRARY__
164  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
165   Lucky GNU user
166  #endif
167 #endif
168     ],
169     ac_cv_gnu_library_2_1=yes,
170     ac_cv_gnu_library_2_1=no)
171   ]
172 )
173
174 #### Integer sizes 
175
176 AC_CHECK_SIZEOF(char)
177 AC_CHECK_SIZEOF(short)
178 AC_CHECK_SIZEOF(long)
179 AC_CHECK_SIZEOF(int)
180 AC_CHECK_SIZEOF(void *)
181 AC_CHECK_SIZEOF(long long)
182 AC_CHECK_SIZEOF(__int64)
183
184 ### See what our 64 bit type is called
185 AC_MSG_CHECKING([64-bit integer type])
186
187 case 8 in
188 $ac_cv_sizeof_int)
189   dbusint64=int
190   dbusint64_constant='(val)'
191   dbusuint64_constant='(val)'
192   dbusint64_printf_modifier='""'
193   ;;
194 $ac_cv_sizeof_long)
195   dbusint64=long
196   dbusint64_constant='(val##L)'
197   dbusuint64_constant='(val##UL)'
198   dbusint64_printf_modifier='"l"'
199   ;;
200 $ac_cv_sizeof_long_long)
201   dbusint64='long long'
202   dbusint64_constant='(val##LL)'
203   dbusuint64_constant='(val##ULL)'
204   # Ideally we discover what the format is, but this is
205   # only used in verbose mode, so eh...
206   if test x"$ac_cv_gnu_library_2_1" = xyes; then
207     dbusint64_printf_modifier='"ll"'
208   fi
209   ;;
210 $ac_cv_sizeof___int64)
211   dbusint64=__int64
212   dbusint64_constant='(val##i64)'
213   dbusuint64_constant='(val##ui64)'
214   # See above case
215   if test x"$ac_cv_gnu_library_2_1" = xyes; then
216     dbusint64_printf_modifier='"ll"'
217   fi
218   ;;
219 esac
220
221 if test -z "$dbusint64" ; then
222         DBUS_INT64_TYPE="no_int64_type_detected"
223         DBUS_HAVE_INT64=0
224         DBUS_INT64_CONSTANT=
225         DBUS_UINT64_CONSTANT=
226         AC_MSG_RESULT([none found])
227 else
228         DBUS_INT64_TYPE="$dbusint64"
229         DBUS_HAVE_INT64=1
230         DBUS_INT64_CONSTANT="$dbusint64_constant"
231         DBUS_UINT64_CONSTANT="$dbusuint64_constant"
232         if test x"$dbusint64_printf_modifier" != x; then
233                 AC_DEFINE_UNQUOTED(DBUS_INT64_PRINTF_MODIFIER, [$dbusint64_printf_modifier], [Define to printf modifier for 64 bit integer type])
234         fi
235         AC_MSG_RESULT($DBUS_INT64_TYPE)
236 fi
237
238 AC_SUBST(DBUS_INT64_TYPE)
239 AC_SUBST(DBUS_INT64_CONSTANT)
240 AC_SUBST(DBUS_UINT64_CONSTANT)
241 AC_SUBST(DBUS_HAVE_INT64)
242
243 ### see what 32-bit int is called
244 AC_MSG_CHECKING([32-bit integer type])
245
246 case 4 in
247 $ac_cv_sizeof_short)
248   dbusint32=int
249   ;;
250 $ac_cv_sizeof_int)
251   dbusint32=int
252   ;;
253 $ac_cv_sizeof_long)
254   dbusint32=long
255   ;;
256 esac
257
258 if test -z "$dbusint32" ; then
259         DBUS_INT32_TYPE="no_int32_type_detected"
260         AC_MSG_ERROR([No 32-bit integer type found])
261 else
262         DBUS_INT32_TYPE="$dbusint32"
263         AC_MSG_RESULT($DBUS_INT32_TYPE)
264 fi
265
266 AC_SUBST(DBUS_INT32_TYPE)
267
268 ### see what 16-bit int is called
269 AC_MSG_CHECKING([16-bit integer type])
270
271 case 2 in
272 $ac_cv_sizeof_short)
273   dbusint16=short
274   ;;
275 $ac_cv_sizeof_int)
276   dbusint16=int
277   ;;
278 esac
279
280 if test -z "$dbusint16" ; then
281         DBUS_INT16_TYPE="no_int16_type_detected"
282         AC_MSG_ERROR([No 16-bit integer type found])
283 else
284         DBUS_INT16_TYPE="$dbusint16"
285         AC_MSG_RESULT($DBUS_INT16_TYPE)
286 fi
287
288 AC_SUBST(DBUS_INT16_TYPE)
289
290 ## byte order
291 case $host_os in
292         darwin*)
293                 # check at compile-time, so that it is possible to build universal
294                 # (with multiple architectures at once on the compile line)
295                 AH_VERBATIM([WORDS_BIGENDIAN_DARWIN], [
296                         /* Use the compiler-provided endianness defines to allow universal compiling. */
297                         #if defined(__BIG_ENDIAN__)
298                         #define WORDS_BIGENDIAN 1
299                         #endif
300                 ])
301                 ;;
302         *)
303                 AC_C_BIGENDIAN
304                 ;;
305 esac
306
307 dnl **********************************
308 dnl *** va_copy checks (from GLib) ***
309 dnl **********************************
310 dnl we currently check for all three va_copy possibilities, so we get
311 dnl all results in config.log for bug reports.
312 AC_CACHE_CHECK([for an implementation of va_copy()],dbus_cv_va_copy,[
313         AC_LINK_IFELSE([#include <stdarg.h>
314 #include <stdlib.h>
315         static void f (int i, ...) {
316         va_list args1, args2;
317         va_start (args1, i);
318         va_copy (args2, args1);
319         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
320           exit (1);
321         va_end (args1); va_end (args2);
322         }
323         int main() {
324           f (0, 42);
325           return 0;
326         }],
327         [dbus_cv_va_copy=yes],
328         [dbus_cv_va_copy=no])
329 ])
330 AC_CACHE_CHECK([for an implementation of __va_copy()],dbus_cv___va_copy,[
331         AC_LINK_IFELSE([#include <stdarg.h>
332 #include <stdlib.h>
333         static void f (int i, ...) {
334         va_list args1, args2;
335         va_start (args1, i);
336         __va_copy (args2, args1);
337         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
338           exit (1);
339         va_end (args1); va_end (args2);
340         }
341         int main() {
342           f (0, 42);
343           return 0;
344         }],
345         [dbus_cv___va_copy=yes],
346         [dbus_cv___va_copy=no])
347 ])
348
349 if test "x$dbus_cv_va_copy" = "xyes"; then
350   dbus_va_copy_func=va_copy
351 else if test "x$dbus_cv___va_copy" = "xyes"; then
352   dbus_va_copy_func=__va_copy
353 fi
354 fi
355
356 if test -n "$dbus_va_copy_func"; then
357   AC_DEFINE_UNQUOTED(DBUS_VA_COPY,$dbus_va_copy_func,[A 'va_copy' style function])
358 fi
359
360 AC_LANG_PUSH(C)
361 AC_CACHE_CHECK([whether va_lists can be copied by value],
362         dbus_cv_va_val_copy,
363         [AC_RUN_IFELSE([AC_LANG_PROGRAM(
364 [[
365         #include <stdarg.h>
366         #include <stdlib.h>
367 ]],
368 [[
369         static void f (int i, ...) {
370         va_list args1, args2;
371         va_start (args1, i);
372         args2 = args1;
373         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
374           exit (1);
375         va_end (args1); va_end (args2);
376         }
377         int main() {
378           f (0, 42);
379           return 0;
380         }
381 ]])],
382         [dbus_cv_va_val_copy=yes],
383         [dbus_cv_va_val_copy=no],
384         [dbus_cv_va_val_copy=yes])
385 ])
386 AC_LANG_POP(C)
387
388 if test "x$dbus_cv_va_val_copy" = "xno"; then
389   AC_DEFINE(DBUS_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
390 fi
391
392
393 #### Atomic integers (checks by Sebastian Wilhelmi for GLib)
394 AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers])
395 have_atomic_inc_cond=0
396 if test x"$GCC" = xyes; then
397   if test "x$enable_ansi" = "xyes"; then
398     AC_MSG_RESULT([no])
399   else
400     case $host_cpu in
401       i386)
402         AC_MSG_RESULT([no])
403         ;;
404       i?86)
405         case $host_os in
406           darwin*)
407             AC_MSG_RESULT([darwin])
408             # check at compile-time, so that it is possible to build universal
409             # (with multiple architectures at once on the compile line)
410             have_atomic_inc_cond="(defined(__i386__) || defined(__x86_64__))"
411             ;;
412           *)
413             AC_MSG_RESULT([i486])
414             have_atomic_inc_cond=1
415             ;;
416         esac
417         ;;
418       *)
419         AC_MSG_RESULT([no])
420         ;;
421     esac
422   fi
423 fi
424 AC_DEFINE_UNQUOTED([DBUS_USE_ATOMIC_INT_486_COND], [$have_atomic_inc_cond],
425                    [Always defined; expands to 1 if we should use atomic integer implementation for 486, else 0])
426 AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, [$have_atomic_inc_cond],
427                    [Always defined; expands to 1 if we have an atomic integer implementation, else 0])
428
429 #### Various functions
430 AC_SEARCH_LIBS(socket,[socket network])
431 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
432
433 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll)
434
435 #### Check for broken poll; taken from Glib's configure
436
437 AC_MSG_CHECKING([for broken poll])
438 AC_RUN_IFELSE([AC_LANG_SOURCE([[
439     #include <stdlib.h>
440     #include <fcntl.h>
441     #include <poll.h>
442     #ifdef HAVE_SYS_POLL_H
443     #include <sys/poll.h>
444     #endif
445     int main(void) {
446       struct pollfd fds[1];
447       int fd;
448       fd = open("/dev/null", 1);
449       fds[0].fd = fd;
450       fds[0].events = POLLIN;
451       fds[0].revents = 0;
452       if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
453             exit(1);  /* Does not work for devices -- fail */
454       }
455       exit(0);
456     }]])],
457   [broken_poll=no],
458   [broken_poll=yes
459    AC_DEFINE(BROKEN_POLL,1,[poll doesn't work on devices])],
460   [broken_poll="no (cross compiling)"])
461 AC_MSG_RESULT($broken_poll)
462
463 AC_MSG_CHECKING(for dirfd)
464 AC_TRY_LINK([
465 #include <sys/types.h>
466 #include <dirent.h>
467 ],[
468 DIR *dirp;
469 dirp = opendir(".");
470 dirfd(dirp);
471 closedir(dirp);
472 ], 
473 dbus_have_dirfd=yes, dbus_have_dirfd=no)
474 AC_MSG_RESULT($dbus_have_dirfd)
475 if test "$dbus_have_dirfd" = yes; then
476         AC_DEFINE(HAVE_DIRFD,1,[Have dirfd function])
477 else
478         AC_MSG_CHECKING(for DIR *dirp->dd_fd)    
479         AC_TRY_LINK([
480 #include <sys/types.h>
481 #include <dirent.h>
482         ],[
483 DIR *dirp;
484 int fd;
485 dirp = opendir(".");
486 fd = dirp->dd_fd;
487 closedir(dirp);
488         ],
489         dbus_have_ddfd=yes, dbus_have_ddfd=no)
490         AC_MSG_RESULT($dbus_have_ddfd)
491         if test "$dbus_have_ddfd" = yes; then
492                 AC_DEFINE(HAVE_DDFD,1,[Have the ddfd member of DIR])
493         fi
494 fi
495
496 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
497
498 AC_CHECK_HEADERS(errno.h)
499
500 AC_CHECK_HEADERS(unistd.h)
501
502 # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris
503 #
504 case $host_os in
505     solaris*)
506        CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;;
507 esac
508     
509 # checking for a posix version of getpwnam_r
510 # if we are cross compiling and can not run the test
511 # assume getpwnam_r is the posix version
512 # it is up to the person cross compiling to change
513 # this behavior if desired
514 AC_LANG_PUSH(C)
515 AC_CACHE_CHECK([for posix getpwnam_r],
516                 ac_cv_func_posix_getpwnam_r,
517                 [AC_RUN_IFELSE([AC_LANG_PROGRAM(
518 [[
519 #include <errno.h>
520 #include <pwd.h>
521 ]],
522 [[
523     char buffer[10000];
524     struct passwd pwd, *pwptr = &pwd;
525     int error;
526     errno = 0;
527     error = getpwnam_r ("", &pwd, buffer, 
528                         sizeof (buffer), &pwptr);
529    return (error < 0 && errno == ENOSYS) 
530            || error == ENOSYS; 
531 ]])],
532         [ac_cv_func_posix_getpwnam_r=yes],
533         [ac_cv_func_posix_getpwnam_r=no],
534         [ac_cv_func_posix_getpwnam_r=yes]
535 )])
536 AC_LANG_POP(C)
537
538 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
539         AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
540                 [Have POSIX function getpwnam_r])
541 else
542         AC_CACHE_CHECK([for nonposix getpwnam_r],
543                 ac_cv_func_nonposix_getpwnam_r,
544                 [AC_TRY_LINK([#include <pwd.h>],
545                         [char buffer[10000];
546                         struct passwd pwd;
547                         getpwnam_r ("", &pwd, buffer, 
548                                         sizeof (buffer));],
549                         [ac_cv_func_nonposix_getpwnam_r=yes],
550                         [ac_cv_func_nonposix_getpwnam_r=no])])
551                 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
552                 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
553                         [Have non-POSIX function getpwnam_r])
554         fi
555 fi
556
557 dnl check for socklen_t
558 AC_MSG_CHECKING(whether socklen_t is defined)
559 AC_TRY_COMPILE([
560 #include <sys/types.h>
561 #include <sys/socket.h>
562 #include <netdb.h>
563 ],[
564 socklen_t foo;
565 foo = 1;
566 ],dbus_have_socklen_t=yes,dbus_have_socklen_t=no)
567 AC_MSG_RESULT($dbus_have_socklen_t)
568
569 if test "x$dbus_have_socklen_t" = "xyes"; then
570     AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type])
571 fi
572
573 dnl check for writev header and writev function so we're 
574 dnl good to go if HAVE_WRITEV gets defined.
575 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
576
577 dnl needed on darwin for NAME_MAX
578 AC_CHECK_HEADERS(sys/syslimits.h)
579
580 dnl check for flavours of varargs macros (test from GLib)
581 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
582 AC_TRY_COMPILE([],[
583 int a(int p1, int p2, int p3);
584 #define call_a(...) a(1,__VA_ARGS__)
585 call_a(2,3);
586 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
587 AC_MSG_RESULT($dbus_have_iso_c_varargs)
588
589 AC_MSG_CHECKING(for GNUC varargs macros)
590 AC_TRY_COMPILE([],[
591 int a(int p1, int p2, int p3);
592 #define call_a(params...) a(1,params)
593 call_a(2,3);
594 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
595 AC_MSG_RESULT($dbus_have_gnuc_varargs)
596
597 dnl Output varargs tests
598 if test x$dbus_have_iso_c_varargs = xyes; then
599     AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
600 fi
601 if test x$dbus_have_gnuc_varargs = xyes; then
602     AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
603 fi
604
605 dnl Check for various credentials.
606 AC_MSG_CHECKING(for struct cmsgcred)
607 AC_TRY_COMPILE([
608 #include <sys/types.h>
609 #include <sys/socket.h>
610 ],[
611 struct cmsgcred cred;
612
613 cred.cmcred_pid = 0;
614 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
615 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
616
617 if test x$dbus_have_struct_cmsgcred = xyes; then
618     AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
619 fi
620
621 AC_CHECK_FUNCS(getpeerucred getpeereid)
622
623 #### Abstract sockets
624
625 if test x$enable_abstract_sockets = xauto; then
626 AC_LANG_PUSH(C)
627 warn_on_xcompile=no
628 AC_CACHE_CHECK([abstract socket namespace],
629                 ac_cv_have_abstract_sockets,
630                 [AC_RUN_IFELSE([AC_LANG_PROGRAM(
631 [[
632 #include <sys/types.h>
633 #include <stdlib.h>
634 #include <string.h>
635 #include <stdio.h>
636 #include <sys/socket.h>
637 #include <sys/un.h>
638 #include <errno.h>
639 ]],
640 [[
641   int listen_fd;
642   struct sockaddr_un addr;
643   
644   listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
645   
646   if (listen_fd < 0)
647     {
648       fprintf (stderr, "socket() failed: %s\n", strerror (errno));
649       exit (1);
650     }
651
652   memset (&addr, '\0', sizeof (addr));
653   addr.sun_family = AF_UNIX;
654   strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
655   addr.sun_path[0] = '\0'; /* this is what makes it abstract */
656   
657   if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
658     {
659        fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", 
660                 strerror (errno));
661        exit (1);
662     }
663   else 
664     exit (0);
665 ]])],
666               [ac_cv_have_abstract_sockets=yes],
667               [ac_cv_have_abstract_sockets=no],
668               [
669                 ac_cv_have_abstract_sockets=no
670                 warn_on_xcompile=yes
671               ]
672 )])
673 if test x$warn_on_xcompile = xyes ; then
674   AC_MSG_WARN([Cannot check for abstract sockets when cross-compiling, please use --enable-abstract-sockets])
675 fi
676 AC_LANG_POP(C)
677 fi
678
679 if test x$enable_abstract_sockets = xyes; then
680     if test x$ac_cv_have_abstract_sockets = xno; then
681         AC_MSG_ERROR([Abstract sockets explicitly required, and support not detected.])
682     fi
683 fi
684
685 if test x$enable_abstract_sockets = xno; then
686    ac_cv_have_abstract_sockets=no;
687 fi
688
689 if test x$ac_cv_have_abstract_sockets = xyes ; then
690    DBUS_PATH_OR_ABSTRACT=abstract
691    AC_DEFINE(HAVE_ABSTRACT_SOCKETS,1,[Have abstract socket namespace])
692 else
693    DBUS_PATH_OR_ABSTRACT=path
694 fi
695
696 # this is used in addresses to prefer abstract, e.g. 
697 # unix:path=/foo or unix:abstract=/foo 
698 AC_SUBST(DBUS_PATH_OR_ABSTRACT)
699
700 #### Sort out XML library
701
702 # see what we have
703 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
704              [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
705              have_expat=false)
706
707 # see what we want to use
708 dbus_use_libxml=false
709 dbus_use_expat=false
710 if test x$with_xml = xexpat; then
711         if ! $have_expat ; then
712            AC_MSG_ERROR([Explicitly requested expat but expat not found])
713         fi
714         dbus_use_expat=true
715 elif test x$with_xml = xlibxml; then
716         PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.6.0, have_libxml=true, have_libxml=false)
717         if ! $have_libxml ; then
718            AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
719         fi
720         dbus_use_libxml=true
721 else
722         ### expat is the default because libxml can't currently survive 
723         ### our brutal OOM-handling unit test setup.
724         ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
725         if test x$have_expat = xfalse; then
726                 AC_MSG_ERROR([Could not find expat.h, check config.log for failed attempts])
727         fi
728         ### By default, only use Expat since it's tested and known to work.  If you're a
729         ### general-purpose OS vendor, please don't enable libxml.  For embedded use
730         ### if your OS is built around libxml, that's another case.
731         dbus_use_expat=true
732 fi
733
734 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
735 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
736
737 if $dbus_use_expat; then
738    XML_LIBS=-lexpat
739    XML_CFLAGS=
740 fi
741 if $dbus_use_libxml; then
742    XML_LIBS=$LIBXML_LIBS
743    XML_CFLAGS=$LIBXML_CFLAGS
744 fi
745
746 # Thread lib detection
747 AC_CHECK_FUNC(pthread_cond_timedwait,[AC_CHECK_LIB(pthread,pthread_cond_timedwait,
748                                                     [THREAD_LIBS="-lpthread"])])
749 save_libs="$LIBS"
750 LIBS="$LIBS $THREAD_LIBS"
751 AC_CHECK_FUNC(pthread_condattr_setclock,have_pthread_condattr_setclock=true,have_pthread_condattr_setclock=false)
752 if test x$have_pthread_condattr_setclock = xtrue; then
753     AC_SEARCH_LIBS([clock_getres],[rt],[THREAD_LIBS="$THREAD_LIBS -lrt"])
754     AC_MSG_CHECKING([for CLOCK_MONOTONIC])
755     AC_TRY_COMPILE([#include <time.h>
756 #include <pthread.h>
757 ], [
758 struct timespec monotonic_timer;
759 pthread_condattr_t attr;
760 pthread_condattr_init (&attr);
761 pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
762 clock_getres (CLOCK_MONOTONIC,&monotonic_timer);
763 ], have_clock_monotonic=true, have_clock_monotonic=false)
764 if test x$have_clock_monotonic = xtrue; then
765     AC_MSG_RESULT([found])
766     AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, [Define if we have CLOCK_MONOTONIC])
767 else
768     AC_MSG_RESULT([not found])
769 fi
770 fi
771 LIBS="$save_libs"
772
773 # SELinux detection
774 if test x$enable_selinux = xno ; then
775     have_selinux=no;
776 else
777     # See if we have SELinux library
778     AC_CHECK_LIB(selinux, is_selinux_enabled, 
779                  have_selinux=yes, have_selinux=no)
780
781     # see if we have the SELinux header with the new D-Bus stuff in it
782     if test x$have_selinux = xyes ; then
783         AC_MSG_CHECKING([for DBUS Flask permissions in selinux/av_permissions.h])
784         AC_TRY_COMPILE([#include <selinux/av_permissions.h>],
785                         [#ifdef DBUS__ACQUIRE_SVC return 0;
786                          #else
787                          #error DBUS__ACQUIRE_SVC not defined
788                          #endif],
789                         have_selinux=yes, have_selinux=no)
790         AC_MSG_RESULT($have_selinux)
791     fi
792
793     if test x$enable_selinux = xauto ; then
794         if test x$have_selinux = xno ; then
795                 AC_MSG_WARN([Sufficiently new SELinux library not found])
796         fi
797     else 
798         if test x$have_selinux = xno ; then
799                 AC_MSG_ERROR([SElinux explicitly required, and SELinux library not found])
800         fi
801     fi
802 fi
803
804 AM_CONDITIONAL(HAVE_SELINUX, test x$have_selinux = xyes)
805
806 if test x$have_selinux = xyes ; then
807     # the selinux code creates threads
808     # which requires libpthread even on linux
809     AC_CHECK_FUNC(pthread_create,,[AC_CHECK_LIB(pthread,pthread_create,
810                                                 [SELINUX_THREAD_LIBS="-lpthread"])])
811
812     SELINUX_LIBS="-lselinux $SELINUX_THREAD_LIBS"
813     AC_DEFINE(HAVE_SELINUX,1,[SELinux support])
814 else
815     SELINUX_LIBS=
816 fi
817
818 # inotify checks
819 if test x$enable_inotify = xno ; then
820     have_inotify=no;
821 else
822     AC_CHECK_HEADERS(sys/inotify.h, have_inotify=yes, have_inotify=no)
823 fi
824
825 dnl check if inotify backend is enabled
826 if test x$have_inotify = xyes; then
827    AC_DEFINE(DBUS_BUS_ENABLE_INOTIFY,1,[Use inotify])
828    AC_CHECK_FUNCS(inotify_init1)
829 fi
830
831 AM_CONDITIONAL(DBUS_BUS_ENABLE_INOTIFY, test x$have_inotify = xyes)
832
833 # dnotify checks
834 if test x$enable_dnotify = xno ; then
835     have_dnotify=no;
836 else
837     if test x$have_inotify = xno -a x$host_os = xlinux-gnu -o x$host_os = xlinux; then
838         have_dnotify=yes;       
839     else
840         have_dnotify=no;
841     fi
842 fi
843
844 dnl check if dnotify backend is enabled
845 if test x$have_dnotify = xyes; then
846    AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux])
847 fi
848
849 AM_CONDITIONAL(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX, test x$have_dnotify = xyes)
850
851 # kqueue checks
852 if test x$enable_kqueue = xno ; then
853     have_kqueue=no
854 else
855     have_kqueue=yes
856     AC_CHECK_HEADER(sys/event.h, , have_kqueue=no)
857     AC_CHECK_FUNC(kqueue, , have_kqueue=no)
858
859     if test x$enable_kqueue = xyes -a x$have_kqueue = xno; then
860         AC_MSG_ERROR(kqueue support explicitly enabled but not available)
861     fi
862 fi
863
864 dnl check if kqueue backend is enabled
865 if test x$have_kqueue = xyes; then
866    AC_DEFINE(DBUS_BUS_ENABLE_KQUEUE,1,[Use kqueue])
867 fi
868
869 AM_CONDITIONAL(DBUS_BUS_ENABLE_KQUEUE, test x$have_kqueue = xyes) 
870
871 dnl console owner file
872 if test x$enable_console_owner_file = xno ; then
873     have_console_owner_file=no;
874 else
875     case $host_os in
876     solaris*)
877         have_console_owner_file=yes;
878         AC_DEFINE(HAVE_CONSOLE_OWNER_FILE,1,[Have console owner file])
879         ;;
880     *)
881         have_console_owner_file=no;;
882     esac
883 fi
884
885 AM_CONDITIONAL(HAVE_CONSOLE_OWNER_FILE, test x$have_console_owner_file = xyes)
886
887 # libaudit detection
888 if test x$enable_libaudit = xno ; then
889     have_libaudit=no;
890 else
891     # See if we have audit daemon & capabilities library
892     AC_CHECK_LIB(audit, audit_log_user_avc_message, 
893                  have_libaudit=yes, have_libaudit=no)
894     if test x$have_libaudit = xyes ; then
895         AC_CHECK_LIB(cap-ng, capng_clear,
896                  have_libaudit=yes, have_libaudit=no)
897     fi
898 fi
899
900 AM_CONDITIONAL(HAVE_LIBAUDIT, test x$have_libaudit = xyes)
901
902 if test x$have_libaudit = xyes ; then
903     SELINUX_LIBS="$SELINUX_LIBS -laudit -lcap-ng"
904     AC_DEFINE(HAVE_LIBAUDIT,1,[audit daemon SELinux support])
905 fi
906
907 # Check for ADT API
908 AC_MSG_CHECKING(for ADT API)
909 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
910 #include <bsm/adt.h>
911 adt_user_context = ADT_USER;
912 ]], [[]])], [ check_adt_audit=yes ], [ check_adt_audit=no ])
913
914 if test ${check_adt_audit} = yes
915 then
916    AC_DEFINE([HAVE_ADT], [], [Adt audit API])
917    ADT_LIBS="-lbsm"
918    LIBS="-lbsm $LIBS"
919    AC_MSG_RESULT(yes)
920 else
921    AC_MSG_RESULT(no)
922 fi
923
924
925 #### Set up final flags
926 DBUS_CLIENT_CFLAGS=
927 DBUS_CLIENT_LIBS="$THREAD_LIBS"
928 AC_SUBST(DBUS_CLIENT_CFLAGS)
929 AC_SUBST(DBUS_CLIENT_LIBS)
930
931 DBUS_BUS_CFLAGS="$XML_CFLAGS"
932 DBUS_BUS_LIBS="$XML_LIBS $SELINUX_LIBS $INTLLIBS $THREAD_LIBS $ADT_LIBS"
933 AC_SUBST(DBUS_BUS_CFLAGS)
934 AC_SUBST(DBUS_BUS_LIBS)
935
936 DBUS_LAUNCHER_CFLAGS="$XML_CFLAGS"
937 DBUS_LAUNCHER_LIBS="$XML_LIBS $THREAD_LIBS"
938 AC_SUBST(DBUS_LAUNCHER_CFLAGS)
939 AC_SUBST(DBUS_LAUNCHER_LIBS)
940
941 DBUS_TEST_CFLAGS=
942 DBUS_TEST_LIBS="$THREAD_LIBS"
943 AC_SUBST(DBUS_TEST_CFLAGS)
944 AC_SUBST(DBUS_TEST_LIBS)
945
946 ### X11 detection
947 AC_PATH_XTRA
948
949 ## for now enable_x11 just tracks have_x11, 
950 ## there's no --enable-x11
951 if test x$no_x = xyes ; then
952    have_x11=no
953    enable_x11=no
954 else
955    have_x11=yes
956    enable_x11=yes
957 fi
958
959 if test x$enable_x11 = xyes ; then
960    AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
961    DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
962    DBUS_X_CFLAGS="$X_CFLAGS"
963 else
964    DBUS_X_LIBS=
965    DBUS_X_CFLAGS=
966 fi
967
968 AC_SUBST(DBUS_X_CFLAGS)
969 AC_SUBST(DBUS_X_LIBS)
970
971
972 #### gcc warning flags
973
974 cc_supports_flag() {
975   AC_MSG_CHECKING(whether $CC supports "$@")
976   Cfile=/tmp/foo${$}
977   touch ${Cfile}.c
978   $CC -c "$@" ${Cfile}.c -o ${Cfile}.o >/dev/null 2>&1
979   rc=$?
980   rm -f ${Cfile}.c ${Cfile}.o
981   case $rc in
982     0) AC_MSG_RESULT(yes);;
983     *) AC_MSG_RESULT(no);;
984   esac
985   return $rc
986 }
987
988 ld_supports_flag() {
989   AC_MSG_CHECKING([whether $LD supports "$@"])
990   AC_TRY_LINK([
991     int one(void) { return 1; }
992     int two(void) { return 2; }
993   ], [ two(); ] , [_ac_ld_flag_supported=yes], [_ac_ld_flag_supported=no])
994
995   if test "$_ac_ld_flag_supported" = "yes"; then
996     rm -f conftest.c
997     touch conftest.c
998     if $CC -c conftest.c; then
999       ld_out=`$LD $@ -o conftest conftest.o 2>&1`
1000       ld_ret=$?
1001       if test $ld_ret -ne 0 ; then
1002         _ac_ld_flag_supported=no
1003       elif echo "$ld_out" | egrep 'option ignored|^usage:|unrecognized option|illegal option' >/dev/null ; then
1004         _ac_ld_flag_supported=no
1005       fi
1006     fi
1007     rm -f conftest.c conftest.o conftest
1008   fi
1009
1010   AC_MSG_RESULT($_ac_ld_flag_supported)
1011   if test "$_ac_ld_flag_supported" = "yes" ; then
1012     return 0
1013   else
1014     return 1
1015   fi
1016 }
1017
1018 if test x$USE_MAINTAINER_MODE = xyes; then
1019   if cc_supports_flag "-Werror"; then
1020     CFLAGS="$CFLAGS -Werror"
1021   fi
1022 fi
1023
1024 if test "x$GCC" = "xyes"; then
1025   changequote(,)dnl
1026   case " $CFLAGS " in
1027   *[\ \ ]-Wall[\ \      ]*) ;;
1028   *) CFLAGS="$CFLAGS -Wall" ;;
1029   esac
1030
1031   case " $CFLAGS " in
1032   *[\ \ ]-Wchar-subscripts[\ \  ]*) ;;
1033   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
1034   esac
1035
1036   case " $CFLAGS " in
1037   *[\ \ ]-Wmissing-declarations[\ \     ]*) ;;
1038   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
1039   esac
1040
1041   case " $CFLAGS " in
1042   *[\ \ ]-Wmissing-prototypes[\ \       ]*) ;;
1043   *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
1044   esac
1045
1046   case " $CFLAGS " in
1047   *[\ \ ]-Wnested-externs[\ \   ]*) ;;
1048   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
1049   esac
1050
1051   case " $CFLAGS " in
1052   *[\ \ ]-Wpointer-arith[\ \    ]*) ;;
1053   *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
1054   esac
1055
1056   case " $CFLAGS " in
1057   *[\ \ ]-Wcast-align[\ \       ]*) ;;
1058   *) CFLAGS="$CFLAGS -Wcast-align" ;;
1059   esac
1060
1061   case " $CFLAGS " in
1062   *[\ \ ]-Wfloat-equal[\ \      ]*) ;;
1063   *) if cc_supports_flag -Wfloat-equals; then
1064         CFLAGS="$CFLAGS -Wfloat-equal" 
1065      fi
1066      ;;
1067   esac
1068
1069   case " $CFLAGS " in
1070   *[\ \ ]-Wdeclaration-after-statement[\ \      ]*) ;;
1071   *) if cc_supports_flag -Wdeclaration-after-statement; then
1072         CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1073      fi
1074      ;;
1075   esac
1076
1077   case " $CFLAGS " in
1078   *[\ \ ]-fno-common[\ \        ]*) ;;
1079   *) if cc_supports_flag -fno-common; then
1080         CFLAGS="$CFLAGS -fno-common"
1081      fi
1082      ;;
1083   esac
1084
1085   case " $CFLAGS " in
1086   *[\ \ ]-fPIC[\ \      ]*) ;;
1087   *) if cc_supports_flag -fPIC; then
1088         PIC_CFLAGS="-fPIC"
1089         if ld_supports_flag -z,relro; then
1090            PIC_LDFLAGS="-Wl,-z,relro"
1091         fi
1092      fi
1093      ;;
1094   esac
1095
1096   case " $CFLAGS " in
1097   *[\ \ ]-fPIE[\ \      ]*) ;;
1098   *) if cc_supports_flag -fPIE; then
1099         PIE_CFLAGS="-fPIE"
1100         if ld_supports_flag -z,relro; then
1101            PIE_LDFLAGS="-pie -Wl,-z,relro"
1102         else
1103            PIE_LDFLAGS="-pie"
1104         fi
1105      fi
1106      ;;
1107   esac
1108   
1109   ### Disabled warnings, and compiler flag overrides
1110   
1111   # Let's just ignore unused for now
1112   case " $CFLAGS " in
1113   *[\ \ ]-Wno-unused[\ \        ]*) ;;
1114   *) CFLAGS="$CFLAGS -Wno-unused" ;;
1115   esac  
1116   
1117   # This group is for warnings we currently don't pass.
1118   # We would like to, however.  Please fix.
1119   
1120   # http://bugs.freedesktop.org/show_bug.cgi?id=17433
1121   case " $CFLAGS " in
1122   *[\ \ ]-Wno-sign-compare[\ \  ]*) ;;
1123   *) CFLAGS="$CFLAGS -Wno-sign-compare" ;;
1124   esac
1125   case " $CFLAGS " in
1126   *[\ \ ]-Wno-pointer-sign[\ \  ]*) ;;
1127   *) if cc_supports_flag -Wno-pointer-sign; then
1128         CFLAGS="$CFLAGS -Wno-pointer-sign"
1129      fi
1130      ;;
1131   esac
1132   
1133   # This one is special - it's not a warning override.
1134   # http://bugs.freedesktop.org/show_bug.cgi?id=10599
1135   case " $CFLAGS " in
1136   *[\ \ ]-fno-strict-aliasing[\ \       ]*) ;;
1137   *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
1138   esac
1139   ### End disabled warnings
1140
1141   if test "x$enable_ansi" = "xyes"; then
1142     case " $CFLAGS " in
1143     *[\ \       ]-ansi[\ \      ]*) ;;
1144     *) CFLAGS="$CFLAGS -ansi" ;;
1145     esac
1146
1147     case " $CFLAGS " in
1148     *[\ \       ]-D_POSIX_C_SOURCE*) ;;
1149     *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
1150     esac
1151
1152     case " $CFLAGS " in
1153     *[\ \       ]-D_BSD_SOURCE[\ \      ]*) ;;
1154     *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
1155     esac
1156
1157     case " $CFLAGS " in
1158     *[\ \       ]-pedantic[\ \  ]*) ;;
1159     *) CFLAGS="$CFLAGS -pedantic" ;;
1160     esac    
1161   fi
1162   if test x$enable_gcov = xyes; then
1163     case " $CFLAGS " in
1164     *[\ \       ]-fprofile-arcs[\ \     ]*) ;;
1165     *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
1166     esac
1167     case " $CFLAGS " in
1168     *[\ \       ]-ftest-coverage[\ \    ]*) ;;
1169     *) CFLAGS="$CFLAGS -ftest-coverage" ;;
1170     esac
1171
1172     ## remove optimization
1173     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
1174   fi
1175   changequote([,])dnl
1176 else
1177   if test x$enable_gcov = xyes; then
1178     AC_MSG_ERROR([--enable-gcov can only be used with gcc])
1179   fi
1180 fi
1181
1182 AC_SUBST(PIC_CFLAGS)
1183 AC_SUBST(PIC_LDFLAGS)  
1184 AC_SUBST(PIE_CFLAGS)
1185 AC_SUBST(PIE_LDFLAGS)  
1186
1187 if ld_supports_flag --gc-sections; then
1188   SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
1189   CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
1190 fi
1191 AC_SUBST(SECTION_FLAGS)
1192 AC_SUBST(SECTION_LDFLAGS)
1193 AC_MSG_RESULT($ac_gcsections)
1194
1195 changequote(,)dnl
1196 # compress spaces in flags
1197 CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`
1198 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ +/ /g'`
1199 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ +/ /g'`
1200 changequote([,])dnl
1201
1202 ### Doxygen Documentation
1203
1204 AC_PATH_PROG(DOXYGEN, doxygen, no)
1205
1206 AC_MSG_CHECKING([whether to build Doxygen documentation])
1207
1208 if test x$DOXYGEN = xno ; then
1209     have_doxygen=no
1210 else
1211     have_doxygen=yes
1212 fi
1213
1214 if test x$enable_doxygen_docs = xauto ; then
1215     if test x$have_doxygen = xno ; then
1216         enable_doxygen_docs=no
1217     else
1218         enable_doxygen_docs=yes
1219     fi
1220 fi
1221
1222 if test x$enable_doxygen_docs = xyes; then
1223     if test x$have_doxygen = xno; then
1224         AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
1225     fi
1226 fi
1227
1228 AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes)
1229 AC_MSG_RESULT(yes)
1230
1231 ### XML Documentation
1232
1233 AC_PATH_PROG(XMLTO, xmlto, no)
1234
1235 AC_MSG_CHECKING([whether to build XML documentation])
1236
1237 if test x$XMLTO = xno ; then
1238     have_xmlto=no
1239 else
1240     have_xmlto=yes
1241 fi
1242
1243 if test x$enable_xml_docs = xauto ; then
1244     if test x$have_xmlto = xno ; then
1245         enable_xml_docs=no
1246     else
1247         enable_xml_docs=yes
1248     fi
1249 fi
1250
1251 if test x$enable_xml_docs = xyes; then
1252     if test x$have_xmlto = xno; then
1253         AC_MSG_ERROR([Building XML docs explicitly required, but xmlto not found])
1254     fi
1255 fi
1256
1257 AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes)
1258 AC_MSG_RESULT(yes)
1259
1260 #### Have to go $localstatedir->$prefix/var->/usr/local/var
1261
1262 #### find the actual value for $prefix that we'll end up with
1263 ##   (I know this is broken and should be done in the Makefile, but
1264 ##    that's a major pain and almost nobody actually seems to care)
1265 AS_AC_EXPAND(EXPANDED_LOCALSTATEDIR, "$localstatedir")
1266 AS_AC_EXPAND(EXPANDED_SYSCONFDIR, "$sysconfdir")
1267 AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir")
1268 AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir")
1269 AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir")
1270 AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir")
1271
1272 #### Check our operating system
1273 operating_system=unknown
1274 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
1275    operating_system=redhat
1276 fi
1277
1278 if test -f /etc/slackware-version || test -f $EXPANDED_SYSCONFDIR/slackware-version ; then
1279    operating_system=slackware
1280 fi
1281
1282 #### Sort out init scripts
1283
1284 if test x$with_init_scripts = x; then
1285     if test xredhat = x$operating_system ; then
1286         with_init_scripts=redhat
1287     else
1288         if test xslackware = x$operating_system ; then
1289                 with_init_scripts=slackware
1290             else
1291                 with_init_scripts=none
1292         fi
1293     fi
1294 fi
1295
1296 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
1297
1298 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_SLACKWARE, test x$with_init_scripts = xslackware)
1299
1300 ##### Set up location for system bus socket
1301 if ! test -z "$with_system_socket"; then
1302    DBUS_SYSTEM_SOCKET=$with_system_socket
1303 else
1304    DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
1305 fi
1306
1307 AC_SUBST(DBUS_SYSTEM_SOCKET)
1308 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default])
1309
1310 ## system bus only listens on local domain sockets, and never 
1311 ## on an abstract socket (so only root can create the socket)
1312 DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
1313 AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
1314 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus])
1315
1316 #### Set up the pid file
1317 if ! test -z "$with_system_pid_file"; then
1318    DBUS_SYSTEM_PID_FILE=$with_system_pid_file
1319 elif test x$with_init_scripts = xredhat ; then
1320    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
1321 else
1322    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
1323 fi
1324
1325 AC_SUBST(DBUS_SYSTEM_PID_FILE)
1326
1327 #### Directory to check for console ownership
1328 if ! test -z "$with_console_auth_dir"; then
1329    DBUS_CONSOLE_AUTH_DIR=$with_console_auth_dir
1330 else
1331    DBUS_CONSOLE_AUTH_DIR=/var/run/console/
1332 fi
1333
1334 AC_SUBST(DBUS_CONSOLE_AUTH_DIR)
1335 AC_DEFINE_UNQUOTED(DBUS_CONSOLE_AUTH_DIR, "$DBUS_CONSOLE_AUTH_DIR", [Directory to check for console ownerhip])
1336
1337 #### File to check for console ownership
1338 if test x$have_console_owner_file = xyes; then
1339    if ! test -z "$with_console_owner_file"; then
1340       DBUS_CONSOLE_OWNER_FILE=$with_console_owner_file
1341    else
1342       DBUS_CONSOLE_OWNER_FILE=/dev/console
1343    fi
1344 else
1345   DBUS_CONSOLE_OWNER_FILE=
1346 fi
1347
1348 AC_SUBST(DBUS_CONSOLE_OWNER_FILE)
1349 AC_DEFINE_UNQUOTED(DBUS_CONSOLE_OWNER_FILE, "$DBUS_CONSOLE_OWNER_FILE", [File to check for console ownerhip])
1350
1351 #### User to start the system bus as
1352 if test -z "$with_dbus_user" ; then
1353     DBUS_USER=messagebus
1354 else
1355     DBUS_USER=$with_dbus_user
1356 fi
1357 AC_SUBST(DBUS_USER)
1358 AC_DEFINE_UNQUOTED(DBUS_USER,"$DBUS_USER", [User for running the system BUS daemon])
1359
1360 #### Direcotry to install data files into
1361 DBUS_DATADIR=$EXPANDED_DATADIR
1362 AC_SUBST(DBUS_DATADIR)
1363 AC_DEFINE_UNQUOTED(DBUS_DATADIR,"$DBUS_DATADIR", [Directory for installing DBUS data files])
1364
1365 #### Directory to install dbus-daemon
1366 if test -z "$with_dbus_daemondir" ; then
1367     DBUS_DAEMONDIR=$EXPANDED_BINDIR
1368 else
1369     DBUS_DAEMONDIR=$with_dbus_daemondir
1370 fi
1371 AC_SUBST(DBUS_DAEMONDIR)
1372 AC_DEFINE_UNQUOTED(DBUS_DAEMONDIR,"$DBUS_DAEMONDIR", [Directory for installing the DBUS daemon])
1373
1374 #### Directory to install the other binaries
1375 DBUS_BINDIR="$EXPANDED_BINDIR"
1376 AC_SUBST(DBUS_BINDIR)
1377 AC_DEFINE_UNQUOTED(DBUS_BINDIR,"$DBUS_BINDIR", [Directory for installing the binaries])
1378
1379 #### Directory to install the libexec binaries
1380 DBUS_LIBEXECDIR="$EXPANDED_LIBEXECDIR"
1381 AC_SUBST(DBUS_LIBEXECDIR)
1382 AC_DEFINE_UNQUOTED(DBUS_LIBEXECDIR,"$DBUS_LIBEXECDIR", [Directory for installing the libexec binaries])
1383
1384 #### Tell tests where to find certain stuff in builddir
1385
1386 DBUS_PWD=`pwd`
1387 AC_DEFUN([TEST_PATH], [
1388 TEST_$1=${DBUS_PWD}/test/$2
1389 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
1390                    [Full path to test file test/$2 in builddir])
1391 AC_SUBST(TEST_$1)
1392 ])
1393
1394 TEST_PATH(VALID_SERVICE_DIR, data/valid-service-files)
1395 TEST_PATH(INVALID_SERVICE_DIR, data/invalid-service-files)
1396 TEST_PATH(VALID_SERVICE_SYSTEM_DIR, data/valid-service-files-system)
1397 TEST_PATH(INVALID_SERVICE_SYSTEM_DIR, data/invalid-service-files-system)
1398 TEST_PATH(SERVICE_BINARY, test-service)
1399 TEST_PATH(SHELL_SERVICE_BINARY, test-shell-service)
1400 TEST_PATH(EXIT_BINARY, test-exit)
1401 TEST_PATH(SEGFAULT_BINARY, test-segfault)
1402 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
1403 TEST_PATH(PRIVSERVER_BINARY, name-test/test-privserver)
1404
1405 AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, "$DBUS_PWD/bus/dbus-daemon",
1406                    [Full path to the daemon in the builddir])
1407 AC_SUBST(TEST_BUS_BINARY)
1408
1409 ## Export the non-setuid external helper
1410 TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test"
1411 AC_SUBST(TEST_LAUNCH_HELPER_BINARY)
1412 AC_DEFINE_UNQUOTED(DBUS_TEST_LAUNCH_HELPER_BINARY, "$TEST_LAUNCH_HELPER_BINARY",
1413                    [Full path to the launch helper test program in the builddir])
1414
1415 #### Find socket directories
1416 if ! test -z "$TMPDIR" ; then
1417    DEFAULT_SOCKET_DIR=$TMPDIR
1418 elif ! test -z "$TEMP" ; then
1419    DEFAULT_SOCKET_DIR=$TEMP
1420 elif ! test -z "$TMP" ; then
1421    DEFAULT_SOCKET_DIR=$TMP
1422 else
1423    DEFAULT_SOCKET_DIR=/tmp
1424 fi
1425
1426 if ! test -z "$with_test_socket_dir" ; then
1427    TEST_SOCKET_DIR="$with_test_socket_dir"
1428 else
1429    TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1430 fi
1431 AC_SUBST(TEST_SOCKET_DIR)
1432 AC_DEFINE_UNQUOTED(DBUS_TEST_SOCKET_DIR, "$TEST_SOCKET_DIR", [Where to put test sockets])
1433
1434 if ! test -z "$with_session_socket_dir" ; then
1435    DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
1436 else
1437    DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1438 fi
1439 AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
1440 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
1441
1442 AC_DEFINE_UNQUOTED(DBUS_UNIX, "1", [Defined on UNIX and Linux systems and not on Windows])
1443
1444 # darwin needs this to initialize the environment
1445 AC_CHECK_HEADERS(crt_externs.h)
1446 AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])])
1447 AH_VERBATIM(_DARWIN_ENVIRON,
1448 [
1449 #if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H)
1450 # include <sys/time.h>
1451 # include <crt_externs.h>
1452 # define environ (*_NSGetEnviron())
1453 #endif
1454 ])
1455
1456 AC_OUTPUT([
1457 Doxyfile
1458 dbus/dbus-arch-deps.h
1459 bus/system.conf
1460 bus/session.conf
1461 bus/messagebus
1462 bus/rc.messagebus
1463 bus/dbus-daemon.1
1464 Makefile
1465 dbus/Makefile
1466 bus/Makefile
1467 tools/Makefile
1468 test/Makefile
1469 test/name-test/Makefile
1470 doc/Makefile
1471 dbus-1.pc
1472 test/data/valid-config-files/debug-allow-all.conf
1473 test/data/valid-config-files/debug-allow-all-sha1.conf
1474 test/data/valid-config-files-system/debug-allow-all-pass.conf
1475 test/data/valid-config-files-system/debug-allow-all-fail.conf
1476 test/data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service
1477 test/data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service
1478 test/data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service
1479 test/data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service
1480 test/data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service
1481 test/data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service
1482 test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service
1483 test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service
1484 test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service
1485 test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service
1486 test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service
1487 test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service
1488 test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service
1489 ])
1490
1491 dnl ==========================================================================
1492 echo "
1493                     D-Bus $VERSION
1494                   ==============
1495
1496         prefix:                   ${prefix}
1497         exec_prefix:              ${exec_prefix}
1498         libdir:                   ${EXPANDED_LIBDIR}
1499         libexecdir:               ${EXPANDED_LIBEXECDIR}
1500         bindir:                   ${EXPANDED_BINDIR}
1501         sysconfdir:               ${EXPANDED_SYSCONFDIR}
1502         localstatedir:            ${EXPANDED_LOCALSTATEDIR}
1503         datadir:                  ${EXPANDED_DATADIR}
1504         source code location:     ${srcdir}
1505         compiler:                 ${CC}
1506         cflags:                   ${CFLAGS}
1507         cppflags:                 ${CPPFLAGS}
1508         cxxflags:                 ${CXXFLAGS}
1509         64-bit int:               ${DBUS_INT64_TYPE}
1510         32-bit int:               ${DBUS_INT32_TYPE}
1511         16-bit int:               ${DBUS_INT16_TYPE}
1512         Doxygen:                  ${DOXYGEN}
1513         xmlto:                    ${XMLTO}"
1514
1515 echo "
1516         Maintainer mode:          ${USE_MAINTAINER_MODE}
1517         gcc coverage profiling:   ${enable_gcov}
1518         Building unit tests:      ${enable_tests}
1519         Building verbose mode:    ${enable_verbose_mode}
1520         Building assertions:      ${enable_asserts}
1521         Building checks:          ${enable_checks}
1522         Building SELinux support: ${have_selinux}
1523         Building inotify support: ${have_inotify}
1524         Building dnotify support: ${have_dnotify}
1525         Building kqueue support:  ${have_kqueue}
1526         Building X11 code:        ${enable_x11}
1527         Building Doxygen docs:    ${enable_doxygen_docs}
1528         Building XML docs:        ${enable_xml_docs}
1529         Building cache support:   ${enable_userdb_cache}
1530         Gettext libs (empty OK):  ${INTLLIBS}
1531         Using XML parser:         ${with_xml}
1532         Init scripts style:       ${with_init_scripts}
1533         Abstract socket names:    ${ac_cv_have_abstract_sockets}
1534         System bus socket:        ${DBUS_SYSTEM_SOCKET}
1535         System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
1536         System bus PID file:      ${DBUS_SYSTEM_PID_FILE}
1537         Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}
1538         Console auth dir:         ${DBUS_CONSOLE_AUTH_DIR}
1539         Console owner file:       ${have_console_owner_file}
1540         Console owner file path:  ${DBUS_CONSOLE_OWNER_FILE}
1541         System bus user:          ${DBUS_USER}
1542         Session bus services dir: ${EXPANDED_DATADIR}/dbus-1/services
1543         'make check' socket dir:  ${TEST_SOCKET_DIR}
1544 "
1545
1546 if test x$enable_tests = xyes; then
1547         echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
1548 fi
1549 if test x$enable_tests = xyes -a x$enable_asserts = xno; then
1550         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)"
1551 fi
1552 if test x$enable_gcov = xyes; then
1553         echo "NOTE: building with coverage profiling is definitely for developers only."
1554 fi
1555 if test x$enable_verbose_mode = xyes; then
1556         echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
1557 fi
1558 if test x$enable_asserts = xyes; then
1559         echo "NOTE: building with assertions increases library size and decreases performance."
1560 fi
1561 if test x$enable_checks = xno; then
1562         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."
1563 fi
1564 if test x$dbus_use_libxml = xtrue; then
1565         echo
1566         echo "WARNING: You have chosen to use libxml as your xml parser however this code path is not maintained by the D-Bus developers and if it breaks you get to keep the pieces.  If you have selected this option in err please reconfigure with expat (e.g. --with-xml=expat)."
1567 fi