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 if test "x$GCC" = "xyes"; then
53 *[\ \ ]-Wall[\ \ ]*) ;;
54 *) CFLAGS="$CFLAGS -Wall" ;;
58 *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
59 *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
63 *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
64 *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
68 *[\ \ ]-Wmissing-prototypes[\ \ ]*) ;;
69 *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
73 *[\ \ ]-Wnested-externs[\ \ ]*) ;;
74 *) CFLAGS="$CFLAGS -Wnested-externs" ;;
78 *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
79 *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
83 *[\ \ ]-Wcast-align[\ \ ]*) ;;
84 *) CFLAGS="$CFLAGS -Wcast-align" ;;
88 *[\ \ ]-Wsign-compare[\ \ ]*) ;;
89 *) CFLAGS="$CFLAGS -Wsign-compare" ;;
92 if test "x$enable_ansi" = "xyes"; then
94 *[\ \ ]-ansi[\ \ ]*) ;;
95 *) CFLAGS="$CFLAGS -ansi" ;;
99 *[\ \ ]-pedantic[\ \ ]*) ;;
100 *) CFLAGS="$CFLAGS -pedantic" ;;
103 if test x$enable_gcov = xyes; then
105 *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
106 *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
109 *[\ \ ]-ftest-coverage[\ \ ]*) ;;
110 *) CFLAGS="$CFLAGS -ftest-coverage" ;;
113 ## remove optimization
114 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
118 if test x$enable_gcov = xyes; then
119 AC_MSG_ERROR([--enable-gcov can only be used with gcc])
123 AC_CHECK_SIZEOF(char)
124 AC_CHECK_SIZEOF(short)
125 AC_CHECK_SIZEOF(long)
127 AC_CHECK_SIZEOF(void *)
128 AC_CHECK_SIZEOF(long long)
129 AC_CHECK_SIZEOF(__int64)
134 AC_CHECK_LIB(socket,socket)
135 AC_CHECK_LIB(nsl,gethostbyname)
137 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv socketpair getgrouplist)
139 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
141 AC_CACHE_CHECK([for posix getpwnam_r],
142 ac_cv_func_posix_getpwnam_r,
148 struct passwd pwd, *pwptr = &pwd;
151 error = getpwnam_r ("", &pwd, buffer,
152 sizeof (buffer), &pwptr);
153 return (error < 0 && errno == ENOSYS)
156 [ac_cv_func_posix_getpwnam_r=yes],
157 [ac_cv_func_posix_getpwnam_r=no])])
158 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
159 AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
160 [Have POSIX function getpwnam_r])
162 AC_CACHE_CHECK([for nonposix getpwnam_r],
163 ac_cv_func_nonposix_getpwnam_r,
164 [AC_TRY_LINK([#include <pwd.h>],
167 getpwnam_r ("", &pwd, buffer,
169 [ac_cv_func_nonposix_getpwnam_r=yes],
170 [ac_cv_func_nonposix_getpwnam_r=no])])
171 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
172 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
173 [Have non-POSIX function getpwnam_r])
177 dnl check for writev header and writev function so we're
178 dnl good to go if HAVE_WRITEV gets defined.
179 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
181 dnl check for flavours of varargs macros (test from GLib)
182 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
184 int a(int p1, int p2, int p3);
185 #define call_a(...) a(1,__VA_ARGS__)
187 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
188 AC_MSG_RESULT($dbus_have_iso_c_varargs)
190 AC_MSG_CHECKING(for GNUC varargs macros)
192 int a(int p1, int p2, int p3);
193 #define call_a(params...) a(1,params)
195 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
196 AC_MSG_RESULT($dbus_have_gnuc_varargs)
198 dnl Output varargs tests
199 if test x$dbus_have_iso_c_varargs = xyes; then
200 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
202 if test x$dbus_have_gnuc_varargs = xyes; then
203 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
206 dnl Check for various credentials.
207 AC_MSG_CHECKING(for struct cmsgcred)
209 #include <sys/types.h>
210 #include <sys/socket.h>
212 struct cmsgcred cred;
215 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
216 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
218 if test x$dbus_have_struct_cmsgcred = xyes; then
219 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
223 #### Sort out XML library
226 AC_CHECK_LIB(expat, XML_ParserCreate_MM,
227 [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ],
230 PKG_CHECK_MODULES(LIBXML, libxml-2.0, have_libxml=true, have_libxml=false)
232 # see what we want to use
233 dbus_use_libxml=false
235 if test x$with_xml = xexpat; then
237 if ! $have_expat ; then
238 AC_MSG_ERROR([Explicitly requested expat but expat not found])
240 elif test x$with_xml = xlibxml; then
242 if ! $have_libxml ; then
243 AC_MSG_ERROR([Explicitly requested libxml but libxml not found])
246 ### expat is the default because libxml can't currently survive
247 ### our brutal OOM-handling unit test setup.
248 ### http://bugzilla.gnome.org/show_bug.cgi?id=109368
249 if $have_expat ; then
252 elif $have_libxml ; then
256 AC_MSG_ERROR([No XML library found, check config.log for failed attempts])
260 AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat)
261 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
263 if $dbus_use_expat; then
267 if $dbus_use_libxml; then
268 XML_LIBS=$LIBXML_LIBS
269 XML_CFLAGS=$LIBXML_CFLAGS
272 #### Set up final flags
275 AC_SUBST(DBUS_CLIENT_CFLAGS)
276 AC_SUBST(DBUS_CLIENT_LIBS)
278 DBUS_BUS_CFLAGS=$XML_CFLAGS
279 DBUS_BUS_LIBS=$XML_LIBS
280 AC_SUBST(DBUS_BUS_CFLAGS)
281 AC_SUBST(DBUS_BUS_LIBS)
285 AC_SUBST(DBUS_TEST_CFLAGS)
286 AC_SUBST(DBUS_TEST_LIBS)
289 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
290 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
292 if test x$have_glib = xno ; then
293 AC_MSG_WARN([GLib development libraries not found])
296 if test x$enable_glib = xyes; then
297 if test x$have_glib = xno; then
298 AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
302 if test x$enable_glib = xno; then
306 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
307 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
310 AC_SUBST(DBUS_GLIB_CFLAGS)
311 AC_SUBST(DBUS_GLIB_LIBS)
312 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
316 if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
318 DBUS_QT_CXXFLAGS=-I$QTDIR/include
321 dnl linking to kdecore will give us a bit of help from libtool
322 if (! kde-config >& /dev/null); then
325 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
326 if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
329 DBUS_QT_LIBS=$kdelibs/libkdecore.la
333 if test x$have_qt = xno ; then
334 AC_MSG_WARN([Qt development libraries not found])
337 if test x$enable_qt = xyes; then
338 if test x$have_qt = xno; then
339 AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
343 if test x$enable_qt = xno; then
347 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
350 AC_SUBST(DBUS_QT_CXXFLAGS)
351 AC_SUBST(DBUS_QT_LIBS)
366 dnl ==========================================================================
372 source code location: ${srcdir}
376 Maintainer mode: ${USE_MAINTAINER_MODE}
377 gcc coverage profiling: ${enable_gcov}
378 Building unit tests: ${enable_tests}
379 Building verbose mode: ${enable_verbose_mode}
380 Building assertions: ${enable_asserts}
381 Building Qt bindings: ${have_qt}
382 Building GLib bindings: ${have_glib}
383 Using XML parser: ${with_xml}
386 if test x$enable_tests = xyes; then
387 echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure"
389 if test x$enable_gcov = xyes; then
390 echo "NOTE: building with coverage profiling is definitely for developers only"
392 if test x$enable_verbose_mode = xyes; then
393 echo "NOTE: building with verbose mode increases library size and may slightly increase security risk, but aids debugging."
395 if test x$enable_asserts = xyes; then
396 echo "NOTE: building with assertions increases library size, but is probably a good idea anyway."