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