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