* Mercilessly ripped out all of the gratuitously complex GNU libintl
[citadel.git] / webcit / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT(webserver.c)
4
5
6 PACKAGE=webcit
7 VERSION=6.40
8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
9 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
10 AC_SUBST(PACKAGE)
11 AC_SUBST(VERSION)
12 AC_SUBST(PROG_SUBDIRS)
13
14 AC_CANONICAL_HOST
15 AC_PROG_INSTALL
16 AC_CHECK_PROG(SED, sed, sed, no)
17 AC_PREFIX_DEFAULT(/usr/local/webcit)
18
19 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
20 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
21 AC_ARG_WITH(with_newt,    [  --with-newt             use newt window library])
22 AC_ARG_WITH(ssl,
23         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
24         [
25                 if test "x$withval" != "xno" ; then
26                         tryssldir=$withval
27                 fi
28         ]
29 )
30 dnl Set some system-specific variables which are OK to set before compiler
31 dnl checks:
32 PTHREAD_DEFS=-D_REENTRANT
33 case "$host" in
34         dnl Tru64 Unix requires we use -pthread instead of linking the threads
35         dnl libraries directly, and we can't build threaded programs with gcc
36         dnl due to header file problems.
37         alpha*-dec-osf*)
38                 test -z "$CC" && CC=cc
39                 LIBS=-pthread
40         ;;
41         dnl FreeBSD is similar:
42         *-*-freebsd*)
43                 LIBS=-pthread
44                 PTHREAD_DEFS=-D_THREAD_SAFE
45         ;;
46         *-*-solaris*)
47                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
48         ;;
49 esac
50 AC_SUBST(PTHREAD_DEFS)
51
52 dnl Checks for programs.
53 AC_PROG_CC
54
55 dnl Configure compiler flags for GCC
56 if test "$GCC" = yes; then
57         case "$host" in
58                 *-*-solaris*)
59                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
60                 ;;
61                 *)
62                         CFLAGS="$CFLAGS -Wall"
63                 ;;
64         esac
65 fi
66
67 dnl ### missing_dir=`cd $ac_aux_dir && pwd`
68 dnl ### AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
69
70 dnl Checks for libraries.
71 if test "$LIBS" != -pthread; then
72         AC_CHECK_LIB(pthread, pthread_create)
73         AC_CHECK_LIB(pthreads, pthread_create)
74 fi
75 AC_SEARCH_LIBS(gethostbyname, nsl)
76 AC_SEARCH_LIBS(connect, socket)
77
78 dnl Checks for header files.
79 AC_HEADER_STDC
80 dnl AC_HEADER_SYS_WAIT
81 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
82
83
84
85
86 dnl Checks for typedefs, structures, and compiler characteristics.
87 AC_C_CONST
88 AC_TYPE_OFF_T
89 AC_TYPE_SIZE_T
90 dnl AC_HEADER_TIME
91
92 dnl Checks for library functions.
93 AC_TYPE_SIGNAL
94 dnl AC_FUNC_VPRINTF
95 dnl AC_CHECK_FUNCS(strerror)
96 AC_REPLACE_FUNCS(snprintf)
97
98 dnl Checks for the libical calendaring library.
99 if test "x$with_libical" != xno ; then
100         AC_CHECK_HEADERS(ical.h,
101                 [AC_CHECK_LIB(ical, icalcomponent_new,
102                         [ok_libical=yes],,
103         )])
104 fi
105
106 if test "x$ok_libical" = xyes ; then
107
108         AC_TRY_RUN(
109                 [
110 #include <ical.h>
111 main() {
112         int major, minor, v;
113         sscanf(ICAL_VERSION, "%d.%d", &major, &minor);
114         v = 100*major + minor;
115         printf("libical version: %i\n", v);
116         if (v >= 24) {
117                 printf("This version is ok.\n");
118                 return(0);
119         }
120         printf("libical 0.24 or newer required.\n");
121         printf("Citadel will be built without calendar support.\n");
122         return(1);
123 }
124                 ], 
125                 [
126                         LIBS="-lical $LIBS"
127                         AC_DEFINE(HAVE_LIBICAL)
128                 ]
129         )
130 fi
131
132
133
134 dnl Checks for the zlib compression library.
135 if test "x$with_zlib" != xno ; then
136         AC_CHECK_HEADERS(zlib.h,
137                 [AC_CHECK_LIB(z, zlibVersion,
138                         [ok_zlib=yes],,
139         )])
140 fi
141
142 if test "x$ok_zlib" = xyes ; then
143         LIBS="-lz $LIBS"
144         AC_DEFINE(HAVE_ZLIB)
145 fi
146
147 dnl Checks for the newt window library.
148 if test "x$with_newt" != xno ; then
149         AC_CHECK_HEADERS(newt.h,
150                 [AC_CHECK_LIB(newt, newtInit,
151                         [ok_newt=yes],,
152         )])
153 fi
154
155 if test "x$ok_newt" = xyes ; then
156         SETUP_LIBS="-lnewt $SETUP_LIBS"
157         AC_DEFINE(HAVE_NEWT)
158 fi
159
160 # The big search for OpenSSL
161 if test "$with_ssl" != "no"; then
162         saved_LIBS="$LIBS"
163         saved_LDFLAGS="$LDFLAGS"
164         saved_CFLAGS="$CFLAGS"
165         if test "x$prefix" != "xNONE"; then
166                 tryssldir="$tryssldir $prefix"
167         fi
168         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
169                 for ssldir in $tryssldir "" /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
170                         CFLAGS="$saved_CFLAGS"
171                         LDFLAGS="$saved_LDFLAGS"
172                         LIBS="$saved_LIBS -lssl -lcrypto"
173         
174                         # Skip directories if they don't exist
175                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
176                                 continue;
177                         fi
178                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
179                                 # Try to use $ssldir/lib if it exists, otherwise
180                                 # $ssldir
181                                 if test -d "$ssldir/lib" ; then
182                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
183                                         if test ! -z "$need_dash_r" ; then
184                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
185                                         fi
186                                 else
187                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
188                                         if test ! -z "$need_dash_r" ; then
189                                                 LDFLAGS="-R$ssldir $LDFLAGS"
190                                         fi
191                                 fi
192                                 # Try to use $ssldir/include if it exists, otherwise
193                                 # $ssldir
194                                 if test -d "$ssldir/include" ; then
195                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
196                                 else
197                                         CFLAGS="-I$ssldir $saved_CFLAGS"
198                                 fi
199                         fi
200         
201                         # Basic test to check for compatible version and correct linking
202                         # *does not* test for RSA - that comes later.
203                         AC_TRY_RUN(
204                                 [
205         #include <string.h>
206         #include <openssl/rand.h>
207         int main(void)
208         {
209                 char a[2048];
210                 memset(a, 0, sizeof(a));
211                 RAND_add(a, sizeof(a), sizeof(a));
212                 return(RAND_status() <= 0);
213         }
214                                 ],
215                                 [
216                                         found_crypto=1
217                                         break;
218                                 ], []
219                         )
220         
221                         if test ! -z "$found_crypto" ; then
222                                 break;
223                         fi
224                 done
225         
226                 if test -z "$ssldir" ; then
227                         ssldir="(system)"
228                 fi
229         
230                 if test ! -z "$found_crypto" ; then
231                         ac_cv_openssldir=$ssldir
232                 else
233                         ac_cv_openssldir="no"
234                 fi
235         ])
236         LIBS="$saved_LIBS"
237         LDFLAGS="$saved_LDFLAGS"
238         CFLAGS="$saved_CFLAGS"
239         
240         if test "x$ac_cv_openssldir" != "xno" ; then
241                 AC_DEFINE(HAVE_OPENSSL)
242                 LIBS="-lssl -lcrypto $LIBS"
243                 dnl Need to recover ssldir - test above runs in subshell
244                 ssldir=$ac_cv_openssldir
245                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
246                         # Try to use $ssldir/lib if it exists, otherwise
247                         # $ssldir
248                         if test -d "$ssldir/lib" ; then
249                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
250                                 if test ! -z "$need_dash_r" ; then
251                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
252                                 fi
253                         else
254                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
255                                 if test ! -z "$need_dash_r" ; then
256                                         LDFLAGS="-R$ssldir $LDFLAGS"
257                                 fi
258                         fi
259                         # Try to use $ssldir/include if it exists, otherwise
260                         # $ssldir
261                         if test -d "$ssldir/include" ; then
262                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
263                         else
264                                 CFLAGS="-I$ssldir $saved_CFLAGS"
265                         fi
266                 fi
267         fi
268 fi
269
270 dnl Here is the check for a usable iconv
271
272 AC_ARG_ENABLE(iconv,
273         [  --disable-iconv         do not use iconv charset conversion],
274         ok_iconv=no, ok_iconv=yes)
275
276 if test "$ok_nls" != "no"; then
277         AC_MSG_RESULT(Checking to see if your system supports iconv...)
278         AC_TRY_RUN([
279                 #include <iconv.h>
280                 main() {
281                         iconv_t ic = (iconv_t)(-1) ;
282                         ic = iconv_open("UTF-8", "us-ascii");
283                         iconv_close(ic);
284                         exit(0);
285                 }
286         ],
287                 ok_iconv=yes,
288                 ok_iconv=no
289         )
290 fi
291
292 if test "$ok_iconv" != "no"; then
293         AC_MSG_RESULT(WebCit will be built with character set conversion.)
294         AC_DEFINE(HAVE_ICONV)
295 else
296         AC_MSG_RESULT(WebCit will be built without character set conversion.)
297 fi
298
299
300
301 dnl Here is the check for libintl etc.
302
303 AC_ARG_ENABLE(nls,
304         [  --disable-nls           do not use Native Language Support],
305         ok_nls=no, ok_nls=yes)
306
307 if test "$ok_nls" != "no"; then
308         AC_MSG_RESULT(Checking to see if your system supports multithreaded NLS...)
309         AC_TRY_RUN([
310                 #define _GNU_SOURCE
311                 #include <locale.h>
312                 #include <libintl.h>
313                 main() {
314                         char *foo;
315                         uselocale(LC_GLOBAL_LOCALE);
316                         foo = gettext("bar");
317                         exit(0);
318                 }
319         ],
320                 ok_nls=yes,
321                 ok_nls=no
322         )
323 fi
324
325 if test "$ok_nls" != "no"; then
326         AC_CHECK_PROG(ok_nls, xgettext, yes, no)
327 fi
328
329 if test "$ok_nls" != "no"; then
330         AC_CHECK_PROG(ok_nls, msgmerge, yes, no)
331 fi
332
333 if test "$ok_nls" != "no"; then
334         AC_CHECK_PROG(ok_nls, msgfmt, yes, no)
335 fi
336
337 if test "$ok_nls" != "no"; then
338         AC_MSG_RESULT(WebCit will be built with national language support.)
339         AC_DEFINE(ENABLE_NLS)
340         PROG_SUBDIRS="$PROG_SUBDIRS po"
341 else
342         AC_MSG_RESULT(WebCit will be built without national language support.)
343 fi
344
345 AC_SUBST(SETUP_LIBS)
346
347 AC_OUTPUT(Makefile po/Makefile )
348