* Makefile.am:
[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_GUI=QtGui$qt_suffix
1003 QT_TESTLIB=QtTest$qt_suffix
1004 min_qt_version=4.1.3
1005
1006 AC_SUBST(QT_CORE)
1007 AC_SUBST(QT_XML)
1008
1009 PKG_CHECK_MODULES([DBUS_QT], 
1010                   [$QT_CORE >= $min_qt_version $QT_XML >= $min_qt_version], 
1011                   have_qt=yes, 
1012                   have_qt=no)
1013
1014 dnl Check for moc too
1015 if test x$have_qt = xyes ; then
1016     AC_MSG_CHECKING([for moc])
1017
1018     if test -z "$with_qt_moc" ; then
1019         QT_MOC=`$PKG_CONFIG --variable=exec_prefix $QT_CORE`
1020         QT_MOC=${QT_MOC}/bin/moc
1021     else
1022         QT_MOC=$with_qt_moc
1023     fi
1024
1025     if test -x "$QT_MOC"; then
1026         AC_MSG_RESULT([found, $QT_MOC])
1027     else
1028         AC_MSG_RESULT([not found])
1029         AC_MSG_WARN([moc not found; disabling Qt])
1030         have_qt=no
1031     fi
1032 fi
1033
1034 if test x$have_qt = xno ; then
1035     if test x$enable_qt = xyes; then
1036             AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
1037     fi
1038     have_qt=no
1039 else
1040     dnl Qt4 flags
1041     AC_SUBST(DBUS_QT_CFLAGS)
1042     AC_SUBST(DBUS_QT_LIBS)
1043     AC_SUBST(QT_MOC)
1044
1045     dnl QTestLib detection
1046     PKG_CHECK_MODULES([DBUS_QTESTLIB], 
1047                       [$QT_TESTLIB >= 4.1.0], 
1048                       have_qtest=yes, 
1049                       have_qtest=no)
1050
1051     if test x$have_qtest = xno ; then
1052         AC_MSG_WARN([Qt Unit Test library not found])
1053     fi
1054
1055     if test x$have_qt = xno; then
1056         have_qtest=no
1057     fi
1058
1059     AC_SUBST(DBUS_QTESTLIB_CFLAGS)
1060     AC_SUBST(DBUS_QTESTLIB_LIBS)
1061
1062     dnl QtGui detection
1063     PKG_CHECK_MODULES([DBUS_QT_GUI], [$QT_GUI >= $min_qt_version],
1064                       have_qt_gui=yes,
1065                       have_qt_gui=no)
1066
1067     if test x$have_qt_gui = xyes ; then
1068         AC_MSG_CHECKING([for uic])
1069         QT_UIC=`$PKG_CONFIG --variable=exec_prefix $QT_GUI`/bin/uic
1070
1071         if test -x "$QT_UIC" ; then
1072             AC_MSG_RESULT([found, $QT_UIC])
1073         else
1074             AC_MSG_RESULT([not found, disabling Qt Gui])
1075             have_qt_gui=no
1076         fi
1077     fi
1078
1079     AC_SUBST(DBUS_QT_GUI_CFLAGS)
1080     AC_SUBST(DBUS_QT_GUI_LIBS)
1081     AC_SUBST(QT_UIC)
1082 fi
1083
1084 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
1085 AM_CONDITIONAL(HAVE_QT_GUI, test x$have_qt_gui = xyes)
1086 AM_CONDITIONAL(HAVE_QTESTLIB, test x$have_qtest = xyes)
1087
1088 ### X11 detection
1089 AC_PATH_XTRA
1090
1091 ## for now enable_x11 just tracks have_x11, 
1092 ## there's no --enable-x11
1093 if test x$no_x = xyes ; then
1094    have_x11=no
1095    enable_x11=no
1096 else
1097    have_x11=yes
1098    enable_x11=yes
1099 fi
1100
1101 if test x$enable_x11 = xyes ; then
1102    AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
1103    DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
1104    DBUS_X_CFLAGS="$X_CFLAGS"
1105 else
1106    DBUS_X_LIBS=
1107    DBUS_X_CFLAGS=
1108 fi
1109
1110 AC_SUBST(DBUS_X_CFLAGS)
1111 AC_SUBST(DBUS_X_LIBS)
1112
1113 ### Doxygen Documentation
1114
1115 AC_PATH_PROG(DOXYGEN, doxygen, no)
1116
1117 AC_MSG_CHECKING([whether to build Doxygen documentation])
1118
1119 if test x$DOXYGEN = xno ; then
1120     have_doxygen=no
1121 else
1122     have_doxygen=yes
1123 fi
1124
1125 if test x$enable_doxygen_docs = xauto ; then
1126     if test x$have_doxygen = xno ; then
1127         enable_doxygen_docs=no
1128     else
1129         enable_doxygen_docs=yes
1130     fi
1131 fi
1132
1133 if test x$enable_doxygen_docs = xyes; then
1134     if test x$have_doxygen = xno; then
1135         AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
1136     fi
1137 fi
1138
1139 AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes)
1140 AC_MSG_RESULT(yes)
1141
1142 ### XML Documentation
1143
1144 AC_PATH_PROG(XMLTO, xmlto, no)
1145
1146 AC_MSG_CHECKING([whether to build XML documentation])
1147
1148 if test x$XMLTO = xno ; then
1149     have_xmlto=no
1150 else
1151     have_xmlto=yes
1152 fi
1153
1154 if test x$enable_xml_docs = xauto ; then
1155     if test x$have_xmlto = xno ; then
1156         enable_xml_docs=no
1157     else
1158         enable_xml_docs=yes
1159     fi
1160 fi
1161
1162 if test x$enable_xml_docs = xyes; then
1163     if test x$have_xmlto = xno; then
1164         AC_MSG_ERROR([Building XML docs explicitly required, but xmlto not found])
1165     fi
1166 fi
1167
1168 AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes)
1169 AC_MSG_RESULT(yes)
1170
1171 #### Have to go $localstatedir->$prefix/var->/usr/local/var   
1172 #### someone please fix this a better way...
1173
1174 #### find the actual value for $prefix that we'll end up with
1175 ##   (I know this is broken and should be done in the Makefile, but
1176 ##    that's a major pain and almost nobody actually seems to care)
1177 REAL_PREFIX=
1178 if test "x$prefix" = "xNONE"; then
1179   REAL_PREFIX=$ac_default_prefix
1180 else
1181   REAL_PREFIX=$prefix
1182 fi
1183
1184 ## temporarily change prefix and exec_prefix
1185 old_prefix=$prefix
1186 prefix=$REAL_PREFIX
1187
1188 if test "x$exec_prefix" = xNONE ; then
1189    REAL_EXEC_PREFIX=$REAL_PREFIX
1190 else
1191    REAL_EXEC_PREFIX=$exec_prefix
1192 fi
1193 old_exec_prefix=$exec_prefix
1194 exec_prefix=$REAL_EXEC_PREFIX
1195
1196 ## eval everything
1197 LOCALSTATEDIR_TMP="$localstatedir"
1198 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
1199 AC_SUBST(EXPANDED_LOCALSTATEDIR)
1200
1201 SYSCONFDIR_TMP="$sysconfdir"
1202 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
1203 AC_SUBST(EXPANDED_SYSCONFDIR)
1204
1205 BINDIR_TMP="$bindir"
1206 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
1207 AC_SUBST(EXPANDED_BINDIR)
1208
1209 LIBDIR_TMP="$libdir"
1210 EXPANDED_LIBDIR=`eval echo $LIBDIR_TMP`
1211 AC_SUBST(EXPANDED_LIBDIR)
1212
1213 DATADIR_TMP="$datadir"
1214 EXPANDED_DATADIR=`eval echo $DATADIR_TMP`
1215 AC_SUBST(EXPANDED_DATADIR)
1216
1217 ## put prefix and exec_prefix back
1218 prefix=$old_prefix
1219 exec_prefix=$old_exec_prefix
1220
1221 #### Check our operating system
1222 operating_system=unknown
1223 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
1224    operating_system=redhat
1225 fi
1226
1227 if test -f /etc/slackware-version || test -f $EXPANDED_SYSCONFDIR/slackware-version ; then
1228    operating_system=slackware
1229 fi
1230
1231 #### Sort out init scripts
1232
1233 if test x$with_init_scripts = x; then
1234     if test xredhat = x$operating_system ; then
1235         with_init_scripts=redhat
1236     else
1237         if test xslackware = x$operating_system ; then
1238                 with_init_scripts=slackware
1239             else
1240                 with_init_scripts=none
1241         fi
1242     fi
1243 fi
1244
1245 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
1246
1247 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_SLACKWARE, test x$with_init_scripts = xslackware)
1248
1249 ##### Set up location for system bus socket
1250 if ! test -z "$with_system_socket"; then
1251    DBUS_SYSTEM_SOCKET=$with_system_socket
1252 else
1253    DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
1254 fi
1255
1256 AC_SUBST(DBUS_SYSTEM_SOCKET)
1257 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default])
1258
1259 ## system bus only listens on local domain sockets, and never 
1260 ## on an abstract socket (so only root can create the socket)
1261 DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
1262 AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
1263 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-BUS address of the system bus])
1264
1265 #### Set up the pid file
1266 if ! test -z "$with_system_pid_file"; then
1267    DBUS_SYSTEM_PID_FILE=$with_system_pid_file
1268 elif test x$operating_system = xredhat ; then
1269    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
1270 else
1271    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
1272 fi
1273
1274 AC_SUBST(DBUS_SYSTEM_PID_FILE)
1275
1276 #### Directory to check for console ownership
1277 if ! test -z "$with_console_auth_dir"; then
1278    DBUS_CONSOLE_AUTH_DIR=$with_console_auth_dir
1279 else
1280    DBUS_CONSOLE_AUTH_DIR=/var/run/console/
1281 fi
1282
1283 AC_SUBST(DBUS_CONSOLE_AUTH_DIR)
1284 AC_DEFINE_UNQUOTED(DBUS_CONSOLE_AUTH_DIR, "$DBUS_CONSOLE_AUTH_DIR", [Directory to check for console ownerhip])
1285
1286 #### User to start the system bus as
1287 if test -z "$with_dbus_user" ; then
1288     DBUS_USER=messagebus
1289 else
1290     DBUS_USER=$with_dbus_user
1291 fi
1292 AC_SUBST(DBUS_USER)
1293 AC_DEFINE_UNQUOTED(DBUS_USER,"$DBUS_USER", [User for running the system BUS daemon])
1294
1295 #### Tell tests where to find certain stuff in builddir
1296 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
1297
1298 AC_DEFUN([TEST_PATH], [
1299 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
1300 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
1301                    [Full path to test file test/$2 in builddir])
1302 AC_SUBST(TEST_$1)
1303 ])
1304
1305 TEST_PATH(SERVICE_DIR, data/valid-service-files)
1306 TEST_PATH(SERVICE_BINARY, test-service)
1307 TEST_PATH(SHELL_SERVICE_BINARY, test-shell-service)
1308 TEST_PATH(GLIB_SERVICE_BINARY, glib/test-service-glib)
1309 TEST_PATH(PYTHON_SERVICE_BINARY, python/test-service.py)
1310 TEST_PATH(EXIT_BINARY, test-exit)
1311 TEST_PATH(SEGFAULT_BINARY, test-segfault)
1312 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
1313 AC_SUBST(ABSOLUTE_TOP_BUILDDIR)
1314
1315 #### Find socket directories
1316 if ! test -z "$TMPDIR" ; then
1317    DEFAULT_SOCKET_DIR=$TMPDIR
1318 elif ! test -z "$TEMP" ; then
1319    DEFAULT_SOCKET_DIR=$TEMP
1320 elif ! test -z "$TMP" ; then
1321    DEFAULT_SOCKET_DIR=$TMP
1322 else
1323    DEFAULT_SOCKET_DIR=/tmp
1324 fi
1325
1326 if ! test -z "$with_test_socket_dir" ; then
1327    TEST_SOCKET_DIR="$with_test_socket_dir"
1328 else
1329    TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1330 fi
1331 AC_SUBST(TEST_SOCKET_DIR)
1332 AC_DEFINE_UNQUOTED(DBUS_TEST_SOCKET_DIR, "$TEST_SOCKET_DIR", [Where to put test sockets])
1333
1334 if ! test -z "$with_session_socket_dir" ; then
1335    DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
1336 else
1337    DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
1338 fi
1339 AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
1340 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
1341
1342 # Detect if we can build Python bindings (need python, python headers, and pyrex)
1343 if test x$enable_python = xno; then
1344     have_python=no
1345 else
1346     have_python_version=2.4
1347     AC_MSG_NOTICE([Checking to see if we can build Python bindings])
1348     have_python=no
1349     AM_PATH_PYTHON()
1350
1351     if test -z "$PYTHON" ; then
1352         AC_MSG_WARN([Python not found])
1353     else
1354         AC_MSG_CHECKING([whether $PYTHON version >= $have_python_version])
1355         AM_PYTHON_CHECK_VERSION([$PYTHON], [$have_python_version],
1356                               [have_python_version="yes"],
1357                               [have_python_version="too old"])
1358     
1359         AC_MSG_RESULT($have_python_version)
1360     
1361         AC_CHECK_PROGS(PYREX, pyrexc)
1362
1363         if test -z "$PYREX" ; then
1364             have_pyrex=no
1365         else
1366             have_pyrex=yes
1367         fi
1368
1369         AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
1370
1371         if test x$have_pyrex = xyes -a x$have_python_headers = xyes -a "x$have_python_version" = xyes ; then
1372             have_python=yes
1373         fi
1374     fi
1375
1376     if test x$have_python = xno ; then
1377         if test x$enable_python = xyes ; then
1378             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])
1379         else
1380             AC_MSG_WARN([Couldn't find either Pyrex, the Python headers or a suitable version of Python, not building Python bindings])
1381         fi
1382     fi               
1383 fi
1384
1385 AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
1386
1387 AC_OUTPUT([
1388 Doxyfile
1389 dbus/dbus-arch-deps.h
1390 bus/system.conf
1391 bus/session.conf
1392 bus/messagebus
1393 bus/rc.messagebus
1394 bus/dbus-daemon.1
1395 Makefile
1396 dbus/Makefile
1397 glib/Makefile
1398 glib/examples/Makefile
1399 glib/examples/statemachine/Makefile
1400 python/Makefile
1401 python/examples/Makefile
1402 qt/Makefile
1403 qt/examples/Makefile
1404 qt3/Makefile
1405 gcj/Makefile
1406 gcj/org/Makefile
1407 gcj/org/freedesktop/Makefile
1408 gcj/org/freedesktop/dbus/Makefile
1409 mono/Makefile
1410 mono/AssemblyInfo.cs
1411 mono/dbus-sharp.dll.config
1412 mono/example/Makefile
1413 mono/doc/Makefile
1414 bus/Makefile
1415 tools/Makefile
1416 test/Makefile
1417 test/glib/Makefile
1418 test/python/Makefile
1419 test/qt/Makefile
1420 test/name-test/Makefile
1421 doc/Makefile
1422 dbus-1.pc
1423 dbus-glib-1.pc
1424 dbus-sharp.pc
1425 dbus-qt4-1.pc
1426 test/data/valid-config-files/debug-allow-all.conf
1427 test/data/valid-config-files/debug-allow-all-sha1.conf
1428 test/data/valid-service-files/debug-echo.service
1429 test/data/valid-service-files/debug-segfault.service
1430 test/data/valid-service-files/debug-glib.service
1431 test/data/valid-service-files/debug-shell-echo-success.service
1432 test/data/valid-service-files/debug-shell-echo-fail.service
1433 test/data/valid-service-files/debug-python.service
1434 ])
1435
1436 ### FIXME it's bizarre that have_qt and have_glib are used
1437 ### instead of enable_ - should fix things so that enable 
1438 ### is always whether it's enabled, and have is always whether 
1439 ### it was found.
1440
1441 dnl ==========================================================================
1442 echo "
1443                     D-BUS $VERSION
1444                   ==============
1445
1446         prefix:                   ${prefix}
1447         exec_prefix:              ${exec_prefix}
1448         libdir:                   ${EXPANDED_LIBDIR}
1449         bindir:                   ${EXPANDED_BINDIR}
1450         sysconfdir:               ${EXPANDED_SYSCONFDIR}
1451         localstatedir:            ${EXPANDED_LOCALSTATEDIR}
1452         datadir:                  ${EXPANDED_DATADIR}
1453         source code location:     ${srcdir}
1454         compiler:                 ${CC}
1455         cflags:                   ${CFLAGS}
1456         cppflags:                 ${CPPFLAGS}
1457         cxxflags:                 ${CXXFLAGS}
1458         64-bit int:               ${DBUS_INT64_TYPE}
1459         32-bit int:               ${DBUS_INT32_TYPE}
1460         16-bit int:               ${DBUS_INT16_TYPE}
1461         Doxygen:                  ${DOXYGEN}
1462         xmlto:                    ${XMLTO}"
1463
1464 if test x$enable_gcj = xyes ; then
1465 echo \
1466 "        gcj:                     ${GCJ}
1467         gcjflags:                 ${GCJFLAGS}
1468         jar:                      ${JAR}"
1469 else
1470 echo \
1471 "        gcj:                      (not enabled)"
1472 fi
1473
1474 if test x$enable_mono = xyes ; then
1475 echo \
1476 "        csc:                     ${CSC}
1477 "
1478 else
1479 echo \
1480 "        csc:                      (not enabled)
1481 "
1482 fi
1483
1484 echo "
1485         Maintainer mode:          ${USE_MAINTAINER_MODE}
1486         gcc coverage profiling:   ${enable_gcov}
1487         Building unit tests:      ${enable_tests}
1488         Building verbose mode:    ${enable_verbose_mode}
1489         Building assertions:      ${enable_asserts}
1490         Building checks:          ${enable_checks}
1491         Building Qt4 bindings:    ${have_qt}
1492         Building Qt3 bindings:    ${have_qt3}
1493         Building GLib bindings:   ${have_glib}
1494         Building Python bindings: ${have_python}
1495         Building SELinux support: ${have_selinux}
1496         Building dnotify support: ${have_dnotify}
1497         Building Mono bindings:   ${enable_mono}
1498         Building Mono docs:       ${enable_mono_docs}
1499         Building GTK+ tools:      ${have_gtk}
1500         Building X11 code:        ${enable_x11}
1501         Building Doxygen docs:    ${enable_doxygen_docs}
1502         Building XML docs:        ${enable_xml_docs}
1503         Gettext libs (empty OK):  ${INTLLIBS}
1504         Using XML parser:         ${with_xml}
1505         Init scripts style:       ${with_init_scripts}
1506         Abstract socket names:    ${have_abstract_sockets}
1507         System bus socket:        ${DBUS_SYSTEM_SOCKET}
1508         System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
1509         System bus PID file:      ${DBUS_SYSTEM_PID_FILE}
1510         Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}
1511         Console auth dir:         ${DBUS_CONSOLE_AUTH_DIR}
1512         System bus user:          ${DBUS_USER}
1513         Session bus services dir: ${EXPANDED_DATADIR}/dbus-1/services
1514         'make check' socket dir:  ${TEST_SOCKET_DIR}
1515 "
1516
1517 if test x$enable_tests = xyes; then
1518         echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
1519 fi
1520 if test x$enable_tests = xyes -a x$enable_asserts = xno; then
1521         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)"
1522 fi
1523 if test x$enable_gcov = xyes; then
1524         echo "NOTE: building with coverage profiling is definitely for developers only."
1525 fi
1526 if test x$enable_verbose_mode = xyes; then
1527         echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
1528 fi
1529 if test x$enable_asserts = xyes; then
1530         echo "NOTE: building with assertions increases library size and decreases performance."
1531 fi
1532 if test x$enable_checks = xno; then
1533         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."
1534 fi