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