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