6 AM_INIT_AUTOMAKE(dbus, 0.6)
8 AM_CONFIG_HEADER(config.h)
11 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
13 GETTEXT_PACKAGE=dbus-1
14 AC_SUBST(GETTEXT_PACKAGE)
15 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain])
17 ## must come before we use the $USE_MAINTAINER_MODE variable later
26 AC_ARG_ENABLE(qt, [ --enable-qt enable Qt-friendly client library],enable_qt=$enableval,enable_qt=auto)
27 AC_ARG_ENABLE(glib, [ --enable-glib enable GLib-friendly client library],enable_glib=$enableval,enable_glib=auto)
28 AC_ARG_ENABLE(tests, [ --enable-tests enable unit test code],enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
29 AC_ARG_ENABLE(ansi, [ --enable-ansi enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
30 AC_ARG_ENABLE(verbose-mode, [ --enable-verbose-mode support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=yes)
31 AC_ARG_ENABLE(asserts, [ --enable-asserts include assertion checks],enable_asserts=$enableval,enable_asserts=yes)
32 AC_ARG_ENABLE(gcov, [ --enable-gcov compile with coverage profiling instrumentation (gcc only)],enable_gcov=$enableval,enable_gcov=no)
34 AC_ARG_WITH(xml, [ --with-xml=[libxml/expat] XML library to use])
36 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
37 dnl and also some stuff in the test/ subdir
38 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
39 if test x$enable_tests = xyes; then
40 AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
43 if test x$enable_verbose_mode = xyes; then
44 AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
46 if test x$enable_asserts = xno; then
47 AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
50 #### gcc warning flags
52 if test "x$GCC" = "xyes"; then
55 *[\ \ ]-Wall[\ \ ]*) ;;
56 *) CFLAGS="$CFLAGS -Wall" ;;
60 *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
61 *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
65 *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
66 *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
70 *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
71 *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
75 *[\ \ ]-Wnested-externs[\ \ ]*) ;;
76 *) CFLAGS="$CFLAGS -Wnested-externs" ;;
80 *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
81 *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
85 *[\ \ ]-Wcast-align[\ \ ]*) ;;
86 *) CFLAGS="$CFLAGS -Wcast-align" ;;
90 *[\ \ ]-Wsign-compare[\ \ ]*) ;;
91 *) CFLAGS="$CFLAGS -Wsign-compare" ;;
94 if test "x$enable_ansi" = "xyes"; then
96 *[\ \ ]-ansi[\ \ ]*) ;;
97 *) CFLAGS="$CFLAGS -ansi" ;;
101 *[\ \ ]-pedantic[\ \ ]*) ;;
102 *) CFLAGS="$CFLAGS -pedantic" ;;
105 if test x$enable_gcov = xyes; then
107 *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
108 *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
111 *[\ \ ]-ftest-coverage[\ \ ]*) ;;
112 *) CFLAGS="$CFLAGS -ftest-coverage" ;;
115 ## remove optimization
116 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
120 if test x$enable_gcov = xyes; then
121 AC_MSG_ERROR([--enable-gcov can only be used with gcc])
127 AC_CHECK_SIZEOF(char)
128 AC_CHECK_SIZEOF(short)
129 AC_CHECK_SIZEOF(long)
131 AC_CHECK_SIZEOF(void *)
132 AC_CHECK_SIZEOF(long long)
133 AC_CHECK_SIZEOF(__int64)
138 AC_CHECK_LIB(socket,socket)
139 AC_CHECK_LIB(nsl,gethostbyname)
141 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv socketpair getgrouplist)
143 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
145 AC_CACHE_CHECK([for posix getpwnam_r],
146 ac_cv_func_posix_getpwnam_r,
152 struct passwd pwd, *pwptr = &pwd;
155 error = getpwnam_r ("", &pwd, buffer,
156 sizeof (buffer), &pwptr);
157 return (error < 0 && errno == ENOSYS)
160 [ac_cv_func_posix_getpwnam_r=yes],
161 [ac_cv_func_posix_getpwnam_r=no])])
162 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
163 AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
164 [Have POSIX function getpwnam_r])
166 AC_CACHE_CHECK([for nonposix getpwnam_r],
167 ac_cv_func_nonposix_getpwnam_r,
168 [AC_TRY_LINK([#include <pwd.h>],
171 getpwnam_r ("", &pwd, buffer,
173 [ac_cv_func_nonposix_getpwnam_r=yes],
174 [ac_cv_func_nonposix_getpwnam_r=no])])
175 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
176 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
177 [Have non-POSIX function getpwnam_r])
181 dnl check for writev header and writev function so we're
182 dnl good to go if HAVE_WRITEV gets defined.
183 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
185 dnl check for flavours of varargs macros (test from GLib)
186 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
188 int a(int p1, int p2, int p3);
189 #define call_a(...) a(1,__VA_ARGS__)
191 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
192 AC_MSG_RESULT($dbus_have_iso_c_varargs)
194 AC_MSG_CHECKING(for GNUC varargs macros)
196 int a(int p1, int p2, int p3);
197 #define call_a(params...) a(1,params)
199 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
200 AC_MSG_RESULT($dbus_have_gnuc_varargs)
202 dnl Output varargs tests
203 if test x$dbus_have_iso_c_varargs = xyes; then
204 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
206 if test x$dbus_have_gnuc_varargs = xyes; then
207 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
210 dnl Check for various credentials.
211 AC_MSG_CHECKING(for struct cmsgcred)
213 #include <sys/types.h>
214 #include <sys/socket.h>
216 struct cmsgcred cred;
219 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
220 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
222 if test x$dbus_have_struct_cmsgcred = xyes; then
223 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
227 #### Sort out XML library
230 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
231 [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
234 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
236 # see what we want to use
237 dbus_use_libxml=false
239 if test x$with_xml = xexpat; then
241 if ! $have_expat ; then
242 AC_MSG_ERROR([Explicitly requested expat but expat not found])
244 elif test x$with_xml = xlibxml; then
246 if ! $have_libxml ; then
247 AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
250 ### expat is the default because libxml can't currently survive
251 ### our brutal OOM-handling unit test setup.
252 ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
253 if $have_expat ; then
256 elif $have_libxml ; then
260 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
264 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
265 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
267 if $dbus_use_expat; then
271 if $dbus_use_libxml; then
272 XML_LIBS=$LIBXML_LIBS
273 XML_CFLAGS=$LIBXML_CFLAGS
276 #### Set up final flags
279 AC_SUBST(DBUS_CLIENT_CFLAGS)
280 AC_SUBST(DBUS_CLIENT_LIBS)
282 DBUS_BUS_CFLAGS=$XML_CFLAGS
283 DBUS_BUS_LIBS=$XML_LIBS
284 AC_SUBST(DBUS_BUS_CFLAGS)
285 AC_SUBST(DBUS_BUS_LIBS)
289 AC_SUBST(DBUS_TEST_CFLAGS)
290 AC_SUBST(DBUS_TEST_LIBS)
293 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
294 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
296 if test x$have_glib = xno ; then
297 AC_MSG_WARN([GLib development libraries not found])
300 if test x$enable_glib = xyes; then
301 if test x$have_glib = xno; then
302 AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
306 if test x$enable_glib = xno; then
310 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
311 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
314 AC_SUBST(DBUS_GLIB_CFLAGS)
315 AC_SUBST(DBUS_GLIB_LIBS)
316 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
320 if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
322 DBUS_QT_CXXFLAGS=-I$QTDIR/include
325 dnl linking to kdecore will give us a bit of help from libtool
326 if (! kde-config >& /dev/null); then
329 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
330 if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
333 DBUS_QT_LIBS=$kdelibs/libkdecore.la
337 if test x$have_qt = xno ; then
338 AC_MSG_WARN([Qt development libraries not found])
341 if test x$enable_qt = xyes; then
342 if test x$have_qt = xno; then
343 AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
347 if test x$enable_qt = xno; then
351 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
354 AC_SUBST(DBUS_QT_CXXFLAGS)
355 AC_SUBST(DBUS_QT_LIBS)
357 ##### Set up location for system bus socket
358 ## name of socket relative to localstatedir
359 DBUS_SYSTEM_SOCKET=run/dbus/system_bus_socket
360 AC_SUBST(DBUS_SYSTEM_SOCKET)
362 #### find the actual value for $prefix that we'll end up with
364 if test "x$prefix" = "xNONE"; then
365 REAL_PREFIX=$ac_default_prefix
370 #### Have to go $localstatedir->$prefix/var->/usr/local/var
371 #### someone please fix this a better way...
372 LOCALSTATEDIR_TMP="$localstatedir"
375 EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
377 AC_SUBST(EXPANDED_LOCALSTATEDIR)
394 dnl ==========================================================================
400 source code location: ${srcdir}
404 Maintainer mode: ${USE_MAINTAINER_MODE}
405 gcc coverage profiling: ${enable_gcov}
406 Building unit tests: ${enable_tests}
407 Building verbose mode: ${enable_verbose_mode}
408 Building assertions: ${enable_asserts}
409 Building Qt bindings: ${have_qt}
410 Building GLib bindings: ${have_glib}
411 Using XML parser: ${with_xml}
412 System bus socket: ${EXPANDED_LOCALSTATEDIR}/${DBUS_SYSTEM_SOCKET}
415 if test x$enable_tests = xyes; then
416 echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
418 if test x$enable_gcov = xyes; then
419 echo "NOTE: building with coverage profiling is definitely for developers only."
421 if test x$enable_verbose_mode = xyes; then
422 echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and may cause a slight performance decrease, but aids debugging."
424 if test x$enable_asserts = xyes; then
425 echo "NOTE: building with assertions increases library size, but will help a lot when tracking down bugs in software using D-BUS."