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