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