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