2006-05-26 Mikael Hallendal <micke@imendio.com>
[jelmer/loudmouth.git] / configure.ac
1 AC_INIT(Loudmouth, 1.1.1, loudmouth)
2 AC_PREREQ(2.59)
3 AC_COPYRIGHT([Copyright (C) 2003-2006 Imendio AB])
4
5 AC_CONFIG_SRCDIR(loudmouth/loudmouth.h)
6 AM_CONFIG_HEADER(config.h)
7 AM_INIT_AUTOMAKE(1.9 dist-bzip2 no-define)
8
9 AM_MAINTAINER_MODE
10
11 AC_CANONICAL_HOST
12
13 os_win32=no
14
15 case "$host_os" in
16   *mingw32*)
17     os_win32=yes
18 esac
19
20 if test "$os_win32" = "yes"; then
21   if test "$enable_static" = "yes" -o "$enable_static" = ""; then
22     AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
23     enable_static=no
24   fi
25
26   if test "$enable_shared" = "no"; then
27     AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
28   fi
29
30   enable_shared=yes
31
32   CFLAGS="$CFLAGS -mms-bitfields"
33   LDFLAGS="$LDFLAGS -no-undefined"
34 fi
35
36 AC_PROG_CC
37 AC_ISC_POSIX
38 AC_HEADER_STDC
39 AC_LIBTOOL_WIN32_DLL
40 AM_PROG_LIBTOOL
41
42 AM_PATH_GLIB_2_0
43
44 AC_CHECK_HEADERS([arpa/inet.h fcntl.h memory.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) 
45 AC_CHECK_HEADERS([winsock2.h])
46
47 if test "$ac_cv_header_winsock2_h" = "yes"; then
48   # If we have <winsock2.h>, assume we find the functions
49   # in -lws2_32 (ws2_32 is winsock v2, wsock32 is v1.1)
50   LIBS="-lws2_32 -lgdi32 $LIBS"
51 fi
52
53 IDT_COMPILE_WARNINGS
54
55 changequote(,)dnl
56 if test "x$GCC" = "xyes"; then
57   case " $CFLAGS " in
58   *[\ \ ]-Wall[\ \      ]*) ;;
59   *) CFLAGS="$CFLAGS -Wall" ;;
60   esac
61 fi
62 changequote([,])dnl
63
64 AC_SUBST(CFLAGS)
65 AC_SUBST(LDFLAGS)
66
67 GLIB2_REQUIRED=2.4.0
68 GNUTLS_REQUIRED=1.0.0
69 LIBTASN1_REQUIRED=0.2.6
70
71 AC_SUBST(GLIB2_REQUIRED)
72 AC_SUBST(GNUTLS_REQUIRED)
73 AC_SUBST(LIBTASN1_REQUIRED)
74
75 LM_CHECK_TIMEZONE
76
77 PKG_CHECK_MODULES(LOUDMOUTH, glib-2.0 >= $GLIB2_REQUIRED)
78
79 # Check Unit test framework (defined in acinclude.m4)
80 IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)
81
82 AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
83
84 dnl Gtk doc
85 GTK_DOC_CHECK(1.0)
86
87 dnl define a MAINT-like variable REBUILD which is set if Perl
88 dnl and awk are found, so autogenerated sources can be rebuilt
89 AC_ARG_ENABLE(rebuilds,
90               AS_HELP_STRING([--enable-rebuilds=@<:@no/yes/auto@:>@],
91                              [Enable source autogeneration rules [[default=yes]]]), ,
92               enable_rebuilds=yes)
93
94 REBUILD=\#
95 if test "x$enable_rebuilds" = "xyes" && \
96      test -n "$PERL" && \
97      $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
98      test -n "$AWK" ; then
99   REBUILD=
100 fi
101 AC_SUBST(REBUILD)
102
103
104 dnl +--------------------------------------------------------+
105 dnl | Checking for libnsl and libsocket need on some systems |-
106 dnl +--------------------------------------------------------+
107 AC_CHECK_LIB(nsl,gethostbyname)
108 AC_CHECK_LIB(socket,socket)
109
110 dnl +--------------------------------------------------------+
111 dnl | Checking for SSL support                               |-
112 dnl +--------------------------------------------------------+
113 AC_ARG_WITH(ssl,
114             AS_HELP_STRING([--with-ssl=@<:@gnutls|openssl|no@:>@], 
115                            [Which SSL implementation to use [[default=gnutls]]]),
116             ac_ssl=$withval,
117             ac_ssl=gnutls)
118
119 AC_ARG_WITH(openssl-includes,
120             AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
121             [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
122             )
123
124 AC_ARG_WITH(openssl-libs,
125             AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
126             [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
127             )
128
129 enable_ssl=no
130 if test "x$ac_ssl" = "xgnutls"; then
131   dnl Look for GnuTLS
132   AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
133   if test "x$have_libgnutls" = "xyes"; then
134     CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
135     LIBS="$LIBS $LIBGNUTLS_LIBS"
136     AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
137     enable_ssl=GnuTLS
138   else
139     AC_MSG_ERROR([GnuTLS was not found, use
140                 --with-ssl=[[no|openssl]] to build without SSL support or
141                 with OpenSSL])
142   fi
143 elif test "$ac_ssl" = "openssl"; then
144   dnl Look for OpenSSL
145   AC_CHECK_HEADERS([openssl/ssl.h])
146   OLDLIBS="$LIBS"
147   AC_CHECK_LIB(crypto, 
148                BIO_f_base64, 
149                [AC_CHECK_LIB(ssl, 
150                              SSL_new, 
151                              [SSL_LIB="-lssl -lcrypto"
152                              AC_DEFINE(HAVE_OPENSSL, 
153                                        [], 
154                                        [Have OpenSSL])], 
155                              [have_openssl=no], 
156                              [-lcrypto])], 
157                [have_openssl=no], 
158                [])
159
160   if test "x$have_openssl" = "xno"; then
161     AC_MSG_ERROR([OpenSSL was not found, use --with-ssl=[[no|gnutls]] to
162                   build without SSL support or with GnuTLS])
163   else 
164     LIBS="$OLDLIBS $SSL_LIB"
165     enable_ssl=OpenSSL
166   fi
167 else
168         echo "Disabling SSL support"
169 fi
170
171 if test x$enable_ssl != xno; then
172         AC_DEFINE(HAVE_SSL, 1, [whether to use SSL support.])
173 else
174         if test x$ac_ssl != xno; then
175                 AC_MSG_ERROR([No SSL implementation was found, if you do not want to build with SSL use --with-ssl=no])
176         fi
177 fi
178
179 AM_CONDITIONAL(USE_OPENSSL, test x$enable_ssl = xOpenSSL)
180 AM_CONDITIONAL(USE_GNUTLS, test x$enable_ssl = xGnuTLS)
181
182 dnl +-------------+
183 dnl | Build Flags |--------------------------------------------
184 dnl +-------------+
185 DOC_CFLAGS="$CFLAGS"
186 CFLAGS="$CFLAGS $WARN_CFLAGS"
187 AC_SUBST(DOC_CFLAGS)
188 AC_SUBST(CFLAGS)
189 AC_SUBST(CPPFLAGS)
190 AC_SUBST(LDFLAGS)
191 dnl -----------------------------------------------------------
192
193 dnl +--------------+
194 dnl | Debug output |-------------------------------------------
195 dnl +--------------+
196
197 AC_ARG_ENABLE(debug,
198               AS_HELP_STRING([--enable-debug=@<:@no/yes/auto@:>@],
199                              [Enable debugging [[default=yes]]]), ,
200               enable_debug=yes)
201
202 if test x$enable_debug = xno ; then
203         echo "Debugging disabled"
204         LOUDMOUTH_CFLAGS="$LOUDMOUTH_CFLAGS -DLM_NO_DEBUG"
205 else
206         echo "Debugging enabled"
207 fi
208
209 AC_SUBST(LOUDMOUTH_CFLAGS)
210 AC_SUBST(LOUDMOUTH_LIBS)
211
212
213 dnl +--------------------------------------+
214 dnl | Check if we shoudl build C# bindings |-------------------
215 dnl +--------------------------------------+
216
217 dnl  --------------
218 dnl | mono setup |--------------------------------------------
219 dnl  --------------
220 dnl AC_ARG_ENABLE(mono, [  --enable-mono        build mono bindings [default=auto]], enable_mono="$enableval", enable_mono=auto)
221                                                                                 
222 dnl if test "x$enable_mono" != "xno"; then
223 dnl     PKG_CHECK_MODULES(,gtk-sharp,have_mono=yes,have_mono=no)
224
225 dnl     if test "x$have_mono" = "xyes"; then
226 dnl         AC_PATH_PROG(MCS, mcs, no)
227 dnl         AC_PATH_PROG(MONO, mono, no)
228 dnl     fi
229 dnl else
230 dnl      have_mono=no
231 dnl fi
232                                                                                 
233 dnl if test "x$enable_mono" = "xyes"; then
234 dnl    AC_MSG_CHECKING(for mono environment)
235 dnl    if test "x$have_mono" = "xno"; then
236 dnl        AC_MSG_ERROR([not found])
237 dnl    fi
238 dnl fi
239                                                                                 
240 dnl AM_CONDITIONAL(HAVE_MONO, test x$have_mono = xyes)
241
242 AC_OUTPUT([
243 Makefile
244 docs/Makefile
245 docs/reference/Makefile
246 loudmouth/Makefile
247 examples/Makefile
248 tests/Makefile
249 loudmouth-1.0.pc
250 loudmouth.spec])
251
252 dnl ==========================================================================
253 echo "
254
255         Loudmouth $VERSION from Imendio AB
256         =====================================
257
258         prefix:                   ${prefix}
259         compiler:                 ${CC}
260         Enable SSL                ${enable_ssl}
261         Enable Debug:             ${enable_debug}
262         Enable Unit Tests:        ${have_check}
263         Enable Documentation      ${enable_gtk_doc}
264         
265         Now type 'make' to build Loudmouth
266 "
267