ff53b944a48bbfd5a9e624de45ca9dcf4d64d75f
[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.21)
7
8 AM_CONFIG_HEADER(config.h)
9
10 # Honor aclocal flags
11 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
12
13 GETTEXT_PACKAGE=dbus-1
14 AC_SUBST(GETTEXT_PACKAGE)
15 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
16
17  ## must come before we use the $USE_MAINTAINER_MODE variable later
18 AM_MAINTAINER_MODE
19
20 AC_PROG_CC
21 AC_PROG_CXX
22 AC_ISC_POSIX
23 AC_HEADER_STDC
24
25 AC_ARG_ENABLE(qt,               [  --enable-qt           enable Qt-friendly client library],enable_qt=$enableval,enable_qt=auto)
26 AC_ARG_ENABLE(glib,             [  --enable-glib         enable GLib-friendly client library],enable_glib=$enableval,enable_glib=auto)
27 AC_ARG_ENABLE(gtk,              [  --enable-gtk          enable GTK-requiring executables],enable_gtk=$enableval,enable_gtk=auto)
28 AC_ARG_ENABLE(tests,            [  --enable-tests        enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
29 AC_ARG_ENABLE(ansi,             [  --enable-ansi         enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
30 AC_ARG_ENABLE(verbose-mode,     [  --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
31 AC_ARG_ENABLE(asserts,          [  --enable-asserts      include assertion checks],enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
32 AC_ARG_ENABLE(checks,           [  --enable-checks       include sanity checks on public API],enable_checks=$enableval,enable_checks=yes)
33 AC_ARG_ENABLE(xml-docs,         [  --enable-xml-docs     build XML documentation (requires xmlto)],enable_xml_docs=$enableval,enable_xml_docs=auto)
34 AC_ARG_ENABLE(doxygen-docs,     [  --enable-doxygen-docs     build DOXYGEN documentation (requires Doxygen)],enable_doxygen_docs=$enableval,enable_doxygen_docs=auto)
35 AC_ARG_ENABLE(gcov,             [  --enable-gcov         compile with coverage profiling instrumentation (gcc only)],enable_gcov=$enableval,enable_gcov=no)
36 AC_ARG_ENABLE(abstract-sockets, [  --enable-abstract-sockets  use abstract socket namespace (linux only)],enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
37 AC_ARG_ENABLE(gcj,              [  --enable-gcj          build gcj bindings],enable_gcj=$enableval,enable_gcj=no)
38 AC_ARG_ENABLE(mono,             [  --enable-mono         build mono bindings],enable_mono=$enableval,enable_mono=auto)
39 AC_ARG_ENABLE(python,           [  --enable-python       build python bindings],enable_python=$enableval,enable_python=auto)
40
41
42 AC_ARG_WITH(xml,                [  --with-xml=[libxml/expat]           XML library to use])
43 AC_ARG_WITH(init-scripts,       [  --with-init-scripts=[redhat]        Style of init scripts to install])
44 AC_ARG_WITH(session-socket-dir, [  --with-session-socket-dir=[dirname] Where to put sockets for the per-login-session message bus])
45 AC_ARG_WITH(test-socket-dir,    [  --with-test-socket-dir=[dirname]    Where to put sockets for make check])
46 AC_ARG_WITH(system-pid-file,    [  --with-system-pid-file=[pidfile]    PID file for systemwide daemon])
47 AC_ARG_WITH(system-socket,      [  --with-system-socket=[filename]     UNIX domain socket for systemwide daemon])
48
49 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files 
50 dnl and also some stuff in the test/ subdir
51 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
52 if test x$enable_tests = xyes; then
53     AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
54 fi
55
56 if test x$enable_verbose_mode = xyes; then
57     AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
58 fi
59 if test x$enable_asserts = xno; then
60     AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
61     AC_DEFINE(G_DISABLE_ASSERT,1,[Disable GLib assertion macros])
62 fi
63 if test x$enable_checks = xno; then
64     AC_DEFINE(DBUS_DISABLE_CHECKS,1,[Disable public API sanity checking])
65     AC_DEFINE(G_DISABLE_CHECKS,1,[Disable GLib public API sanity checking])
66 fi
67
68 #### gcc warning flags
69
70 if test "x$GCC" = "xyes"; then
71   changequote(,)dnl
72   case " $CFLAGS " in
73   *[\ \ ]-Wall[\ \      ]*) ;;
74   *) CFLAGS="$CFLAGS -Wall" ;;
75   esac
76
77   case " $CFLAGS " in
78   *[\ \ ]-Wchar-subscripts[\ \  ]*) ;;
79   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
80   esac
81
82   case " $CFLAGS " in
83   *[\ \ ]-Wmissing-declarations[\ \     ]*) ;;
84   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
85   esac
86
87   case " $CFLAGS " in
88   *[\ \ ]-Wmissing-prototypes[\ \       ]*) ;;
89   *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
90   esac
91
92   case " $CFLAGS " in
93   *[\ \ ]-Wnested-externs[\ \   ]*) ;;
94   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
95   esac
96
97   case " $CFLAGS " in
98   *[\ \ ]-Wpointer-arith[\ \    ]*) ;;
99   *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
100   esac
101
102   case " $CFLAGS " in
103   *[\ \ ]-Wcast-align[\ \       ]*) ;;
104   *) CFLAGS="$CFLAGS -Wcast-align" ;;
105   esac
106
107   case " $CFLAGS " in
108   *[\ \ ]-Wsign-compare[\ \     ]*) ;;
109   *) CFLAGS="$CFLAGS -Wsign-compare" ;;
110   esac
111
112   if test "x$enable_ansi" = "xyes"; then
113     case " $CFLAGS " in
114     *[\ \       ]-ansi[\ \      ]*) ;;
115     *) CFLAGS="$CFLAGS -ansi" ;;
116     esac
117
118     case " $CFLAGS " in
119     *[\ \       ]-D_POSIX_C_SOURCE*) ;;
120     *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
121     esac
122
123     case " $CFLAGS " in
124     *[\ \       ]-D_BSD_SOURCE[\ \      ]*) ;;
125     *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
126     esac
127
128     case " $CFLAGS " in
129     *[\ \       ]-pedantic[\ \  ]*) ;;
130     *) CFLAGS="$CFLAGS -pedantic" ;;
131     esac
132   fi
133   if test x$enable_gcov = xyes; then
134     case " $CFLAGS " in
135     *[\ \       ]-fprofile-arcs[\ \     ]*) ;;
136     *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
137     esac
138     case " $CFLAGS " in
139     *[\ \       ]-ftest-coverage[\ \    ]*) ;;
140     *) CFLAGS="$CFLAGS -ftest-coverage" ;;
141     esac
142
143     ## remove optimization
144     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
145   fi
146   changequote([,])dnl
147 else
148   if test x$enable_gcov = xyes; then
149     AC_MSG_ERROR([--enable-gcov can only be used with gcc])
150   fi
151 fi
152
153 #### can't use AM_PROG_GCJ since it fails fatally if no gcj found
154 AC_CHECK_PROGS(GCJ, gcj, gcj)
155 if test -z "$GCJ" ; then
156      have_gcj=no
157 else
158      # Needs to be here so libtool wont get confused
159      AM_PROG_GCJ
160
161      have_gcj=yes
162      if test "x${GCJFLAGS-unset}" = xunset; then
163         GCJFLAGS="-g -O2 -Wall"
164      fi
165      AC_SUBST(GCJFLAGS)
166 fi
167
168 if test x$enable_gcj = xauto ; then
169     if test x$have_gcj = xno ; then
170         enable_gcj=no
171     else
172         enable_gcj=yes
173     fi
174 fi
175
176 if test x$enable_gcj = xyes; then
177     if test x$have_gcj = xno ; then
178         AC_MSG_ERROR([Building gcj explicitly required, but gcj not found])
179     fi
180 fi
181
182 AM_CONDITIONAL(DBUS_USE_GCJ, test x$enable_gcj = xyes)
183
184 AM_PROG_LIBTOOL
185
186 #### Look for mono
187 AC_CHECK_TOOL(MCS, mcs)
188 if test -z "$MCS" ; then
189      have_mcs=no
190 else
191      have_mcs=yes
192      if test "x${MCSFLAGS-unset}" = xunset; then
193         MCSFLAGS="" ### put default MCSFLAGS here
194      fi
195      AC_SUBST(MCSFLAGS)
196 fi
197
198 if test x$enable_mono = xauto ; then
199     if test x$have_mcs = xno ; then
200         enable_mono=no
201     else
202         enable_mono=yes
203     fi
204 fi
205
206 if test x$enable_mono = xyes; then
207     if test x$have_mcs = xno ; then
208         AC_MSG_ERROR([Building Mono bindings explicitly required, but mcs compiler not found])
209     fi
210 fi
211
212 AM_CONDITIONAL(DBUS_USE_MCS, test x$enable_mono = xyes)
213
214 changequote(,)dnl
215 # let ourselves use our own unstable API
216 CPPFLAGS="-DDBUS_API_SUBJECT_TO_CHANGE=1 $CPPFLAGS"
217 # compress spaces in flags
218 CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`
219 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ +/ /g'`
220 CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/ +/ /g'`
221 changequote([,])dnl
222
223 if test x$enable_gcov = xyes; then
224      ## so that config.h changes when you toggle gcov support
225      AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
226
227      AC_MSG_CHECKING([for gcc 3.3 version of gcov file format])
228      have_gcc33_gcov=no
229      AC_RUN_IFELSE( [AC_LANG_PROGRAM( , [[ if (__GNUC__ >=3 && __GNUC_MINOR__ >= 3) exit (0); else exit (1); ]])],  
230                    have_gcc33_gcov=yes)
231      if test x$have_gcc33_gcov = xyes ; then
232          AC_DEFINE_UNQUOTED(DBUS_HAVE_GCC33_GCOV, 1, [Defined if we have gcc 3.3 and thus the new gcov format])
233      fi
234      AC_MSG_RESULT($have_gcc33_gcov)
235 fi
236 AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
237
238 #### Integer sizes 
239
240 AC_CHECK_SIZEOF(char)
241 AC_CHECK_SIZEOF(short)
242 AC_CHECK_SIZEOF(long)
243 AC_CHECK_SIZEOF(int)
244 AC_CHECK_SIZEOF(void *)
245 AC_CHECK_SIZEOF(long long)
246 AC_CHECK_SIZEOF(__int64)
247
248 ### See what our 64 bit type is called
249 AC_MSG_CHECKING([64-bit integer type])
250
251 case 8 in
252 $ac_cv_sizeof_int)
253   dbusint64=int
254   dbusint64_constant='(val)'
255   dbusuint64_constant='(val)'
256   ;;
257 $ac_cv_sizeof_long)
258   dbusint64=long
259   dbusint64_constant='(val##L)'
260   dbusuint64_constant='(val##UL)'
261   ;;
262 $ac_cv_sizeof_long_long)
263   dbusint64='long long'
264   dbusint64_constant='(val##LL)'
265   dbusuint64_constant='(val##ULL)'
266   ;;
267 $ac_cv_sizeof___int64)
268   dbusint64=__int64
269   dbusint64_constant='(val##i64)'
270   dbusuint64_constant='(val##ui64)'
271   ;;
272 esac
273
274 if test -z "$dbusint64" ; then
275         DBUS_INT64_TYPE="no_int64_type_detected"
276         DBUS_HAVE_INT64=0
277         DBUS_INT64_CONSTANT=
278         DBUS_UINT64_CONSTANT=
279         AC_MSG_RESULT([none found])
280 else
281         DBUS_INT64_TYPE="$dbusint64"
282         DBUS_HAVE_INT64=1
283         DBUS_INT64_CONSTANT="$dbusint64_constant"
284         DBUS_UINT64_CONSTANT="$dbusuint64_constant"
285         AC_MSG_RESULT($DBUS_INT64_TYPE)
286 fi
287
288 AC_SUBST(DBUS_INT64_TYPE)
289 AC_SUBST(DBUS_INT64_CONSTANT)
290 AC_SUBST(DBUS_UINT64_CONSTANT)
291 AC_SUBST(DBUS_HAVE_INT64)
292
293 ## byte order
294 AC_C_BIGENDIAN
295
296
297 dnl **********************************
298 dnl *** va_copy checks (from GLib) ***
299 dnl **********************************
300 dnl we currently check for all three va_copy possibilities, so we get
301 dnl all results in config.log for bug reports.
302 AC_CACHE_CHECK([for an implementation of va_copy()],dbus_cv_va_copy,[
303         AC_LINK_IFELSE([#include <stdarg.h>
304         void f (int i, ...) {
305         va_list args1, args2;
306         va_start (args1, i);
307         va_copy (args2, args1);
308         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
309           exit (1);
310         va_end (args1); va_end (args2);
311         }
312         int main() {
313           f (0, 42);
314           return 0;
315         }],
316         [dbus_cv_va_copy=yes],
317         [dbus_cv_va_copy=no])
318 ])
319 AC_CACHE_CHECK([for an implementation of __va_copy()],dbus_cv___va_copy,[
320         AC_LINK_IFELSE([#include <stdarg.h>
321         void f (int i, ...) {
322         va_list args1, args2;
323         va_start (args1, i);
324         __va_copy (args2, args1);
325         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
326           exit (1);
327         va_end (args1); va_end (args2);
328         }
329         int main() {
330           f (0, 42);
331           return 0;
332         }],
333         [dbus_cv___va_copy=yes],
334         [dbus_cv___va_copy=no])
335 ])
336
337 if test "x$dbus_cv_va_copy" = "xyes"; then
338   dbus_va_copy_func=va_copy
339 else if test "x$dbus_cv___va_copy" = "xyes"; then
340   dbus_va_copy_func=__va_copy
341 fi
342 fi
343
344 if test -n "$dbus_va_copy_func"; then
345   AC_DEFINE_UNQUOTED(DBUS_VA_COPY,$dbus_va_copy_func,[A 'va_copy' style function])
346 fi
347
348 AC_CACHE_CHECK([whether va_lists can be copied by value],dbus_cv_va_val_copy,[
349         AC_TRY_RUN([#include <stdarg.h>
350         void f (int i, ...) {
351         va_list args1, args2;
352         va_start (args1, i);
353         args2 = args1;
354         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
355           exit (1);
356         va_end (args1); va_end (args2);
357         }
358         int main() {
359           f (0, 42);
360           return 0;
361         }],
362         [dbus_cv_va_val_copy=yes],
363         [dbus_cv_va_val_copy=no],
364         [dbus_cv_va_val_copy=yes])
365 ])
366
367 if test "x$dbus_cv_va_val_copy" = "xno"; then
368   AC_DEFINE(DBUS_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
369 fi
370
371
372 #### Atomic integers (checks by Sebastian Wilhelmi for GLib)
373 AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers])
374 have_atomic_inc=no
375 if test x"$GCC" = xyes; then
376   if test "x$enable_ansi" = "xyes"; then
377     AC_MSG_RESULT([no])
378   else
379     case $host_cpu in
380       i386)
381         AC_MSG_RESULT([no])
382         ;;
383       i?86)
384         AC_MSG_RESULT([i486])
385         AC_DEFINE_UNQUOTED(DBUS_USE_ATOMIC_INT_486, 1, [Use atomic integer implementation for 486])
386         have_atomic_inc=yes
387         ;;
388       *)
389         AC_MSG_RESULT([no])
390         ;;
391     esac
392   fi
393 fi
394 if test x$have_atomic_inc = xyes ; then
395   AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT, 1, [Some atomic integer implementation present])
396 fi
397
398 #### Various functions
399 AC_CHECK_LIB(socket,socket)
400 AC_CHECK_LIB(nsl,gethostbyname)
401
402 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv unsetenv socketpair getgrouplist)
403
404 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
405
406 AC_CACHE_CHECK([for posix getpwnam_r],
407                 ac_cv_func_posix_getpwnam_r,
408                 [AC_TRY_RUN([
409 #include <errno.h>
410 #include <pwd.h>
411 int main () { 
412     char buffer[10000];
413     struct passwd pwd, *pwptr = &pwd;
414     int error;
415     errno = 0;
416     error = getpwnam_r ("", &pwd, buffer, 
417                         sizeof (buffer), &pwptr);
418    return (error < 0 && errno == ENOSYS) 
419            || error == ENOSYS; 
420 }               ],
421         [ac_cv_func_posix_getpwnam_r=yes],
422         [ac_cv_func_posix_getpwnam_r=no])])
423 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
424         AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
425                 [Have POSIX function getpwnam_r])
426 else
427         AC_CACHE_CHECK([for nonposix getpwnam_r],
428                 ac_cv_func_nonposix_getpwnam_r,
429                 [AC_TRY_LINK([#include <pwd.h>],
430                         [char buffer[10000];
431                         struct passwd pwd;
432                         getpwnam_r ("", &pwd, buffer, 
433                                         sizeof (buffer));],
434                         [ac_cv_func_nonposix_getpwnam_r=yes],
435                         [ac_cv_func_nonposix_getpwnam_r=no])])
436                 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
437                 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
438                         [Have non-POSIX function getpwnam_r])
439         fi
440 fi
441
442 dnl check for socklen_t
443 AC_MSG_CHECKING(whether socklen_t is defined)
444 AC_TRY_COMPILE([
445 #include <sys/types.h>
446 #include <sys/socket.h>
447 #include <netdb.h>
448 ],[
449 socklen_t foo;
450 foo = 1;
451 ],dbus_have_socklen_t=yes,dbus_have_socklen_t=no)
452 AC_MSG_RESULT($dbus_have_socklen_t)
453
454 if test "x$dbus_have_socklen_t" = "xyes"; then
455     AC_DEFINE(HAVE_SOCKLEN_T,1,[Have socklen_t type])
456 fi
457
458 dnl check for writev header and writev function so we're 
459 dnl good to go if HAVE_WRITEV gets defined.
460 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
461
462 dnl check for flavours of varargs macros (test from GLib)
463 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
464 AC_TRY_COMPILE([],[
465 int a(int p1, int p2, int p3);
466 #define call_a(...) a(1,__VA_ARGS__)
467 call_a(2,3);
468 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
469 AC_MSG_RESULT($dbus_have_iso_c_varargs)
470
471 AC_MSG_CHECKING(for GNUC varargs macros)
472 AC_TRY_COMPILE([],[
473 int a(int p1, int p2, int p3);
474 #define call_a(params...) a(1,params)
475 call_a(2,3);
476 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
477 AC_MSG_RESULT($dbus_have_gnuc_varargs)
478
479 dnl Output varargs tests
480 if test x$dbus_have_iso_c_varargs = xyes; then
481     AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
482 fi
483 if test x$dbus_have_gnuc_varargs = xyes; then
484     AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
485 fi
486
487 dnl Check for various credentials.
488 AC_MSG_CHECKING(for struct cmsgcred)
489 AC_TRY_COMPILE([
490 #include <sys/types.h>
491 #include <sys/socket.h>
492 ],[
493 struct cmsgcred cred;
494
495 cred.cmcred_pid = 0;
496 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
497 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
498
499 if test x$dbus_have_struct_cmsgcred = xyes; then
500     AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
501 fi
502
503
504 #### Abstract sockets
505
506 AC_MSG_CHECKING(abstract socket namespace)
507 AC_LANG_PUSH(C)
508 AC_RUN_IFELSE([AC_LANG_PROGRAM(
509 [[
510 #include <sys/types.h>
511 #include <stdlib.h>
512 #include <string.h>
513 #include <stdio.h>
514 #include <sys/socket.h>
515 #include <sys/un.h>
516 #include <errno.h>
517 ]],
518 [[
519   int listen_fd;
520   struct sockaddr_un addr;
521   
522   listen_fd = socket (PF_UNIX, SOCK_STREAM, 0);
523   
524   if (listen_fd < 0)
525     {
526       fprintf (stderr, "socket() failed: %s\n", strerror (errno));
527       exit (1);
528     }
529
530   memset (&addr, '\0', sizeof (addr));
531   addr.sun_family = AF_UNIX;
532   strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test");
533   addr.sun_path[0] = '\0'; /* this is what makes it abstract */
534   
535   if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0)
536     {
537        fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", 
538                 strerror (errno));
539        exit (1);
540     }
541   else 
542     exit (0);
543 ]])],
544               [have_abstract_sockets=yes],
545               [have_abstract_sockets=no])
546 AC_LANG_POP(C)
547 AC_MSG_RESULT($have_abstract_sockets)
548
549 if test x$enable_abstract_sockets = xyes; then
550     if test x$have_abstract_sockets = xno; then
551         AC_MSG_ERROR([Abstract sockets explicitly required, and support not detected.])
552     fi
553 fi
554
555 if test x$enable_abstract_sockets = xno; then
556    have_abstract_sockets=no;
557 fi
558
559 if test x$have_abstract_sockets = xyes ; then
560    abstract_sockets=1
561    DBUS_PATH_OR_ABSTRACT=abstract
562 else
563    abstract_sockets=0
564    DBUS_PATH_OR_ABSTRACT=path
565 fi
566
567 AC_DEFINE_UNQUOTED(HAVE_ABSTRACT_SOCKETS, $abstract_sockets, [Have abstract socket namespace])
568
569 # this is used in addresses to prefer abstract, e.g. 
570 # unix:path=/foo or unix:abstract=/foo 
571 AC_SUBST(DBUS_PATH_OR_ABSTRACT)
572
573 #### Sort out XML library
574
575 # see what we have
576 AC_CHECK_LIB(expat, XML_ParserCreate_MM, 
577              [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
578              have_expat=false)
579
580 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
581
582 # see what we want to use
583 dbus_use_libxml=false
584 dbus_use_expat=false
585 if test x$with_xml = xexpat; then
586         dbus_use_expat=true
587         if ! $have_expat ; then
588            AC_MSG_ERROR([Explicitly requested expat but expat not found])
589         fi
590 elif test x$with_xml = xlibxml; then
591         dbus_use_libxml=true
592         if ! $have_libxml ; then
593            AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
594         fi
595 else
596         ### expat is the default because libxml can't currently survive 
597         ### our brutal OOM-handling unit test setup.
598         ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
599         if $have_expat ; then
600                 with_xml=expat
601                 dbus_use_expat=true
602         elif $have_libxml ; then
603                 with_xml=libxml
604                 dbus_use_libxml=true
605         else
606                 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
607         fi
608 fi
609
610 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
611 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
612
613 if $dbus_use_expat; then
614    XML_LIBS=-lexpat
615    XML_CFLAGS=
616 fi
617 if $dbus_use_libxml; then
618    XML_LIBS=$LIBXML_LIBS
619    XML_CFLAGS=$LIBXML_CFLAGS
620 fi
621
622 #### Set up final flags
623 DBUS_CLIENT_CFLAGS=
624 DBUS_CLIENT_LIBS=
625 AC_SUBST(DBUS_CLIENT_CFLAGS)
626 AC_SUBST(DBUS_CLIENT_LIBS)
627
628 DBUS_BUS_CFLAGS=$XML_CFLAGS
629 DBUS_BUS_LIBS=$XML_LIBS
630 AC_SUBST(DBUS_BUS_CFLAGS)
631 AC_SUBST(DBUS_BUS_LIBS)
632
633 DBUS_TEST_CFLAGS=
634 DBUS_TEST_LIBS=
635 AC_SUBST(DBUS_TEST_CFLAGS)
636 AC_SUBST(DBUS_TEST_LIBS)
637
638 # Glib detection
639 PKG_CHECK_MODULES(DBUS_GLIB, gobject-2.0, have_glib=yes, have_glib=no)
640 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
641
642 if test x$have_glib = xno ; then
643     AC_MSG_WARN([GLib development libraries not found])
644 fi
645
646 if test x$enable_glib = xyes; then
647     if test x$have_glib = xno; then
648         AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
649     fi
650 fi
651
652 if test x$enable_glib = xno; then
653    have_glib=no;
654 fi
655
656 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
657 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
658
659 dnl GLib flags
660 AC_SUBST(DBUS_GLIB_CFLAGS)
661 AC_SUBST(DBUS_GLIB_LIBS)
662 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
663
664 DBUS_GLIB_TOOL_CFLAGS=$XML_CFLAGS
665 DBUS_GLIB_TOOL_LIBS=$XML_LIBS
666 AC_SUBST(DBUS_GLIB_TOOL_CFLAGS)
667 AC_SUBST(DBUS_GLIB_TOOL_LIBS)
668
669 # GTK detection
670 if test x$have_glib = xno ; then
671     AC_MSG_WARN([Can't use GTK+ since GLib not enabled])
672     have_gtk=no
673 else
674     PKG_CHECK_MODULES(DBUS_GTK, gtk+-2.0, have_gtk=yes, have_gtk=no)
675 fi
676
677 if test x$have_gtk = xno ; then
678     AC_MSG_WARN([GTK+ development libraries not found])
679 fi
680
681 if test x$enable_gtk = xyes; then
682     if test x$have_gtk = xno; then
683         AC_MSG_ERROR([GTK+ explicitly required, and GTK+ development libraries not found])
684     fi
685 fi
686
687 if test x$enable_gtk = xno; then
688    have_gtk=no;
689 fi
690
691 AM_CONDITIONAL(HAVE_GTK, test x$have_gtk = xyes)
692
693 dnl Gtk flags
694 AC_SUBST(DBUS_GTK_CFLAGS)
695 AC_SUBST(DBUS_GTK_LIBS)
696
697 # Qt detection
698 AC_PATH_PROG(QT_MOC, moc, no)
699
700 have_qt=no
701 AC_MSG_CHECKING([for qglobal.h])
702 if test -n "$QTDIR" -a -f "$QTDIR/include/qglobal.h"; then
703     have_qt=yes
704     DBUS_QT_CXXFLAGS="-I$QTDIR/include"
705 else
706     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
707         if test -f "$dir/qglobal.h"; then
708             have_qt=yes
709             DBUS_QT_CXXFLAGS="-I$dir"
710        fi
711     done
712 fi
713 if test x"$have_qt" = x"yes"; then
714    AC_MSG_RESULT([found])
715 else
716    AC_MSG_RESULT([not found])
717 fi
718
719 dnl linking to kdecore will give us a bit of help from libtool
720 if (! kde-config >& /dev/null); then
721     have_qt=no
722 else
723     kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
724     if test -z $kdelibs -o ! -f $kdelibs/libkdecore.la; then
725         have_qt=no
726     else
727         DBUS_QT_LIBS="$kdelibs/libkdecore.la"
728     fi
729 fi
730
731 if test x$have_qt = xno ; then
732     AC_MSG_WARN([Qt development libraries not found])
733 fi
734
735 if test x$enable_qt = xyes; then
736     if test x$have_qt = xno; then
737         AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
738     fi
739 fi
740
741 if test x$enable_qt = xno; then
742    have_qt=no;
743 fi
744
745 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
746
747 dnl Qt flags
748 AC_SUBST(DBUS_QT_CXXFLAGS)
749 AC_SUBST(DBUS_QT_LIBS)
750
751 ### X11 detection
752 AC_PATH_XTRA
753
754 ## for now enable_x11 just tracks have_x11, 
755 ## there's no --enable-x11
756 if test x$no_x = xyes ; then
757    have_x11=no
758    enable_x11=no
759 else
760    have_x11=yes
761    enable_x11=yes
762 fi
763
764 if test x$enable_x11 = xyes ; then
765    AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
766    DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
767    DBUS_X_CFLAGS="$X_CFLAGS"
768 else
769    DBUS_X_LIBS=
770    DBUS_X_CFLAGS=
771 fi
772
773 AC_SUBST(DBUS_X_CFLAGS)
774 AC_SUBST(DBUS_X_LIBS)
775
776 ### Doxygen Documentation
777
778 AC_PATH_PROG(DOXYGEN, doxygen, no)
779
780 AC_MSG_CHECKING([whether to build Doxygen documentation])
781
782 if test x$DOXYGEN = xno ; then
783     have_doxygen=no
784 else
785     have_doxygen=yes
786 fi
787
788 if test x$enable_doxygen_docs = xauto ; then
789     if test x$have_doxygen = xno ; then
790         enable_doxygen_docs=no
791     else
792         enable_doxygen_docs=yes
793     fi
794 fi
795
796 if test x$enable_doxygen_docs = xyes; then
797     if test x$have_doxygen = xno; then
798         AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
799     fi
800 fi
801
802 AM_CONDITIONAL(DBUS_DOXYGEN_DOCS_ENABLED, test x$enable_doxygen_docs = xyes)
803 AC_MSG_RESULT(yes)
804
805 ### XML Documentation
806
807 AC_PATH_PROG(XMLTO, xmlto, no)
808
809 AC_MSG_CHECKING([whether to build XML documentation])
810
811 if test x$XMLTO = xno ; then
812     have_xmlto=no
813 else
814     have_xmlto=yes
815 fi
816
817 if test x$enable_xml_docs = xauto ; then
818     if test x$have_xmlto = xno ; then
819         enable_xml_docs=no
820     else
821         enable_xml_docs=yes
822     fi
823 fi
824
825 if test x$enable_xml_docs = xyes; then
826     if test x$have_xmlto = xno; then
827         AC_MSG_ERROR([Building XML docs explicitly required, but xmlto not found])
828     fi
829 fi
830
831 AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes)
832 AC_MSG_RESULT(yes)
833
834 #### Have to go $localstatedir->$prefix/var->/usr/local/var   
835 #### someone please fix this a better way...
836
837 #### find the actual value for $prefix that we'll end up with
838 ##   (I know this is broken and should be done in the Makefile, but
839 ##    that's a major pain and almost nobody actually seems to care)
840 REAL_PREFIX=
841 if test "x$prefix" = "xNONE"; then
842   REAL_PREFIX=$ac_default_prefix
843 else
844   REAL_PREFIX=$prefix
845 fi
846
847 ## temporarily change prefix and exec_prefix
848 old_prefix=$prefix
849 prefix=$REAL_PREFIX
850
851 if test "x$exec_prefix" = xNONE ; then
852    REAL_EXEC_PREFIX=$REAL_PREFIX
853 else
854    REAL_EXEC_PREFIX=$exec_prefix
855 fi
856 old_exec_prefix=$exec_prefix
857 exec_prefix=$REAL_EXEC_PREFIX
858
859 ## eval everything
860 LOCALSTATEDIR_TMP="$localstatedir"
861 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
862 AC_SUBST(EXPANDED_LOCALSTATEDIR)
863
864 SYSCONFDIR_TMP="$sysconfdir"
865 EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
866 AC_SUBST(EXPANDED_SYSCONFDIR)
867
868 BINDIR_TMP="$bindir"
869 EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
870 AC_SUBST(EXPANDED_BINDIR)
871
872 LIBDIR_TMP="$libdir"
873 EXPANDED_LIBDIR=`eval echo $LIBDIR_TMP`
874 AC_SUBST(EXPANDED_LIBDIR)
875
876 ## put prefix and exec_prefix back
877 prefix=$old_prefix
878 exec_prefix=$old_exec_prefix
879
880 #### Check our operating system
881 operating_system=unknown
882 if test -f /etc/redhat-release || test -f $EXPANDED_SYSCONFDIR/redhat-release ; then
883    operating_system=redhat
884 fi
885
886 #### Sort out init scripts
887
888 if test x$with_init_scripts = x; then
889     if test xredhat = x$operating_system ; then
890         with_init_scripts=redhat
891     else
892         with_init_scripts=none
893     fi
894 fi
895
896 AM_CONDITIONAL(DBUS_INIT_SCRIPTS_RED_HAT, test x$with_init_scripts = xredhat)
897
898
899 ##### Set up location for system bus socket
900 if ! test -z "$with_system_socket"; then
901    DBUS_SYSTEM_SOCKET=$with_system_socket
902 else
903    DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket
904 fi
905
906 AC_SUBST(DBUS_SYSTEM_SOCKET)
907 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default])
908
909 ## system bus only listens on local domain sockets, and never 
910 ## on an abstract socket (so only root can create the socket)
911 DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET"
912 AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS)
913 AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-BUS address of the system bus])
914
915 #### Set up the pid file
916 if ! test -z "$with_system_pid_file"; then
917    DBUS_SYSTEM_PID_FILE=$with_system_pid_file
918 elif test x$operating_system = xredhat ; then
919    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid
920 else
921    DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid
922 fi
923
924 AC_SUBST(DBUS_SYSTEM_PID_FILE)
925
926 #### Tell tests where to find certain stuff in builddir
927 ABSOLUTE_TOP_BUILDDIR=`cd ${ac_top_builddir}. && pwd`
928
929 AC_DEFUN(TEST_PATH, [
930 TEST_$1=${ABSOLUTE_TOP_BUILDDIR}/test/$2
931 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1",
932                    [Full path to test file test/$2 in builddir])
933 AC_SUBST(TEST_$1)
934 ])
935
936 TEST_PATH(SERVICE_DIR, data/valid-service-files)
937 TEST_PATH(SERVICE_BINARY, test-service)
938 TEST_PATH(GLIB_SERVICE_BINARY, test-service-glib)
939 TEST_PATH(EXIT_BINARY, test-exit)
940 TEST_PATH(SEGFAULT_BINARY, test-segfault)
941 TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever)
942 AC_SUBST(ABSOLUTE_TOP_BUILDDIR)
943
944 #### Find socket directories
945 if ! test -z "$TMPDIR" ; then
946    DEFAULT_SOCKET_DIR=$TMPDIR
947 elif ! test -z "$TEMP" ; then
948    DEFAULT_SOCKET_DIR=$TEMP
949 elif ! test -z "$TMP" ; then
950    DEFAULT_SOCKET_DIR=$TMP
951 else
952    DEFAULT_SOCKET_DIR=/tmp
953 fi
954
955 if ! test -z "$with_test_socket_dir" ; then
956    TEST_SOCKET_DIR="$with_test_socket_dir"
957 else
958    TEST_SOCKET_DIR=$DEFAULT_SOCKET_DIR
959 fi
960 AC_SUBST(TEST_SOCKET_DIR)
961 AC_DEFINE_UNQUOTED(DBUS_TEST_SOCKET_DIR, "$TEST_SOCKET_DIR", [Where to put test sockets])
962
963 if ! test -z "$with_session_socket_dir" ; then
964    DBUS_SESSION_SOCKET_DIR="$with_session_socket_dir"
965 else
966    DBUS_SESSION_SOCKET_DIR=$DEFAULT_SOCKET_DIR
967 fi
968 AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
969 AC_SUBST(DBUS_SESSION_SOCKET_DIR)
970
971 # Detect if we can build Python bindings (need python, python headers, and pyrex)
972 if test x$enable_python = xno; then
973     have_python=no
974 else
975     AC_MSG_NOTICE([Checking to see if we can build Python bindings])
976     have_python=no
977     AM_PATH_PYTHON(2.2)
978
979     if test -z "$PYTHON" ; then
980         AC_MSG_WARN([Python not found])
981     else
982         AC_CHECK_PROGS(PYREX, pyrexc)
983
984         if test -z "$PYREX" ; then
985             have_pyrex=no
986         else
987             have_pyrex=yes
988         fi
989
990         AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
991
992         if test x$have_pyrex = xyes -a x$have_python_headers = xyes ; then
993             have_python=yes
994         fi
995     fi
996
997     if test x$have_python = xno ; then
998         if test x$enable_python = xyes ; then
999             AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings])
1000         else
1001             AC_MSG_WARN([Couldn't find either Pyrex or the Python headers, not building Python bindings])
1002         fi
1003     fi               
1004 fi
1005
1006 AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
1007
1008
1009 AC_OUTPUT([
1010 Doxyfile
1011 dbus/dbus-arch-deps.h
1012 bus/system.conf
1013 bus/session.conf
1014 bus/messagebus
1015 bus/dbus-daemon-1.1
1016 Makefile
1017 dbus/Makefile
1018 glib/Makefile
1019 python/Makefile
1020 qt/Makefile
1021 gcj/Makefile
1022 gcj/org/Makefile
1023 gcj/org/freedesktop/Makefile
1024 gcj/org/freedesktop/dbus/Makefile
1025 mono/Makefile
1026 mono/example/Makefile
1027 bus/Makefile
1028 tools/Makefile
1029 test/Makefile
1030 test/glib/Makefile
1031 doc/Makefile
1032 dbus-1.pc
1033 dbus-glib-1.pc
1034 dbus-sharp.pc
1035 test/data/valid-config-files/debug-allow-all.conf
1036 test/data/valid-config-files/debug-allow-all-sha1.conf
1037 test/data/valid-service-files/debug-echo.service
1038 test/data/valid-service-files/debug-segfault.service
1039 ])
1040
1041 ### FIXME it's bizarre that have_qt and have_glib are used
1042 ### instead of enable_ - should fix things so that enable 
1043 ### is always whether it's enabled, and have is always whether 
1044 ### it was found.
1045
1046 dnl ==========================================================================
1047 echo "
1048                     D-BUS $VERSION
1049                   ==============
1050
1051         prefix:                   ${prefix}
1052         exec_prefix:              ${exec_prefix}
1053         libdir:                   ${EXPANDED_LIBDIR}
1054         bindir:                   ${EXPANDED_BINDIR}
1055         sysconfdir:               ${EXPANDED_SYSCONFDIR}
1056         localstatedir:            ${EXPANDED_LOCALSTATEDIR}
1057         source code location:     ${srcdir}
1058         compiler:                 ${CC}
1059         cflags:                   ${CFLAGS}
1060         cppflags:                 ${CPPFLAGS}
1061         cxxflags:                 ${CXXFLAGS}
1062         64-bit int:               ${DBUS_INT64_TYPE}
1063         Doxygen:                  ${DOXYGEN}
1064         xmlto:                    ${XMLTO}"
1065
1066 if test x$enable_gcj = xyes ; then
1067 echo \
1068 "        gcj:                     ${GCJ}
1069         gcjflags:                 ${GCJFLAGS}"
1070 else
1071 echo \
1072 "        gcj:                      (not enabled)"
1073 fi
1074
1075 if test x$enable_mono = xyes ; then
1076 echo \
1077 "        mcs:                     ${MCS}
1078         mcsflags:                 ${MCSFLAGS}
1079 "
1080 else
1081 echo \
1082 "        mcs:                      (not enabled)
1083 "
1084 fi
1085
1086 echo "
1087         Maintainer mode:          ${USE_MAINTAINER_MODE}
1088         gcc coverage profiling:   ${enable_gcov}
1089         Building unit tests:      ${enable_tests}
1090         Building verbose mode:    ${enable_verbose_mode}
1091         Building assertions:      ${enable_asserts}
1092         Building checks:          ${enable_checks}
1093         Building Qt bindings:     ${have_qt}
1094         Building GLib bindings:   ${have_glib}
1095         Building Python bindings: ${have_python}
1096         Building Mono bindings:   ${enable_mono}
1097         Building GTK+ tools:      ${have_gtk}
1098         Building X11 code:        ${enable_x11}
1099         Building Doxygen docs:    ${enable_doxygen_docs}
1100         Building XML docs:        ${enable_xml_docs}
1101         Using XML parser:         ${with_xml}
1102         Init scripts style:       ${with_init_scripts}
1103         Abstract socket names:    ${have_abstract_sockets}
1104         System bus socket:        ${DBUS_SYSTEM_SOCKET}
1105         System bus address:       ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
1106         System bus PID file:      ${DBUS_SYSTEM_PID_FILE}
1107         Session bus socket dir:   ${DBUS_SESSION_SOCKET_DIR}
1108         'make check' socket dir:  ${TEST_SOCKET_DIR}
1109 "
1110
1111 if test x$enable_tests = xyes; then
1112         echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
1113 fi
1114 if test x$enable_tests = xyes -a x$enable_asserts = xno; then
1115         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)"
1116 fi
1117 if test x$enable_gcov = xyes; then
1118         echo "NOTE: building with coverage profiling is definitely for developers only."
1119 fi
1120 if test x$enable_verbose_mode = xyes; then
1121         echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance."
1122 fi
1123 if test x$enable_asserts = xyes; then
1124         echo "NOTE: building with assertions increases library size and decreases performance."
1125 fi
1126 if test x$enable_checks = xno; then
1127         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."
1128 fi