2003-01-18 Havoc Pennington <hp@pobox.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.2)
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
31 dnl DBUS_BUILD_TESTS controls unit tests built in to .c files 
32 dnl and also some stuff in the test/ subdir
33 AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
34 if test x$enable_tests = xyes; then
35     AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
36 fi
37
38 changequote(,)dnl
39 if test "x$GCC" = "xyes"; then
40   case " $CFLAGS " in
41   *[\ \ ]-Wall[\ \      ]*) ;;
42   *) CFLAGS="$CFLAGS -Wall" ;;
43   esac
44
45   case " $CFLAGS " in
46   *[\ \ ]-Wchar-subscripts[\ \  ]*) ;;
47   *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
48   esac
49
50   case " $CFLAGS " in
51   *[\ \ ]-Wmissing-declarations[\ \     ]*) ;;
52   *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
53   esac
54
55   case " $CFLAGS " in
56   *[\ \ ]-Wmissing-prototypes[\ \       ]*) ;;
57   *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
58   esac
59
60   case " $CFLAGS " in
61   *[\ \ ]-Wnested-externs[\ \   ]*) ;;
62   *) CFLAGS="$CFLAGS -Wnested-externs" ;;
63   esac
64
65   case " $CFLAGS " in
66   *[\ \ ]-Wpointer-arith[\ \    ]*) ;;
67   *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
68   esac
69
70   case " $CFLAGS " in
71   *[\ \ ]-Wcast-align[\ \       ]*) ;;
72   *) CFLAGS="$CFLAGS -Wcast-align" ;;
73   esac
74
75   case " $CFLAGS " in
76   *[\ \ ]-Wsign-compare[\ \     ]*) ;;
77   *) CFLAGS="$CFLAGS -Wsign-compare" ;;
78   esac
79
80   if test "x$enable_ansi" = "xyes"; then
81     case " $CFLAGS " in
82     *[\ \       ]-ansi[\ \      ]*) ;;
83     *) CFLAGS="$CFLAGS -ansi" ;;
84     esac
85
86     case " $CFLAGS " in
87     *[\ \       ]-pedantic[\ \  ]*) ;;
88     *) CFLAGS="$CFLAGS -pedantic" ;;
89     esac
90   fi
91 fi
92 changequote([,])dnl
93
94 AC_CHECK_SIZEOF(char)
95 AC_CHECK_SIZEOF(short)
96 AC_CHECK_SIZEOF(long)
97 AC_CHECK_SIZEOF(int)
98 AC_CHECK_SIZEOF(void *)
99 AC_CHECK_SIZEOF(long long)
100 AC_CHECK_SIZEOF(__int64)
101
102 ## byte order
103 AC_C_BIGENDIAN
104
105 AC_CHECK_FUNCS(vsnprintf vasprintf getpwnam_r nanosleep usleep poll)
106
107 dnl check for writev header and writev function so we're 
108 dnl good to go if HAVE_WRITEV gets defined.
109 AC_CHECK_HEADERS(sys/uio.h, [AC_CHECK_FUNCS(writev)])
110
111 DBUS_CLIENT_CFLAGS=
112 DBUS_CLIENT_LIBS=
113 AC_SUBST(DBUS_CLIENT_CFLAGS)
114 AC_SUBST(DBUS_CLIENT_LIBS)
115
116 DBUS_BUS_CFLAGS=
117 DBUS_BUS_LIBS=
118 AC_SUBST(DBUS_BUS_CFLAGS)
119 AC_SUBST(DBUS_BUS_LIBS)
120
121 DBUS_TEST_CFLAGS=
122 DBUS_TEST_LIBS=
123 AC_SUBST(DBUS_TEST_CFLAGS)
124 AC_SUBST(DBUS_TEST_LIBS)
125
126 # Glib detection
127 PKG_CHECK_MODULES(DBUS_GLIB, glib-2.0, have_glib=yes, have_glib=no)
128
129 if test x$have_glib = xno ; then
130     AC_MSG_WARN([GLib development libraries not found])
131 fi
132
133 if test x$enable_glib = xyes; then
134     if test x$have_glib = xno; then
135         AC_MSG_ERROR([GLib explicitly required, and GLib development libraries not found])
136     fi
137 fi
138
139 if test x$enable_glib = xno; then
140    have_glib=no;
141 fi
142
143 AM_CONDITIONAL(HAVE_GLIB, test x$have_glib = xyes)
144
145 dnl GLib flags
146 AC_SUBST(DBUS_GLIB_CFLAGS)
147 AC_SUBST(DBUS_GLIB_LIBS)
148
149 # Qt detection
150 have_qt=no
151 if test -n "$QTDIR" -a -f $QTDIR/include/qglobal.h; then
152     have_qt=yes
153     DBUS_QT_CXXFLAGS=-I$QTDIR/include
154 fi
155
156 dnl linking to kdecore will give us a bit of help from libtool
157 kdelibs=`kde-config --install lib --expandvars 2>/dev/null`
158 if test -z $kdelibs -a -f $kdelibs/libkdecore.la; then
159     have_qt=no
160 else
161     DBUS_QT_LIBS=$kdelibs/libkdecore.la
162 fi
163
164 if test x$have_qt = xno ; then
165     AC_MSG_WARN([Qt development libraries not found])
166 fi
167
168 if test x$enable_qt = xyes; then
169     if test x$have_qt = xno; then
170         AC_MSG_ERROR([Qt integration explicitly required, and Qt libraries not found])
171     fi
172 fi
173
174 if test x$enable_qt = xno; then
175    have_qt=no;
176 fi
177
178 AM_CONDITIONAL(HAVE_QT, test x$have_qt = xyes)
179
180 dnl Qt flags
181 AC_SUBST(DBUS_QT_CXXFLAGS)
182 AC_SUBST(DBUS_QT_LIBS)
183
184 AC_OUTPUT([
185 Makefile
186 Doxyfile
187 dbus/Makefile
188 glib/Makefile
189 qt/Makefile
190 bus/Makefile
191 test/Makefile
192 doc/Makefile
193 dbus-1.0.pc
194 dbus-glib-1.0.pc
195 ])
196
197 dnl ==========================================================================
198 echo "
199                     D-BUS $VERSION
200                   ==============
201
202         prefix:                 ${prefix}
203         source code location:   ${srcdir}
204         compiler:               ${CC}
205
206         Maintainer mode:        ${USE_MAINTAINER_MODE}
207         Building unit tests:    ${enable_tests}
208         Building Qt bindings:   ${have_qt}
209         Building GLib bindings: ${have_glib}
210 "
211
212 if test x$enable_tests = xyes; then
213         echo "NOTE: building with unit tests increases the size of the installed library"
214 fi