2003-03-25 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 AM_INIT_AUTOMAKE(dbus, 0.6)
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 AM_PROG_LIBTOOL
25
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)
33
34 AC_ARG_WITH(xml, [  --with-xml=[libxml] XML library to use])
35
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])
41 fi
42
43 if test x$enable_verbose_mode = xyes; then
44     AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
45 fi
46 if test x$enable_asserts = xno; then
47     AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
48 fi
49
50 dbus_use_libxml=false
51 dbus_use_fooxml=false
52 if test x$with_xml = xfooxml; then
53         dbus_use_fooxml=true
54 elif test x$with_xml = xlibxml; then
55         dbus_use_libxml=true
56 else
57         with_xml=libxml
58         dbus_use_libxml=true   
59 fi
60
61 AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml)
62 if $dbus_use_libxml; then
63         PKG_CHECK_MODULES(LIBXML, libxml-2.0)
64 fi
65 AM_CONDITIONAL(DBUS_USE_FOOXML, $dbus_use_fooxml)
66
67 if test "x$GCC" = "xyes"; then
68   changequote(,)dnl
69   case " $CFLAGS " in
70   *[\ \ ]-Wall[\ \      ]*) ;;
71   *) CFLAGS="$CFLAGS -Wall" ;;
72   esac
73
74   case " $CFLAGS " in
75   *[\ \ ]-Wchar-subscripts[\ \  ]*) ;;
76   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
77   esac
78
79   case " $CFLAGS " in
80   *[\ \ ]-Wmissing-declarations[\ \     ]*) ;;
81   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
82   esac
83
84   case " $CFLAGS " in
85   *[\ \ ]-Wmissing-prototypes[\ \       ]*) ;;
86   *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
87   esac
88
89   case " $CFLAGS " in
90   *[\ \ ]-Wnested-externs[\ \   ]*) ;;
91   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
92   esac
93
94   case " $CFLAGS " in
95   *[\ \ ]-Wpointer-arith[\ \    ]*) ;;
96   *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
97   esac
98
99   case " $CFLAGS " in
100   *[\ \ ]-Wcast-align[\ \       ]*) ;;
101   *) CFLAGS="$CFLAGS -Wcast-align" ;;
102   esac
103
104   case " $CFLAGS " in
105   *[\ \ ]-Wsign-compare[\ \     ]*) ;;
106   *) CFLAGS="$CFLAGS -Wsign-compare" ;;
107   esac
108
109   if test "x$enable_ansi" = "xyes"; then
110     case " $CFLAGS " in
111     *[\ \       ]-ansi[\ \      ]*) ;;
112     *) CFLAGS="$CFLAGS -ansi" ;;
113     esac
114
115     case " $CFLAGS " in
116     *[\ \       ]-pedantic[\ \  ]*) ;;
117     *) CFLAGS="$CFLAGS -pedantic" ;;
118     esac
119   fi
120   if test x$enable_gcov = xyes; then
121     case " $CFLAGS " in
122     *[\ \       ]-fprofile-arcs[\ \     ]*) ;;
123     *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
124     esac
125     case " $CFLAGS " in
126     *[\ \       ]-ftest-coverage[\ \    ]*) ;;
127     *) CFLAGS="$CFLAGS -ftest-coverage" ;;
128     esac
129
130     ## remove optimization
131     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
132   fi
133   changequote([,])dnl
134 else
135   if test x$enable_gcov = xyes; then
136     AC_MSG_ERROR([--enable-gcov can only be used with gcc])
137   fi
138 fi
139
140
141
142 AC_CHECK_SIZEOF(char)
143 AC_CHECK_SIZEOF(short)
144 AC_CHECK_SIZEOF(long)
145 AC_CHECK_SIZEOF(int)
146 AC_CHECK_SIZEOF(void *)
147 AC_CHECK_SIZEOF(long long)
148 AC_CHECK_SIZEOF(__int64)
149
150 ## byte order
151 AC_C_BIGENDIAN
152
153 AC_CHECK_LIB(socket,socket)
154 AC_CHECK_LIB(nsl,gethostbyname)
155
156 AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep poll setenv socketpair getgrouplist)
157
158 AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)])
159
160 AC_CACHE_CHECK([for posix getpwnam_r],
161                 ac_cv_func_posix_getpwnam_r,
162                 [AC_TRY_RUN([
163 #include <errno.h>
164 #include <pwd.h>
165 int main () { 
166     char buffer[10000];
167     struct passwd pwd, *pwptr = &pwd;
168     int error;
169     errno = 0;
170     error = getpwnam_r ("", &pwd, buffer, 
171                         sizeof (buffer), &pwptr);
172    return (error < 0 && errno == ENOSYS) 
173            || error == ENOSYS; 
174 }               ],
175         [ac_cv_func_posix_getpwnam_r=yes],
176         [ac_cv_func_posix_getpwnam_r=no])])
177 if test "$ac_cv_func_posix_getpwnam_r" = yes; then
178         AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1,
179                 [Have POSIX function getpwnam_r])
180 else
181         AC_CACHE_CHECK([for nonposix getpwnam_r],
182                 ac_cv_func_nonposix_getpwnam_r,
183                 [AC_TRY_LINK([#include <pwd.h>],
184                         [char buffer[10000];
185                         struct passwd pwd;
186                         getpwnam_r ("", &pwd, buffer, 
187                                         sizeof (buffer));],
188                         [ac_cv_func_nonposix_getpwnam_r=yes],
189                         [ac_cv_func_nonposix_getpwnam_r=no])])
190                 if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then
191                 AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1,
192                         [Have non-POSIX function getpwnam_r])
193         fi
194 fi
195
196 dnl check for writev header and writev function so we're 
197 dnl good to go if HAVE_WRITEV gets defined.
198 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
199
200 dnl check for flavours of varargs macros (test from GLib)
201 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
202 AC_TRY_COMPILE([],[
203 int a(int p1, int p2, int p3);
204 #define call_a(...) a(1,__VA_ARGS__)
205 call_a(2,3);
206 ],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no)
207 AC_MSG_RESULT($dbus_have_iso_c_varargs)
208
209 AC_MSG_CHECKING(for GNUC varargs macros)
210 AC_TRY_COMPILE([],[
211 int a(int p1, int p2, int p3);
212 #define call_a(params...) a(1,params)
213 call_a(2,3);
214 ],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no)
215 AC_MSG_RESULT($dbus_have_gnuc_varargs)
216
217 dnl Output varargs tests
218 if test x$dbus_have_iso_c_varargs = xyes; then
219     AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros])
220 fi
221 if test x$dbus_have_gnuc_varargs = xyes; then
222     AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros])
223 fi
224
225 dnl Check for various credentials.
226 AC_MSG_CHECKING(for struct cmsgcred)
227 AC_TRY_COMPILE([
228 #include <sys/types.h>
229 #include <sys/socket.h>
230 ],[
231 struct cmsgcred cred;
232
233 cred.cmcred_pid = 0;
234 ],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no)
235 AC_MSG_RESULT($dbus_have_struct_cmsgcred)
236
237 if test x$dbus_have_struct_cmsgcred = xyes; then
238     AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure])
239 fi
240
241 DBUS_CLIENT_CFLAGS=
242 DBUS_CLIENT_LIBS=
243 AC_SUBST(DBUS_CLIENT_CFLAGS)
244 AC_SUBST(DBUS_CLIENT_LIBS)
245
246 DBUS_BUS_CFLAGS=$LIBXML_CFLAGS
247 DBUS_BUS_LIBS=$LIBXML_LIBS
248 AC_SUBST(DBUS_BUS_CFLAGS)
249 AC_SUBST(DBUS_BUS_LIBS)
250
251 DBUS_TEST_CFLAGS=
252 DBUS_TEST_LIBS=
253 AC_SUBST(DBUS_TEST_CFLAGS)
254 AC_SUBST(DBUS_TEST_LIBS)
255
256 # Glib detection
257 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
258 PKG_CHECK_MODULES(DBUS_GLIB_THREADS, glib-2.0 gthread-2.0, have_glib_threads=yes, have_glib_threads=no)
259
260 if test x$have_glib = xno ; then
261     AC_MSG_WARN([GLib development libraries not found])
262 fi
263
264 if test x$enable_glib = xyes; then
265     if test x$have_glib = xno; then
266         AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
267     fi
268 fi
269
270 if test x$enable_glib = xno; then
271    have_glib=no;
272 fi
273
274 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
275 AM_CONDITIONAL(HAVE_GLIB_THREADS, test x$have_glib_threads = xyes)
276
277 dnl GLib flags
278 AC_SUBST(DBUS_GLIB_CFLAGS)
279 AC_SUBST(DBUS_GLIB_LIBS)
280 AC_SUBST(DBUS_GLIB_THREADS_LIBS)
281
282 # Qt detection
283 have_qt=no
284 if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
285     have_qt=yes
286     DBUS_QT_CXXFLAGS=-I$QTDIR/include
287 fi
288
289 dnl linking to kdecore will give us a bit of help from libtool
290 if (! kde-config >& /dev/null); then
291     have_qt=no
292 else
293     kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
294     if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
295         have_qt=no
296     else
297         DBUS_QT_LIBS=$kdelibs/libkdecore.la
298     fi
299 fi
300
301 if test x$have_qt = xno ; then
302     AC_MSG_WARN([Qt development libraries not found])
303 fi
304
305 if test x$enable_qt = xyes; then
306     if test x$have_qt = xno; then
307         AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
308     fi
309 fi
310
311 if test x$enable_qt = xno; then
312    have_qt=no;
313 fi
314
315 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
316
317 dnl Qt flags
318 AC_SUBST(DBUS_QT_CXXFLAGS)
319 AC_SUBST(DBUS_QT_LIBS)
320
321 AC_OUTPUT([
322 Makefile
323 Doxyfile
324 dbus/Makefile
325 glib/Makefile
326 qt/Makefile
327 bus/Makefile
328 test/Makefile
329 doc/Makefile
330 dbus-1.0.pc
331 dbus-glib-1.0.pc
332 ])
333
334 dnl ==========================================================================
335 echo "
336                     D-BUS $VERSION
337                   ==============
338
339         prefix:                 ${prefix}
340         source code location:   ${srcdir}
341         compiler:               ${CC}
342         cflags:                 ${CFLAGS}
343
344         Maintainer mode:        ${USE_MAINTAINER_MODE}
345         gcc coverage profiling: ${enable_gcov}
346         Building unit tests:    ${enable_tests}
347         Building verbose mode:  ${enable_verbose_mode}
348         Building assertions:    ${enable_asserts}
349         Building Qt bindings:   ${have_qt}
350         Building GLib bindings: ${have_glib}
351         Using XML parser:       ${with_xml}
352 "
353
354 if test x$enable_tests = xyes; then
355         echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure"
356 fi
357 if test x$enable_gcov = xyes; then
358         echo "NOTE: building with coverage profiling is definitely for developers only"
359 fi
360 if test x$enable_verbose_mode = xyes; then
361         echo "NOTE: building with verbose mode increases library size and may slightly increase security risk, but aids debugging."
362 fi
363 if test x$enable_asserts = xyes; then
364         echo "NOTE: building with assertions increases library size, but is probably a good idea anyway."
365 fi