Added .gitignore
[jelmer/loudmouth.git] / configure.ac
1 AC_INIT(Loudmouth, 1.2.0, loudmouth)
2 AC_PREREQ(2.59)
3 AC_COPYRIGHT([Copyright (C) 2003-2007 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 PKG_CHECK_MODULES(LIBIDN, libidn, have_idn=yes, have_idn=no)
80 if test "x$have_idn" = "xyes"; then
81         AC_DEFINE(HAVE_IDN, 1, [Define if IDN support is included])
82 fi
83
84 # Check Unit test framework (defined in acinclude.m4)
85 IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)
86
87 AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
88
89 dnl Gtk doc
90 GTK_DOC_CHECK(1.0)
91
92 dnl define a MAINT-like variable REBUILD which is set if Perl
93 dnl and awk are found, so autogenerated sources can be rebuilt
94 AC_ARG_ENABLE(rebuilds,
95               AS_HELP_STRING([--enable-rebuilds=@<:@no/yes/auto@:>@],
96                              [Enable source autogeneration rules [[default=yes]]]), ,
97               enable_rebuilds=yes)
98
99 REBUILD=\#
100 if test "x$enable_rebuilds" = "xyes" && \
101      test -n "$PERL" && \
102      $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
103      test -n "$AWK" ; then
104   REBUILD=
105 fi
106 AC_SUBST(REBUILD)
107
108
109 dnl +--------------------------------------------------------+
110 dnl | Checking for libnsl and libsocket need on some systems |-
111 dnl +--------------------------------------------------------+
112 AC_CHECK_LIB(nsl,gethostbyname)
113 AC_CHECK_LIB(socket,socket)
114
115 dnl +--------------------------------------------------------+
116 dnl | Checking for SSL support                               |-
117 dnl +--------------------------------------------------------+
118 AC_ARG_WITH(ssl,
119             AS_HELP_STRING([--with-ssl=@<:@gnutls|openssl|no@:>@], 
120                            [Which SSL implementation to use [[default=gnutls]]]),
121             ac_ssl=$withval,
122             ac_ssl=gnutls)
123
124 AC_ARG_WITH(openssl-includes,
125             AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
126             [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
127             )
128
129 AC_ARG_WITH(openssl-libs,
130             AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
131             [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
132             )
133
134 enable_ssl=no
135 if test "x$ac_ssl" = "xgnutls"; then
136   dnl Look for GnuTLS
137   AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
138   if test "x$have_libgnutls" = "xyes"; then
139     CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
140     LIBS="$LIBS $LIBGNUTLS_LIBS"
141     AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
142     enable_ssl=GnuTLS
143   else
144     AC_MSG_ERROR([GnuTLS was not found, use
145                 --with-ssl=[[no|openssl]] to build without SSL support or
146                 with OpenSSL])
147   fi
148 elif test "$ac_ssl" = "openssl"; then
149   dnl Look for OpenSSL
150   AC_CHECK_HEADERS([openssl/ssl.h])
151   OLDLIBS="$LIBS"
152   AC_CHECK_LIB(crypto, 
153                BIO_f_base64, 
154                [AC_CHECK_LIB(ssl, 
155                              SSL_new, 
156                              [SSL_LIB="-lssl -lcrypto"
157                              AC_DEFINE(HAVE_OPENSSL, 
158                                        [], 
159                                        [Have OpenSSL])], 
160                              [have_openssl=no], 
161                              [-lcrypto])], 
162                [have_openssl=no], 
163                [])
164
165   if test "x$have_openssl" = "xno"; then
166     AC_MSG_ERROR([OpenSSL was not found, use --with-ssl=[[no|gnutls]] to
167                   build without SSL support or with GnuTLS])
168   else 
169     LIBS="$OLDLIBS $SSL_LIB"
170     enable_ssl=OpenSSL
171   fi
172 else
173         echo "Disabling SSL support"
174 fi
175
176 if test x$enable_ssl != xno; then
177         AC_DEFINE(HAVE_SSL, 1, [whether to use SSL support.])
178 else
179         if test x$ac_ssl != xno; then
180                 AC_MSG_ERROR([No SSL implementation was found, if you do not want to build with SSL use --with-ssl=no])
181         fi
182 fi
183
184 AM_CONDITIONAL(USE_OPENSSL, test x$enable_ssl = xOpenSSL)
185 AM_CONDITIONAL(USE_GNUTLS, test x$enable_ssl = xGnuTLS)
186
187 dnl +-------------+
188 dnl | Build Flags |--------------------------------------------
189 dnl +-------------+
190 DOC_CFLAGS="$CFLAGS"
191 CFLAGS="$CFLAGS $WARN_CFLAGS"
192 AC_SUBST(DOC_CFLAGS)
193 AC_SUBST(CFLAGS)
194 AC_SUBST(CPPFLAGS)
195 AC_SUBST(LDFLAGS)
196 dnl -----------------------------------------------------------
197
198 dnl +--------------+
199 dnl | Debug output |-------------------------------------------
200 dnl +--------------+
201
202 AC_ARG_ENABLE(debug,
203               AS_HELP_STRING([--enable-debug=@<:@no/yes/auto@:>@],
204                              [Enable debugging [[default=yes]]]), ,
205               enable_debug=yes)
206
207 if test x$enable_debug = xno ; then
208         echo "Debugging disabled"
209         LOUDMOUTH_CFLAGS="$LOUDMOUTH_CFLAGS -DLM_NO_DEBUG"
210 else
211         echo "Debugging enabled"
212 fi
213
214 AC_SUBST(LOUDMOUTH_CFLAGS)
215 AC_SUBST(LOUDMOUTH_LIBS)
216
217 AC_OUTPUT([
218 Makefile
219 docs/Makefile
220 docs/reference/Makefile
221 loudmouth/Makefile
222 examples/Makefile
223 tests/Makefile
224 tests/parser-tests/Makefile
225 loudmouth-1.0.pc
226 loudmouth.spec])
227
228 dnl ==========================================================================
229 echo "
230
231         Loudmouth $VERSION from Imendio AB
232         =====================================
233
234         prefix:                   ${prefix}
235         compiler:                 ${CC}
236         Have IDN support:         ${have_idn}
237         Enable SSL                ${enable_ssl}
238         Enable Debug:             ${enable_debug}
239         Enable Unit Tests:        ${have_check}
240         Enable Documentation      ${enable_gtk_doc}
241         
242         Now type 'make' to build Loudmouth
243 "
244