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