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