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