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