03ee65542408e39e266d46470566e3a543c16433
[platform/upstream/dbus.git] / configure.in
1 dnl -*- mode: m4 -*-
2 AC_PREREQ(2.52)
3
4 AC_INIT(dbus/dbus.h)
5
6 AM_INIT_AUTOMAKE(dbus, 0.51)
7
8 AM_CONFIG_HEADER(config.h)
9
10 AC_CANONICAL_TARGET
11
12 # Honor aclocal flags
13 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
14
15 GETTEXT_PACKAGE=dbus-1
16 AC_SUBST(GETTEXT_PACKAGE)
17 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
18
19  ## must come before we use the $USE_MAINTAINER_MODE variable later
20 AM_MAINTAINER_MODE
21
22 # libtool versioning - this applies to libdbus
23 #
24 # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
25 #
26
27 ## increment if the interface has additions, changes, removals.
28 LT_CURRENT=1
29
30 ## increment any time the source changes; set to
31 ##  0 if you increment CURRENT
32 LT_REVISION=0
33
34 ## increment if any interfaces have been added; set to 0
35 ## if any interfaces have been changed or removed. removal has
36 ## precedence over adding, so set to 0 if both happened.
37 LT_AGE=0
38
39 AC_SUBST(LT_CURRENT)
40 AC_SUBST(LT_REVISION)
41 AC_SUBST(LT_AGE)
42
43
44 AC_PROG_CC
45 AC_PROG_CXX
46 AC_ISC_POSIX
47 AC_HEADER_STDC
48
49 AC_ARG_ENABLE(qt,               [  --enable-qt           enable Qt-friendly client library],enable_qt=$enableval,enable_qt=auto)
50 AC_ARG_ENABLE(glib,             [  --enable-glib         enable GLib-friendly client library],enable_glib=$enableval,enable_glib=auto)
51 AC_ARG_ENABLE(gtk,              [  --enable-gtk          enable GTK-requiring executables],enable_gtk=$enableval,enable_gtk=auto)
52 AC_ARG_ENABLE(tests,            [  --enable-tests        enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
53 AC_ARG_ENABLE(ansi,             [  --enable-ansi         enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
54 AC_ARG_ENABLE(verbose-mode,     [  --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
55 AC_ARG_ENABLE(asserts,          [  --enable-asserts      include assertion checks],enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
56 AC_ARG_ENABLE(checks,           [  --enable-checks       include sanity checks on public API],enable_checks=$enableval,enable_checks=yes)
57 AC_ARG_ENABLE(xml-docs,         [  --enable-xml-docs     build XML documentation (requires xmlto)],enable_xml_docs=$enableval,enable_xml_docs=auto)
58 AC_ARG_ENABLE(doxygen-docs,     [  --enable-doxygen-docs     build DOXYGEN documentation (requires Doxygen)],enable_doxygen_docs=$enableval,enable_doxygen_docs=auto)
59 AC_ARG_ENABLE(gcov,             [  --enable-gcov         compile with coverage profiling instrumentation (gcc only)],enable_gcov=$enableval,enable_gcov=no)
60 AC_ARG_ENABLE(abstract-sockets, [  --enable-abstract-sockets  use abstract socket namespace (linux only)],enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
61 AC_ARG_ENABLE(gcj,              [  --enable-gcj          build gcj bindings],enable_gcj=$enableval,enable_gcj=no)
62 AC_ARG_ENABLE(mono,             [  --enable-mono         build mono bindings],enable_mono=$enableval,enable_mono=auto)
63 AC_ARG_ENABLE(mono_docs,        [  --enable-mono-docs    build mono docs],enable_mono_docs=$enableval,enable_mono_docs=auto)
64 AC_ARG_ENABLE(python,           [  --enable-python       build python bindings],enable_python=$enableval,enable_python=auto)
65 AC_ARG_ENABLE(selinux,          [  --enable-selinux      build with SELinux support],enable_selinux=$enableval,enable_selinux=auto)
66
67 AC_ARG_WITH(xml,                [  --with-xml=[libxml/expat]           XML library to use])
68 AC_ARG_WITH(init-scripts,       [  --with-init-scripts=[redhat]        Style of init scripts to install])
69 AC_ARG_WITH(session-socket-dir, [  --with-session-socket-dir=[dirname] Where to put sockets for the per-login-session message bus])
70 AC_ARG_WITH(test-socket-dir,    [  --with-test-socket-dir=[dirname]    Where to put sockets for make check])
71 AC_ARG_WITH(system-pid-file,    [  --with-system-pid-file=[pidfile]    PID file for systemwide daemon])
72 AC_ARG_WITH(system-socket,      [  --with-system-socket=[filename]     UNIX domain socket for systemwide daemon])
73 AC_ARG_WITH(console-auth-dir,   [  --with-console-auth-dir=[dirname]   directory to check for console ownerhip])
74 AC_ARG_WITH(dbus_user,          [  --with-dbus-user=<user>  User for running the DBUS daemon (messagebus)])
75
76 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files 
77 dnl and also some stuff in the test/ subdir
78 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
79 if test x$enable_tests = xyes; then
80     AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
81 fi
82
83 if test x$enable_verbose_mode = xyes; then
84     AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
85 fi
86 if test x$enable_asserts = xno; then
87     AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
88     AC_DEFINE(G_DISABLE_ASSERT,1,[Disable GLib assertion macros])
89 fi
90 if test x$enable_checks = xno; then
91     AC_DEFINE(DBUS_DISABLE_CHECKS,1,[Disable public API sanity checking])
92     AC_DEFINE(G_DISABLE_CHECKS,1,[Disable GLib public API sanity checking])
93 fi
94
95 #### gcc warning flags
96
97 if test "x$GCC" = "xyes"; then
98   changequote(,)dnl
99   case " $CFLAGS " in
100   *[\ \ ]-Wall[\ \      ]*) ;;
101   *) CFLAGS="$CFLAGS -Wall" ;;
102   esac
103
104   case " $CFLAGS " in
105   *[\ \ ]-Wchar-subscripts[\ \  ]*) ;;
106   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
107   esac
108
109   case " $CFLAGS " in
110   *[\ \ ]-Wmissing-declarations[\ \     ]*) ;;
111   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
112   esac
113
114   case " $CFLAGS " in
115   *[\ \ ]-Wmissing-prototypes[\ \       ]*) ;;
116   *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
117   esac
118
119   case " $CFLAGS " in
120   *[\ \ ]-Wnested-externs[\ \   ]*) ;;
121   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
122   esac
123
124   case " $CFLAGS " in
125   *[\ \ ]-Wpointer-arith[\ \    ]*) ;;
126   *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
127   esac
128
129   case " $CFLAGS " in
130   *[\ \ ]-Wcast-align[\ \       ]*) ;;
131   *) CFLAGS="$CFLAGS -Wcast-align" ;;
132   esac
133
134   case " $CFLAGS " in
135   *[\ \ ]-Wfloat-equal[\ \      ]*) ;;
136   *) CFLAGS="$CFLAGS -Wfloat-equal" ;;
137   esac
138
139   case " $CFLAGS " in
140   *[\ \ ]-Wsign-compare[\ \     ]*) ;;
141   *) CFLAGS="$CFLAGS -Wsign-compare" ;;
142   esac
143
144   if test "x$enable_ansi" = "xyes"; then
145     case " $CFLAGS " in
146     *[\ \       ]-ansi[\ \      ]*) ;;
147     *) CFLAGS="$CFLAGS -ansi" ;;
148     esac
149
150     case " $CFLAGS " in
151     *[\ \       ]-D_POSIX_C_SOURCE*) ;;
152     *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
153     esac
154
155     case " $CFLAGS " in
156     *[\ \       ]-D_BSD_SOURCE[\ \      ]*) ;;
157     *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
158     esac
159
160     case " $CFLAGS " in
161     *[\ \       ]-pedantic[\ \  ]*) ;;
162     *) CFLAGS="$CFLAGS -pedantic" ;;
163     esac
164   fi
165   if test x$enable_gcov = xyes; then
166     case " $CFLAGS " in
167     *[\ \       ]-fprofile-arcs[\ \     ]*) ;;
168     *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
169     esac
170     case " $CFLAGS " in
171     *[\ \       ]-ftest-coverage[\ \    ]*) ;;
172     *) CFLAGS="$CFLAGS -ftest-coverage" ;;
173     esac
174
175     ## remove optimization
176     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
177   fi
178   changequote([,])dnl
179 else
180   if test x$enable_gcov = xyes; then
181     AC_MSG_ERROR([--enable-gcov can only be used with gcc])
182   fi
183 fi
184
185 #### can't use AM_PROG_GCJ since it fails fatally if no gcj found
186 AC_CHECK_PROGS(GCJ, gcj, gcj)
187 if test -z "$GCJ" ; then
188      have_gcj=no
189 else
190      # Needs to be here so libtool wont get confused
191      AM_PROG_GCJ
192
193      have_gcj=yes
194      if test "x${GCJFLAGS-unset}" = xunset; then
195         GCJFLAGS="-g -O2 -Wall"
196      fi
197      AC_SUBST(GCJFLAGS)
198 fi
199
200 if test x$enable_gcj = xauto ; then
201     if test x$have_gcj = xno ; then
202         enable_gcj=no
203     else
204         enable_gcj=yes
205     fi
206 fi
207
208 if test x$enable_gcj = xyes; then
209     if test x$have_gcj = xno ; then
210         AC_MSG_ERROR([Building gcj explicitly required, but gcj not found])
211     fi
212 fi
213
214 AM_CONDITIONAL(DBUS_USE_GCJ, test x$enable_gcj = xyes)
215
216 AM_PROG_LIBTOOL
217
218 #### Look for mono
219 MONO_REQUIRED_VERSION=0.95
220 AC_SUBST(MONO_REQUIRED_VERSION)
221 PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, have_mono=true, have_mono=false)
222
223 if test "x$enable_mono" = "xyes"; then
224         if test "x$have_mono" = "xfalse"; then
225                 AC_MSG_ERROR([Mono was not found])
226         fi
227 fi
228
229 if test "x$have_mono" = "xtrue"; then
230         if test `uname -s` = "Darwin"; then
231                 AC_PATH_PROG(RUNTIME, mint, no)
232                 AC_PATH_PROG(CSC, mcs, no)
233                 LIB_PREFIX=
234                 LIB_SUFFIX=.dylib
235         else
236                 AC_PATH_PROG(RUNTIME, mono, no)
237                 AC_PATH_PROG(CSC, mcs, no)
238                 LIB_PREFIX=.so
239                 LIB_SUFFIX=
240         fi
241 else
242         AC_PATH_PROG(CSC, csc.exe, no)
243         RUNTIME=
244         LIB_PREFIX=
245         LIB_SUFFIX=.dylib
246 fi
247
248 if test x$enable_mono = xyes; then
249     if test x$have_mcs = xno ; then
250         AC_MSG_ERROR([Building Mono bindings explicitly required, but mcs compiler not found])
251     fi
252
253     ### Test for GACUTIL
254     AC_PATH_PROG(GACUTIL, gacutil, no)
255     if test "x$GACUTIL" = "xno" ; then
256         AC_MSG_ERROR([No gacutil tool found])
257     fi
258
259     AC_SUBST(GACUTIL)
260 fi
261
262 if test x$enable_mono = xauto ; then
263     if test x$CSC = xno ; then
264         enable_mono=no
265     else
266         ### Test for GACUTIL
267         AC_PATH_PROG(GACUTIL, gacutil, no)
268         if test "x$GACUTIL" = "xno" ; then
269            enable_mono=no
270         else
271            enable_mono=yes
272         fi
273     fi
274 fi
275
276 AC_SUBST(RUNTIME)
277 AC_SUBST(CSC)
278 AC_SUBST(GACUTIL)
279 AC_SUBST(LIB_PREFIX)
280 AC_SUBST(LIB_SUFFIX)
281
282 AM_CONDITIONAL(DBUS_USE_CSC, test x$enable_mono = xyes)
283
284 #### Look for monodoc
285 MONODOC_REQUIRED_VERSION=0.16
286 AC_SUBST(MONODOC_REQUIRED_VERSION)
287 PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, have_monodoc=yes, have_monodoc=no)
288
289 if test x$enable_mono_docs = xyes; then
290     if test x$have_monodoc = xno ; then
291         AC_MSG_ERROR([Building Mono docs explicitly required, but monodoc not found])
292     else
293         AC_PATH_PROG(MONODOC, monodoc, no)
294         if test x$MONODOC = xno; then
295            AC_MSG_ERROR([Building Mono docs explicitly required, but monodoc not found])        
296         fi
297     fi
298 fi
299
300 if test x$enable_mono_docs = xauto ; then
301     if test x$have_monodoc = xno ; then
302         enable_mono_docs=no
303         MONODOC=
304     else
305         AC_PATH_PROG(MONODOC, monodoc, no)
306         if test x$MONODOC = xno; then
307            enable_mono_docs=no
308            MONODOC=
309         else
310            enable_mono_docs=yes
311         fi
312     fi
313 fi
314
315 AC_SUBST(MONODOC)
316
317 AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_mono_docs" = "xyes")
318
319 changequote(,)dnl
320 # let ourselves use our own unstable API
321 CPPFLAGS="-DDBUS_API_SUBJECT_TO_CHANGE=1 $CPPFLAGS"
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 AC_C_BIGENDIAN
447
448
449 dnl **********************************
450 dnl *** va_copy checks (from GLib) ***
451 dnl **********************************
452 dnl we currently check for all three va_copy possibilities, so we get
453 dnl all results in config.log for bug reports.
454 AC_CACHE_CHECK([for an implementation of va_copy()],dbus_cv_va_copy,[
455         AC_LINK_IFELSE([#include <stdarg.h>
456         void f (int i, ...) {
457         va_list args1, args2;
458         va_start (args1, i);
459         va_copy (args2, args1);
460         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
461           exit (1);
462         va_end (args1); va_end (args2);
463         }
464         int main() {
465           f (0, 42);
466           return 0;
467         }],
468         [dbus_cv_va_copy=yes],
469         [dbus_cv_va_copy=no])
470 ])
471 AC_CACHE_CHECK([for an implementation of __va_copy()],dbus_cv___va_copy,[
472         AC_LINK_IFELSE([#include <stdarg.h>
473         void f (int i, ...) {
474         va_list args1, args2;
475         va_start (args1, i);
476         __va_copy (args2, args1);
477         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
478           exit (1);
479         va_end (args1); va_end (args2);
480         }
481         int main() {
482           f (0, 42);
483           return 0;
484         }],
485         [dbus_cv___va_copy=yes],
486         [dbus_cv___va_copy=no])
487 ])
488
489 if test "x$dbus_cv_va_copy" = "xyes"; then
490   dbus_va_copy_func=va_copy
491 else if test "x$dbus_cv___va_copy" = "xyes"; then
492   dbus_va_copy_func=__va_copy
493 fi
494 fi
495
496 if test -n "$dbus_va_copy_func"; then
497   AC_DEFINE_UNQUOTED(DBUS_VA_COPY,$dbus_va_copy_func,[A 'va_copy' style function])
498 fi
499
500 AC_CACHE_CHECK([whether va_lists can be copied by value],dbus_cv_va_val_copy,[
501         AC_TRY_RUN([#include <stdarg.h>
502         void f (int i, ...) {
503         va_list args1, args2;
504         va_start (args1, i);
505         args2 = args1;
506         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
507           exit (1);
508         va_end (args1); va_end (args2);
509         }
510         int main() {
511           f (0, 42);
512           return 0;
513         }],
514         [dbus_cv_va_val_copy=yes],
515         [dbus_cv_va_val_copy=no],
516         [dbus_cv_va_val_copy=yes])
517 ])
518
519 if test "x$dbus_cv_va_val_copy" = "xno"; then
520   AC_DEFINE(DBUS_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
521 fi
522
523
524 #### Atomic integers (checks by Sebastian Wilhelmi for GLib)
525 AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers])
526 have_atomic_inc=no
527 if test x"$GCC" = xyes; then
528   if test "x$enable_ansi" = "xyes"; then
529     AC_MSG_RESULT([no])
530   else
531     case $host_cpu in
532       i386)
533         AC_MSG_RESULT([no])
534         ;;
535       i?86)
536         AC_MSG_RESULT([i486])
537         AC_DEFINE_UNQUOTED(DBUS_USE_ATOMIC_INT_486, 1, [Use atomic integer implementation for 486])
538         have_atomic_inc=yes
539         ;;
540       *)
541         AC_MSG_RESULT([no])
542         ;;
543     esac
544   fi
545 fi
546 if test x$have_atomic_inc = xyes ; then
547   AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT, 1, [Some atomic integer implementation present])
548 fi
549
550 #### Various functions
551 AC_CHECK_LIB(socket,socket)
552 AC_CHECK_LIB(nsl,gethostbyname)
553
554 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist)
555
556 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
557
558 AC_CACHE_CHECK([for posix getpwnam_r],
559                 ac_cv_func_posix_getpwnam_r,
560                 [AC_TRY_RUN([
561 #include <errno.h>
562 #include <pwd.h>
563 int main () { 
564     char buffer[10000];
565     struct passwd pwd, *pwptr = &pwd;
566     int error;
567     errno = 0;
568     error = getpwnam_r ("", &pwd, buffer, 
569                         sizeof (buffer), &pwptr);
570    return (error < 0 && errno == ENOSYS) 
571            || error == ENOSYS; 
572 }               ],
573         [ac_cv_func_posix_getpwnam_r=yes],
574         [ac_cv_func_posix_getpwnam_r=no])])
575 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
576         AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
577                 [Have POSIX function getpwnam_r])
578 else
579         AC_CACHE_CHECK([for nonposix getpwnam_r],
580                 ac_cv_func_nonposix_getpwnam_r,
581                 [AC_TRY_LINK([#include <pwd.h>],
582                         [char buffer[10000];
583                         struct passwd pwd;
584                         getpwnam_r ("", &pwd, buffer, 
585                                         sizeof (buffer));],
586                         [ac_cv_func_nonposix_getpwnam_r=yes],
587                         [ac_cv_func_nonposix_getpwnam_r=no])])
588                 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
589                 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
590                         [Have non-POSIX function getpwnam_r])
591         fi
592 fi
593
594 dnl check for socklen_t
595 AC_MSG_CHECKING(whether socklen_t is defined)
596 AC_TRY_COMPILE([
597 #include <sys/types.h>
598 #include <sys/socket.h>
599 #include <netdb.h>
600 ],[
601 socklen_t foo;
602 foo = 1;
603 ],dbus_have_socklen_t=yes,dbus_have_socklen_t=no)
604 AC_MSG_RESULT($dbus_have_socklen_t)
605
606 if test "x$dbus_have_socklen_t" = "xyes"; then
607     AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type])
608 fi
609
610 dnl check for writev header and writev function so we're 
611 dnl good to go if HAVE_WRITEV gets defined.
612 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
613
614 dnl check for flavours of varargs macros (test from GLib)
615 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
616 AC_TRY_COMPILE([],[
617 int a(int p1, int p2, int p3);
618 #define call_a(...) a(1,__VA_ARGS__)
619 call_a(2,3);
620 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
621 AC_MSG_RESULT($dbus_have_iso_c_varargs)
622
623 AC_MSG_CHECKING(for GNUC varargs macros)
624 AC_TRY_COMPILE([],[
625 int a(int p1, int p2, int p3);
626 #define call_a(params...) a(1,params)
627 call_a(2,3);
628 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
629 AC_MSG_RESULT($dbus_have_gnuc_varargs)
630
631 dnl Output varargs tests
632 if test x$dbus_have_iso_c_varargs = xyes; then
633     AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
634 fi
635 if test x$dbus_have_gnuc_varargs = xyes; then
636     AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
637 fi
638
639 dnl Check for various credentials.
640 AC_MSG_CHECKING(for struct cmsgcred)
641 AC_TRY_COMPILE([
642 #include <sys/types.h>
643 #include <sys/socket.h>
644 ],[
645 struct cmsgcred cred;
646
647 cred.cmcred_pid = 0;
648 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
649 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
650
651 if test x$dbus_have_struct_cmsgcred = xyes; then
652     AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
653 fi
654
655
656 #### Abstract sockets
657
658 AC_MSG_CHECKING(abstract socket namespace)
659 AC_LANG_PUSH(C)
660 AC_RUN_IFELSE([AC_LANG_PROGRAM(
661 [[
662 #include <sys/types.h>
663 #include <stdlib.h>
664 #include <string.h>
665 #include <stdio.h>
666 #include <sys/socket.h>
667 #include <sys/un.h>
668 #include <errno.h>
669 ]],
670 [[
671   int listen_fd;
672   struct sockaddr_un addr;
673   
674   listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
675   
676   if (listen_fd < 0)
677     {
678       fprintf (stderr, "socket() failed: %s\n", strerror (errno));
679       exit (1);
680     }
681
682   memset (&addr, '\0', sizeof (addr));
683   addr.sun_family = AF_UNIX;
684   strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
685   addr.sun_path[0] = '\0'; /* this is what makes it abstract */
686   
687   if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
688     {
689        fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", 
690                 strerror (errno));
691        exit (1);
692     }
693   else 
694     exit (0);
695 ]])],
696               [have_abstract_sockets=yes],
697               [have_abstract_sockets=no])
698 AC_LANG_POP(C)
699 AC_MSG_RESULT($have_abstract_sockets)
700
701 if test x$enable_abstract_sockets = xyes; then
702     if test x$have_abstract_sockets = xno; then
703         AC_MSG_ERROR([Abstract sockets explicitly required, and support not detected.])
704     fi
705 fi
706
707 if test x$enable_abstract_sockets = xno; then
708    have_abstract_sockets=no;
709 fi
710
711 if test x$have_abstract_sockets = xyes ; then
712    DBUS_PATH_OR_ABSTRACT=abstract
713    AC_DEFINE(HAVE_ABSTRACT_SOCKETS,1,[Have abstract socket namespace])
714 else
715    DBUS_PATH_OR_ABSTRACT=path
716 fi
717
718 # this is used in addresses to prefer abstract, e.g. 
719 # unix:path=/foo or unix:abstract=/foo 
720 AC_SUBST(DBUS_PATH_OR_ABSTRACT)
721
722 #### Sort out gettext
723
724 # this makes us require GLib to run autoconf, but not at runtime
725 ALL_LINGUAS=""
726 AM_GLIB_GNU_GETTEXT
727
728 # INTLLIBS is now set
729
730 # (if someone wants to go through and make internationalization 
731 #  conditional with #ifdef ENABLE_NLS then go crazy and send us a patch, 
732 #  but right now we won't build without gettext)
733 if test "$gt_cv_have_gettext" != "yes" ; then
734   AC_MSG_ERROR([
735 *** You must have either have gettext support in your C library, or use the 
736 *** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
737 ])
738 fi
739
740 #### Sort out XML library
741
742 # see what we have
743 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
744              [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
745              have_expat=false)
746
747 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
748
749 # see what we want to use
750 dbus_use_libxml=false
751 dbus_use_expat=false
752 if test x$with_xml = xexpat; then
753         dbus_use_expat=true
754         if ! $have_expat ; then
755            AC_MSG_ERROR([Explicitly requested expat but expat not found])
756         fi
757 elif test x$with_xml = xlibxml; then
758         dbus_use_libxml=true
759         if ! $have_libxml ; then
760            AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
761         fi
762 else
763         ### expat is the default because libxml can't currently survive 
764         ### our brutal OOM-handling unit test setup.
765         ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
766         if $have_expat ; then
767                 with_xml=expat
768                 dbus_use_expat=true
769         elif $have_libxml ; then
770                 with_xml=libxml
771                 dbus_use_libxml=true
772         else
773                 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
774         fi
775 fi
776
777 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
778 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
779
780 if $dbus_use_expat; then
781    XML_LIBS=-lexpat
782    XML_CFLAGS=
783 fi
784 if $dbus_use_libxml; then
785    XML_LIBS=$LIBXML_LIBS
786    XML_CFLAGS=$LIBXML_CFLAGS
787 fi
788
789 # SELinux detection
790 if test x$enable_selinux = xno ; then
791     have_selinux=no;
792 else
793     # See if we have SELinux library
794     AC_CHECK_LIB(selinux, is_selinux_enabled, 
795                  have_selinux=yes, have_selinux=no)
796
797     # see if we have the SELinux header with the new D-BUS stuff in it
798     if test x$have_selinux = xyes ; then
799         AC_MSG_CHECKING([for DBUS Flask permissions in selinux/av_permissions.h])
800         AC_TRY_COMPILE([#include <selinux/av_permissions.h>],
801                         [#ifdef DBUS__ACQUIRE_SVC return 0;
802                          #else
803                          #error DBUS__ACQUIRE_SVC not defined
804                          #endif],
805                         have_selinux=yes, have_selinux=no)
806         AC_MSG_RESULT($have_selinux)
807     fi
808
809     if test x$enable_selinux = xauto ; then
810         if test x$have_selinux = xno ; then
811                 AC_MSG_WARN([Sufficiently new SELinux library not found])
812         fi
813     else 
814         if test x$have_selinux = xno ; then
815                 AC_MSG_ERROR([SElinux explicitly required, and SELinux library not found])
816         fi
817     fi
818 fi
819
820 AM_CONDITIONAL(HAVE_SELINUX, test x$have_selinux = xyes)
821
822 if test x$have_selinux = xyes ; then
823     SELINUX_LIBS="-lselinux -lpthread"
824     AC_DEFINE(HAVE_SELINUX,1,[SELinux support])
825 else
826     SELINUX_LIBS=
827 fi
828
829 # dnotify checks
830 if test x$target_os = xlinux-gnu; then
831         AC_ARG_ENABLE(dnotify,
832         [  --disable-dnotify         Disable using dnotify on Linux],
833         [case "${enableval}" in
834           yes) dnotify=false ;;
835           no)  dnotify=true ;;
836           *) AC_MSG_ERROR(bad value ${enableval} for --disable-dnotify) ;;
837         esac],[dnotify=true])
838 fi
839 dnl check if dnotify backend is enabled
840 if test x$dnotify = xtrue; then
841    AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux])
842 fi
843
844
845 #### Set up final flags
846 DBUS_CLIENT_CFLAGS=
847 DBUS_CLIENT_LIBS=
848 AC_SUBST(DBUS_CLIENT_CFLAGS)
849 AC_SUBST(DBUS_CLIENT_LIBS)
850
851 DBUS_BUS_CFLAGS=$XML_CFLAGS
852 DBUS_BUS_LIBS="$XML_LIBS $SELINUX_LIBS $INTLLIBS"
853 AC_SUBST(DBUS_BUS_CFLAGS)
854 AC_SUBST(DBUS_BUS_LIBS)
855
856 DBUS_TEST_CFLAGS=
857 DBUS_TEST_LIBS=
858 AC_SUBST(DBUS_TEST_CFLAGS)
859 AC_SUBST(DBUS_TEST_LIBS)
860
861 # Glib detection
862 PKG_CHECK_MODULES(DBUS_GLIB, gobject-2.0 >= 2.4, have_glib=yes, have_glib=no)
863 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, gthread-2.0 >= 2.4, have_glib_threads=yes, have_glib_threads=no)
864
865 if test x$have_glib = xno ; then
866     AC_MSG_WARN([GLib development libraries not found])
867 fi
868
869 if test x$enable_glib = xyes; then
870     if test x$have_glib = xno; then
871         AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
872     fi
873 fi
874
875 if test x$enable_glib = xno; then
876    have_glib=no;
877 fi
878
879 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
880 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
881
882 if test x$have_glib = xyes; then
883    GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
884 else
885    GLIB_GENMARSHAL=glib-not-enabled-so-there-is-no-genmarshal
886 fi
887 AC_SUBST(GLIB_GENMARSHAL)
888
889 dnl GLib flags
890 AC_SUBST(DBUS_GLIB_CFLAGS)
891 AC_SUBST(DBUS_GLIB_LIBS)
892 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
893
894 DBUS_GLIB_TOOL_CFLAGS=$XML_CFLAGS
895 DBUS_GLIB_TOOL_LIBS="$XML_LIBS $INTLLIBS"
896 AC_SUBST(DBUS_GLIB_TOOL_CFLAGS)
897 AC_SUBST(DBUS_GLIB_TOOL_LIBS)
898
899 # GTK detection
900 if test x$have_glib = xno ; then
901     AC_MSG_WARN([Can't use GTK+ since GLib not enabled])
902     have_gtk=no
903 else
904     PKG_CHECK_MODULES(DBUS_GTK, gtk+-2.0 >= 2.4, have_gtk=yes, have_gtk=no)
905     PKG_CHECK_MODULES(DBUS_GTK_THREADS, gtk+-2.0 >= 2.4 gthread-2.0, have_gtk_threads=yes, have_gtk_threads=no)
906 fi
907
908 if test x$have_gtk = xno ; then
909     AC_MSG_WARN([GTK+ development libraries not found])
910 fi
911
912 if test x$enable_gtk = xyes; then
913     if test x$have_gtk = xno; then
914         AC_MSG_ERROR([GTK+ explicitly required, and GTK+ development libraries not found])
915     fi
916 fi
917
918 if test x$enable_gtk = xno; then
919    have_gtk=no;
920 fi
921
922 AM_CONDITIONAL(HAVE_GTK, test x$have_gtk = xyes)
923
924 dnl Gtk flags
925 AC_SUBST(DBUS_GTK_CFLAGS)
926 AC_SUBST(DBUS_GTK_LIBS)
927 AC_SUBST(DBUS_GTK_THREADS_CFLAGS)
928 AC_SUBST(DBUS_GTK_THREADS_LIBS)
929
930
931 dnl Qt detection
932 PKG_CHECK_MODULES(DBUS_QT, QtCore >= 4.0, have_qt=yes, have_qt=no)
933
934 if test x$have_qt = xno ; then
935     AC_MSG_WARN([Qt development libraries not found])
936 fi
937
938 if test x$enable_qt = xyes; then
939     if test x$have_qt = xno; then
940         AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
941     fi
942 fi
943
944 if test x$enable_qt = xno; then
945    have_qt=no;
946 fi
947
948 QT_MOC=`$PKG_CONFIG --variable=exec_prefix QtCore`
949 QT_MOC=${QT_MOC}/bin/moc
950
951 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
952
953 dnl Qt flags
954 AC_SUBST(DBUS_QT_CFLAGS)
955 AC_SUBST(DBUS_QT_LIBS)
956 AC_SUBST(QT_MOC)
957
958 dnl QTestLib detection
959 PKG_CHECK_MODULES(DBUS_QTESTLIB, QtTest, have_qtest=yes, have_qtest=no)
960
961 if test x$have_qtest = xno ; then
962     AC_MSG_WARN([Qt Unit Test library not found])
963 fi
964
965 if test x$have_qt = xno; then
966     have_qtest=no
967 fi
968
969 AM_CONDITIONAL(HAVE_QTESTLIB, test x$have_qtest = xyes)
970
971 AC_SUBST(DBUS_QTESTLIB_CFLAGS)
972 AC_SUBST(DBUS_QTESTLIB_LIBS)
973
974 ### X11 detection
975 AC_PATH_XTRA
976
977 ## for now enable_x11 just tracks have_x11, 
978 ## there's no --enable-x11
979 if test x$no_x = xyes ; then
980    have_x11=no
981    enable_x11=no
982 else
983    have_x11=yes
984    enable_x11=yes
985 fi
986
987 if test x$enable_x11 = xyes ; then
988    AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
989    DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
990    DBUS_X_CFLAGS="$X_CFLAGS"
991 else
992    DBUS_X_LIBS=
993    DBUS_X_CFLAGS=
994 fi
995
996 AC_SUBST(DBUS_X_CFLAGS)
997 AC_SUBST(DBUS_X_LIBS)
998
999 ### Doxygen Documentation
1000
1001 AC_PATH_PROG(DOXYGEN, doxygen, no)
1002
1003 AC_MSG_CHECKING([whether to build Doxygen documentation])
1004
1005 if test x$DOXYGEN = xno ; then
1006     have_doxygen=no
1007 else
1008     have_doxygen=yes
1009 fi
1010
1011 if test x$enable_doxygen_docs = xauto ; then
1012     if test x$have_doxygen = xno ; then
1013         enable_doxygen_docs=no
1014     else
1015         enable_doxygen_docs=yes
1016     fi
1017 fi
1018
1019 if test x$enable_doxygen_docs = xyes; then
1020     if test x$have_doxygen = xno; then
1021         AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
1022     fi
1023 fi
1024
1025 AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes)
1026 AC_MSG_RESULT(yes)
1027
1028 ### XML Documentation
1029
1030 AC_PATH_PROG(XMLTO, xmlto, no)
1031
1032 AC_MSG_CHECKING([whether to build XML documentation])
1033
1034 if test x$XMLTO = xno ; then
1035     have_xmlto=no
1036 else
1037     have_xmlto=yes
1038 fi
1039
1040 if test x$enable_xml_docs = xauto ; then
1041     if test x$have_xmlto = xno ; then
1042         enable_xml_docs=no
1043     else
1044         enable_xml_docs=yes
1045     fi
1046 fi
1047
1048 if test x$enable_xml_docs = xyes; then
1049     if test x$have_xmlto = xno; then
1050         AC_MSG_ERROR([Building XML docs explicitly required, but xmlto not found])
1051     fi
1052 fi
1053
1054 AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes)
1055 AC_MSG_RESULT(yes)
1056
1057 #### Have to go $localstatedir->$prefix/var->/usr/local/var   
1058 #### someone please fix this a better way...
1059
1060 #### find the actual value for $prefix that we'll end up with
1061 ##   (I know this is broken and should be done in the Makefile, but
1062 ##    that's a major pain and almost nobody actually seems to care)
1063 REAL_PREFIX=
1064 if test "x$prefix" = "xNONE"; then
1065   REAL_PREFIX=$ac_default_prefix
1066 else
1067   REAL_PREFIX=$prefix
1068 fi
1069
1070 ## temporarily change prefix and exec_prefix
1071 old_prefix=$prefix
1072 prefix=$REAL_PREFIX
1073
1074 if test "x$exec_prefix" = xNONE ; then
1075    REAL_EXEC_PREFIX=$REAL_PREFIX
1076 else
1077    REAL_EXEC_PREFIX=$exec_prefix
1078 fi
1079 old_exec_prefix=$exec_prefix
1080 exec_prefix=$REAL_EXEC_PREFIX
1081
1082 ## eval everything
1083 LOCALSTATEDIR_TMP="$localstatedir"
1084 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
1085 AC_SUBST(EXPANDED_LOCALSTATEDIR)
1086
1087 SYSCONFDIR_TMP="$sysconfdir"
1088 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
1089 AC_SUBST(EXPANDED_SYSCONFDIR)
1090
1091 BINDIR_TMP="$bindir"
1092 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
1093 AC_SUBST(EXPANDED_BINDIR)
1094
1095 LIBDIR_TMP="$libdir"
1096 EXPANDED_LIBDIR=`eval echo $LIBDIR_TMP`
1097 AC_SUBST(EXPANDED_LIBDIR)
1098
1099 DATADIR_TMP="$datadir"
1100 EXPANDED_DATADIR=`eval echo $DATADIR_TMP`
1101 AC_SUBST(EXPANDED_DATADIR)
1102
1103 ## put prefix and exec_prefix back
1104 prefix=$old_prefix
1105 exec_prefix=$old_exec_prefix
1106
1107 #### Check our operating system
1108 operating_system=unknown
1109 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
1110    operating_system=redhat
1111 fi
1112
1113 if test -f /etc/slackware-version || test -f $EXPANDED_SYSCONFDIR/slackware-version ; then
1114    operating_system=slackware
1115 fi
1116
1117 #### Sort out init scripts
1118
1119 if test x$with_init_scripts = x; then
1120     if test xredhat = x$operating_system ; then
1121         with_init_scripts=redhat
1122     else
1123         if test xslackware = x$operating_system ; then
1124                 with_init_scripts=slackware
1125             else
1126                 with_init_scripts=none
1127         fi
1128     fi
1129 fi
1130
1131 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
1132
1133 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_SLACKWARE, test x$with_init_scripts = xslackware)
1134
1135 ##### Set up location for system bus socket
1136 if ! test -z "$with_system_socket"; then
1137    DBUS_SYSTEM_SOCKET=$with_system_socket
1138 else
1139    DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
1140 fi
1141
1142 AC_SUBST(DBUS_SYSTEM_SOCKET)
1143 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default])
1144
1145 ## system bus only listens on local domain sockets, and never 
1146 ## on an abstract socket (so only root can create the socket)
1147 DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
1148 AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
1149 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-BUS address of the system bus])
1150
1151 #### Set up the pid file
1152 if ! test -z "$with_system_pid_file"; then
1153    DBUS_SYSTEM_PID_FILE=$with_system_pid_file
1154 elif test x$operating_system = xredhat ; then
1155    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
1156 else
1157    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
1158 fi
1159
1160 AC_SUBST(DBUS_SYSTEM_PID_FILE)
1161
1162 #### Directory to check for console ownership
1163 if ! test -z "$with_console_auth_dir"; then
1164    DBUS_CONSOLE_AUTH_DIR=$with_console_auth_dir
1165 else
1166    DBUS_CONSOLE_AUTH_DIR=/var/run/console/
1167 fi
1168
1169 AC_SUBST(DBUS_CONSOLE_AUTH_DIR)
1170 AC_DEFINE_UNQUOTED(DBUS_CONSOLE_AUTH_DIR, "$DBUS_CONSOLE_AUTH_DIR", [Directory to check for console ownerhip])
1171
1172 #### User to start the system bus as
1173 if test -z "$with_dbus_user" ; then
1174     DBUS_USER=messagebus
1175 else
1176     DBUS_USER=$with_dbus_user
1177 fi
1178 AC_SUBST(DBUS_USER)
1179 AC_DEFINE_UNQUOTED(DBUS_USER,"$DBUS_USER", [User for running the system BUS daemon])
1180
1181 #### Tell tests where to find certain stuff in builddir
1182 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
1183
1184 AC_DEFUN(TEST_PATH, [
1185 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
1186 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
1187                    [Full path to test file test/$2 in builddir])
1188 AC_SUBST(TEST_$1)
1189 ])
1190
1191 TEST_PATH(SERVICE_DIR, data/valid-service-files)
1192 TEST_PATH(SERVICE_BINARY, test-service)
1193 TEST_PATH(SHELL_SERVICE_BINARY, test-shell-service)
1194 TEST_PATH(GLIB_SERVICE_BINARY, glib/test-service-glib)
1195 TEST_PATH(PYTHON_SERVICE_BINARY, python/test-service.py)
1196 TEST_PATH(EXIT_BINARY, test-exit)
1197 TEST_PATH(SEGFAULT_BINARY, test-segfault)
1198 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
1199 AC_SUBST(ABSOLUTE_TOP_BUILDDIR)
1200
1201 #### Find socket directories
1202 if ! test -z "$TMPDIR" ; then
1203    DEFAULT_SOCKET_DIR=$TMPDIR
1204 elif ! test -z "$TEMP" ; then
1205    DEFAULT_SOCKET_DIR=$TEMP
1206 elif ! test -z "$TMP" ; then
1207    DEFAULT_SOCKET_DIR=$TMP
1208 else
1209    DEFAULT_SOCKET_DIR=/tmp
1210 fi
1211
1212 if ! test -z "$with_test_socket_dir" ; then
1213    TEST_SOCKET_DIR="$with_test_socket_dir"
1214 else
1215    TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1216 fi
1217 AC_SUBST(TEST_SOCKET_DIR)
1218 AC_DEFINE_UNQUOTED(DBUS_TEST_SOCKET_DIR, "$TEST_SOCKET_DIR", [Where to put test sockets])
1219
1220 if ! test -z "$with_session_socket_dir" ; then
1221    DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
1222 else
1223    DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1224 fi
1225 AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
1226 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
1227
1228 # Detect if we can build Python bindings (need python, python headers, and pyrex)
1229 if test x$enable_python = xno; then
1230     have_python=no
1231 else
1232     have_python_version=2.4
1233     AC_MSG_NOTICE([Checking to see if we can build Python bindings])
1234     have_python=no
1235     AM_PATH_PYTHON()
1236
1237     if test -z "$PYTHON" ; then
1238         AC_MSG_WARN([Python not found])
1239     else
1240         AC_MSG_CHECKING([whether $PYTHON version >= $have_python_version])
1241         AM_PYTHON_CHECK_VERSION([$PYTHON], [$have_python_version],
1242                               [have_python_version="yes"],
1243                               [have_python_version="too old"])
1244     
1245         AC_MSG_RESULT($have_python_version)
1246     
1247         AC_CHECK_PROGS(PYREX, pyrexc)
1248
1249         if test -z "$PYREX" ; then
1250             have_pyrex=no
1251         else
1252             have_pyrex=yes
1253         fi
1254
1255         AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
1256
1257         if test x$have_pyrex = xyes -a x$have_python_headers = xyes -a "x$have_python_version" = xyes ; then
1258             have_python=yes
1259         fi
1260     fi
1261
1262     if test x$have_python = xno ; then
1263         if test x$enable_python = xyes ; then
1264             AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings because either Pyrex, Python headers or a suitable Python version was not found])
1265         else
1266             AC_MSG_WARN([Couldn't find either Pyrex, the Python headers or a suitable version of Python, not building Python bindings])
1267         fi
1268     fi               
1269 fi
1270
1271 AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
1272
1273 AC_OUTPUT([
1274 Doxyfile
1275 dbus/dbus-arch-deps.h
1276 bus/system.conf
1277 bus/session.conf
1278 bus/messagebus
1279 bus/rc.messagebus
1280 bus/dbus-daemon.1
1281 Makefile
1282 dbus/Makefile
1283 glib/Makefile
1284 glib/examples/Makefile
1285 glib/examples/statemachine/Makefile
1286 python/Makefile
1287 python/examples/Makefile
1288 qt/Makefile
1289 gcj/Makefile
1290 gcj/org/Makefile
1291 gcj/org/freedesktop/Makefile
1292 gcj/org/freedesktop/dbus/Makefile
1293 mono/Makefile
1294 mono/AssemblyInfo.cs
1295 mono/dbus-sharp.dll.config
1296 mono/example/Makefile
1297 mono/doc/Makefile
1298 bus/Makefile
1299 tools/Makefile
1300 test/Makefile
1301 test/glib/Makefile
1302 test/python/Makefile
1303 test/qt/Makefile
1304 doc/Makefile
1305 dbus-1.pc
1306 dbus-glib-1.pc
1307 dbus-sharp.pc
1308 test/data/valid-config-files/debug-allow-all.conf
1309 test/data/valid-config-files/debug-allow-all-sha1.conf
1310 test/data/valid-service-files/debug-echo.service
1311 test/data/valid-service-files/debug-segfault.service
1312 test/data/valid-service-files/debug-glib.service
1313 test/data/valid-service-files/debug-shell-echo-success.service
1314 test/data/valid-service-files/debug-shell-echo-fail.service
1315 test/data/valid-service-files/debug-python.service
1316 ])
1317
1318 ### FIXME it's bizarre that have_qt and have_glib are used
1319 ### instead of enable_ - should fix things so that enable 
1320 ### is always whether it's enabled, and have is always whether 
1321 ### it was found.
1322
1323 dnl ==========================================================================
1324 echo "
1325                     D-BUS $VERSION
1326                   ==============
1327
1328         prefix:                   ${prefix}
1329         exec_prefix:              ${exec_prefix}
1330         libdir:                   ${EXPANDED_LIBDIR}
1331         bindir:                   ${EXPANDED_BINDIR}
1332         sysconfdir:               ${EXPANDED_SYSCONFDIR}
1333         localstatedir:            ${EXPANDED_LOCALSTATEDIR}
1334         datadir:              ${EXPANDED_DATADIR}
1335         source code location:     ${srcdir}
1336         compiler:                 ${CC}
1337         cflags:                   ${CFLAGS}
1338         cppflags:                 ${CPPFLAGS}
1339         cxxflags:                 ${CXXFLAGS}
1340         64-bit int:               ${DBUS_INT64_TYPE}
1341         32-bit int:               ${DBUS_INT32_TYPE}
1342         16-bit int:               ${DBUS_INT16_TYPE}
1343         Doxygen:                  ${DOXYGEN}
1344         xmlto:                    ${XMLTO}"
1345
1346 if test x$enable_gcj = xyes ; then
1347 echo \
1348 "        gcj:                     ${GCJ}
1349         gcjflags:                 ${GCJFLAGS}"
1350 else
1351 echo \
1352 "        gcj:                      (not enabled)"
1353 fi
1354
1355 if test x$enable_mono = xyes ; then
1356 echo \
1357 "        csc:                     ${CSC}
1358 "
1359 else
1360 echo \
1361 "        csc:                      (not enabled)
1362 "
1363 fi
1364
1365 echo "
1366         Maintainer mode:          ${USE_MAINTAINER_MODE}
1367         gcc coverage profiling:   ${enable_gcov}
1368         Building unit tests:      ${enable_tests}
1369         Building verbose mode:    ${enable_verbose_mode}
1370         Building assertions:      ${enable_asserts}
1371         Building checks:          ${enable_checks}
1372         Building Qt bindings:     ${have_qt}
1373         Building GLib bindings:   ${have_glib}
1374         Building Python bindings: ${have_python}
1375         Building SELinux support: ${have_selinux}
1376         Building Mono bindings:   ${enable_mono}
1377         Building Mono docs:       ${enable_mono_docs}
1378         Building GTK+ tools:      ${have_gtk}
1379         Building X11 code:        ${enable_x11}
1380         Building Doxygen docs:    ${enable_doxygen_docs}
1381         Building XML docs:        ${enable_xml_docs}
1382         Gettext libs (empty OK):  ${INTLLIBS}
1383         Using XML parser:         ${with_xml}
1384         Init scripts style:       ${with_init_scripts}
1385         Abstract socket names:    ${have_abstract_sockets}
1386         System bus socket:        ${DBUS_SYSTEM_SOCKET}
1387         System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
1388         System bus PID file:      ${DBUS_SYSTEM_PID_FILE}
1389         Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}
1390         Console auth dir:         ${DBUS_CONSOLE_AUTH_DIR}
1391         System bus user:          ${DBUS_USER}
1392         'make check' socket dir:  ${TEST_SOCKET_DIR}
1393 "
1394
1395 if test x$enable_tests = xyes; then
1396         echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
1397 fi
1398 if test x$enable_tests = xyes -a x$enable_asserts = xno; then
1399         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)"
1400 fi
1401 if test x$enable_gcov = xyes; then
1402         echo "NOTE: building with coverage profiling is definitely for developers only."
1403 fi
1404 if test x$enable_verbose_mode = xyes; then
1405         echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
1406 fi
1407 if test x$enable_asserts = xyes; then
1408         echo "NOTE: building with assertions increases library size and decreases performance."
1409 fi
1410 if test x$enable_checks = xno; then
1411         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."
1412 fi