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