* Restored zlib.h support to WebCit
[citadel.git] / webcit / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT([WebCit], [7.37], [http://www.citadel.org/])
4
5
6 AC_SUBST(PROG_SUBDIRS)
7 AC_DEFINE(PROG_SUBDIRS, [], [Program dirs])
8 AC_CANONICAL_HOST
9 AC_PROG_INSTALL
10 missing_dir=`cd $ac_aux_dir && pwd`
11 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
12 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
13
14 dnl Make sure we see all GNU and Solaris extensions.
15 AC_GNU_SOURCE
16
17 AC_CHECK_PROG(SED, sed, sed, no)
18 AC_PREFIX_DEFAULT(/usr/local/webcit)
19 if test "$prefix" = NONE; then
20         AC_DEFINE_UNQUOTED(WEBCITDIR, "$ac_default_prefix", [define this to the Citadel home directory])
21         ssl_dir="$ac_default_prefix/keys"
22 else
23         AC_DEFINE_UNQUOTED(WEBCITDIR, "$prefix", [define this to the Citadel home directory])
24         ssl_dir="$prefix/keys"
25 fi
26
27 AC_ARG_WITH(ssl,
28         [  --with-ssl=PATH         Specify path to OpenSSL installation ],
29         [
30                 if test "x$withval" != "xno" ; then
31                         tryssldir=$withval
32                 fi
33         ]
34 )
35 dnl Set some system-specific variables which are OK to set before compiler
36 dnl checks:
37 PTHREAD_DEFS=-D_REENTRANT
38 case "$host" in
39         dnl Tru64 Unix requires we use -pthread instead of linking the threads
40         dnl libraries directly, and we can't build threaded programs with gcc
41         dnl due to header file problems.
42         alpha*-dec-osf*)
43                 test -z "$CC" && CC=cc
44                 LIBS=-pthread
45         ;;
46         dnl FreeBSD is similar:
47         *-*-freebsd*)
48                 LIBS=-pthread
49                 PTHREAD_DEFS=-D_THREAD_SAFE
50         ;;
51         *-*-solaris*)
52                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
53         ;;
54         *-*-darwin*)
55                 LIBS=-lintl
56 esac
57 AC_SUBST(PTHREAD_DEFS)
58
59 dnl Checks for programs.
60 AC_PROG_CC
61
62 dnl Configure compiler flags for GCC
63 if test "$GCC" = yes; then
64         case "$host" in
65                 *-*-solaris*)
66                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts --pedantic"
67                 ;;
68                 *)
69                         CFLAGS="$CFLAGS -Wall --pedantic"
70                 ;;
71         esac
72 fi
73
74 # missing_dir=`cd $ac_aux_dir && pwd`
75 # AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
76
77 dnl Checks for libraries.
78 if test "$LIBS" != -pthread; then
79         AC_CHECK_LIB(pthread, pthread_create)
80         AC_CHECK_LIB(pthreads, pthread_create)
81 fi
82 AC_SEARCH_LIBS(gethostbyname, nsl)
83 AC_SEARCH_LIBS(connect, socket)
84
85 dnl Checks for header files.
86 AC_HEADER_STDC
87 dnl AC_HEADER_SYS_WAIT
88
89
90
91
92 dnl Checks for typedefs, structures, and compiler characteristics.
93 AC_C_CONST
94 AC_TYPE_OFF_T
95 AC_TYPE_SIZE_T
96 dnl AC_HEADER_TIME
97
98 dnl Checks for library functions.
99 AC_TYPE_SIGNAL
100 dnl AC_FUNC_VPRINTF
101 AC_REPLACE_FUNCS(snprintf)
102 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h iconv.h xlocale.h)
103
104 dnl Checks for the zlib compression library.
105 if test "x$with_zlib" != xno ; then
106        AC_CHECK_HEADERS(zlib.h,
107                [AC_CHECK_LIB(z, zlibVersion,
108                        [ok_zlib=yes],,
109        )])
110 fi
111
112 if test "x$ok_zlib" = xyes ; then
113 dnl  libcitadel will bring libz, so we don't need it here.     LDFLAGS="-lz $LDFLAGS" 
114        AC_DEFINE(HAVE_ZLIB, [], [define this if you have zlib compression available])
115 fi
116
117 dnl Here is the check for a libc integrated iconv
118 AC_ARG_ENABLE(iconv,
119         [  --disable-iconv         do not use iconv charset conversion],
120         ok_iconv=no, ok_iconv=yes)
121
122 AC_MSG_CHECKING(Checking to see if your system supports iconv)
123 AC_TRY_RUN([
124         #include <iconv.h>
125         main() {
126                 iconv_t ic = (iconv_t)(-1) ;
127                 ic = iconv_open("UTF-8", "us-ascii");
128                 iconv_close(ic);
129                 exit(0);
130         }
131  ],
132                 [
133                   ok_iconv=yes
134                   AC_MSG_RESULT([yes])
135                 ],
136                 [ 
137                   ok_iconv=no
138                   AC_MSG_RESULT([no])
139                 ]
140 )
141
142 dnl Check for iconv in external libiconv
143 if test "$ok_iconv" = no; then
144         AC_MSG_CHECKING(Checking for an external libiconv)
145         OLD_LDFLAGS="$LDFLAGS"
146         LDFLAGS="$LDFLAGS -liconv"
147         AC_TRY_RUN([
148                         #include <iconv.h>
149                         main() {
150                                 iconv_t ic = (iconv_t)(-1) ;
151                                 ic = iconv_open("UTF-8", "us-ascii");
152                                 iconv_close(ic);
153                         }
154                 ],
155                         [
156                           ok_iconv=yes
157                           AC_MSG_RESULT([yes])
158                         ],
159                         [ 
160                           ok_iconv=no
161                           LDFLAGS="$OLD_LDFLAGS"
162                           AC_MSG_RESULT([no])
163                         ]
164                 )
165 fi      
166 if test "$ok_iconv" != "no"; then
167         AC_MSG_RESULT(WebCit will be built with character set conversion.)
168         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
169 else
170         AC_MSG_RESULT(WebCit will be built without character set conversion.)
171 fi
172
173 AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"])
174
175
176 dnl Checks for the libical iCalendar library.
177 AC_CHECK_HEADER(libical/ical.h,
178         [AC_CHECK_LIB(ical, icaltimezone_set_tzid_prefix,
179                 [
180                         LIBS="-lical $LIBS"
181                 ],
182                 [
183                         AC_MSG_ERROR(libical was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
184                 ]
185         ,
186         )],
187         [
188                 AC_MSG_ERROR(libical/ical.h was not found and is required.  More info: http://www.citadel.org/doku.php/installation:start)
189         ]
190 )
191
192
193 dnl Check for libcitadel
194 AC_CHECK_HEADER(libcitadel.h,
195         [AC_CHECK_LIB(citadel, libcitadel_version_string,
196                 [
197                         LIBS="-lcitadel $LIBS"
198                         SETUP_LIBS="-lcitadel $SETUP_LIBS"
199                 ],
200                 [
201                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
202                 ]
203         ,
204         )],
205         [
206                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
207         ]
208 )
209
210
211
212 found_ssl=no
213 # The big search for OpenSSL
214 if test "$with_ssl" != "no"; then
215         saved_LIBS="$LIBS"
216         saved_LDFLAGS="$LDFLAGS"
217         saved_CFLAGS="$CFLAGS"
218         if test "x$prefix" != "xNONE"; then
219                 tryssldir="$tryssldir $prefix"
220         fi
221         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
222                 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
223                         CFLAGS="$saved_CFLAGS"
224                         LDFLAGS="$saved_LDFLAGS"
225                         LIBS="$saved_LIBS -lssl -lcrypto"
226         
227                         # Skip directories if they don't exist
228                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
229                                 continue;
230                         fi
231                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
232                                 # Try to use $ssldir/lib if it exists, otherwise
233                                 # $ssldir
234                                 if test -d "$ssldir/lib" ; then
235                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
236                                         if test ! -z "$need_dash_r" ; then
237                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
238                                         fi
239                                 else
240                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
241                                         if test ! -z "$need_dash_r" ; then
242                                                 LDFLAGS="-R$ssldir $LDFLAGS"
243                                         fi
244                                 fi
245                                 # Try to use $ssldir/include if it exists, otherwise
246                                 # $ssldir
247                                 if test -d "$ssldir/include" ; then
248                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
249                                 else
250                                         CFLAGS="-I$ssldir $saved_CFLAGS"
251                                 fi
252                         fi
253         
254                         # Basic test to check for compatible version and correct linking
255                         # *does not* test for RSA - that comes later.
256                         AC_TRY_RUN(
257                                 [
258         #include <string.h>
259         #include <openssl/rand.h>
260         int main(void)
261         {
262                 char a[2048];
263                 memset(a, 0, sizeof(a));
264                 RAND_add(a, sizeof(a), sizeof(a));
265                 return(RAND_status() <= 0);
266         }
267                                 ],
268                                 [
269                                         found_crypto=1
270                                         break;
271                                 ], []
272                         )
273         
274                         if test ! -z "$found_crypto" ; then
275                                 break;
276                         fi
277                 done
278         
279                 if test -z "$ssldir" ; then
280                         ssldir="(system)"
281                 fi
282         
283                 if test ! -z "$found_crypto" ; then
284                         ac_cv_openssldir=$ssldir
285                 else
286                         ac_cv_openssldir="no"
287                 fi
288         ])
289         LIBS="$saved_LIBS"
290         LDFLAGS="$saved_LDFLAGS"
291         CFLAGS="$saved_CFLAGS"
292         
293         if test "x$ac_cv_openssldir" != "xno" ; then
294                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
295                 found_ssl=yes
296                 LIBS="-lssl -lcrypto $LIBS"
297                 dnl Need to recover ssldir - test above runs in subshell
298                 ssldir=$ac_cv_openssldir
299                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
300                         # Try to use $ssldir/lib if it exists, otherwise
301                         # $ssldir
302                         if test -d "$ssldir/lib" ; then
303                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
304                                 if test ! -z "$need_dash_r" ; then
305                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
306                                 fi
307                         else
308                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
309                                 if test ! -z "$need_dash_r" ; then
310                                         LDFLAGS="-R$ssldir $LDFLAGS"
311                                 fi
312                         fi
313                         # Try to use $ssldir/include if it exists, otherwise
314                         # $ssldir
315                         if test -d "$ssldir/include" ; then
316                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
317                         else
318                                 CFLAGS="-I$ssldir $saved_CFLAGS"
319                         fi
320                 fi
321         fi
322 fi
323 dnl Checks for the SSLdir
324 dnl this is a bit different than the rest, 
325 dnl because of the citadel used to have a keys/ subdir.
326 AC_ARG_WITH(ssldir, 
327                     [  --with-ssldir          directory to store the ssl certificates under],
328                         [ if test "x$withval" != "xno" ; then
329                                               
330                                                   ssl_dir="$withval"
331                                                   if test "$found_ssl" = "no"; then
332                                                      echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
333                                                      exit
334                                                   fi
335                           fi
336                         AC_SUBST(MAKE_SSL_DIR)
337                         ]
338 )
339 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
340
341
342
343
344 AC_CHECK_FUNCS(strftime_l uselocale gettext)
345
346 if test "$ok_nls" != "no"; then
347         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
348         ok_nls=$ok_xgettext
349 fi
350
351 if test "$ok_nls" != "no"; then
352         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
353         ok_nls=$ok_msgmerge
354 fi
355
356 if test "$ok_nls" != "no"; then
357         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
358         ok_nls=$ok_msgfmt
359 fi
360
361 if test "$ok_nls" != "no"; then
362         AC_MSG_RESULT(WebCit will be built with national language support.)
363         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
364         PROG_SUBDIRS="$PROG_SUBDIRS po"
365 else
366         AC_MSG_RESULT(WebCit will be built without national language support.)
367 fi
368
369 AC_SUBST(SETUP_LIBS)
370
371 dnl disable backtrace if we don't want it.
372 AC_ARG_WITH(gprof, 
373                     [  --with-gprof          enable profiling],
374                         [ if test "x$withval" != "xno" ; then
375                              CFLAGS="$CFLAGS  -pg "
376                              LDFLAGS="$LDFLAGS  -pg "
377                           fi
378                         ]
379 )
380
381 dnl disable backtrace if we don't want it.
382 AC_ARG_WITH(backtrace, 
383                     [  --with-backtrace          enable backtrace dumps in the syslog],
384                         [ if test "x$withval" != "xno" ; then
385                              CFLAGS="$CFLAGS  -rdynamic "
386                              LDFLAGS="$LDFLAGS  -rdynamic "
387                              AC_CHECK_FUNCS(backtrace)
388                           fi
389                         ]
390 )
391
392 if test "$prefix" = NONE; then
393         datadir=$ac_default_prefix
394         localedir=$ac_default_prefix
395         wwwdir=$ac_default_prefix
396         rundir=$ac_default_prefix
397         editordir=$ac_default_prefix/tiny_mce
398 else
399         localedir=$prefix
400         wwwdir=$prefix
401         datadir=$prefix
402         rundir=$prefix
403         editordir=$prefix/tiny_mce
404 fi
405
406 dnl where to put the locale files
407 AC_ARG_WITH(localedir, 
408                     [  --with-localedir          directory to put the locale files to],
409                         [ if test "x$withval" != "xno" ; then
410                             localedir=$withval
411                           fi
412                         ]
413 )
414 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
415 LOCALEDIR=$localedir
416 AC_SUBST(LOCALEDIR)
417
418 dnl Checks where to put our templates
419 AC_ARG_WITH(wwwdir, 
420                     [  --with-wwwdir             directory to put our templates],
421                         [ if test "x$withval" != "xno" ; then
422                                 wwwdir=$withval
423                           fi
424                         ]
425 )
426 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
427 WWWDIR=$wwwdir
428 AC_SUBST(WWWDIR)
429
430
431 dnl Checks for the run-dir for the sockets
432 AC_ARG_WITH(rundir, 
433                         [  --with-rundir           directory to place runtime files (UDS) to?],
434                         [ if test "x$withval" != "xno" ; then
435                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
436                                                 
437                                                 rundir=$withval
438                                                 AC_SUBST(MAKE_RUN_DIR)
439                           fi
440                         ]
441 )
442 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
443
444 dnl Checks for the Datadir
445 AC_ARG_WITH(datadir, 
446                     [  --with-datadir          directory to store the databases under],
447                         [ if test "x$withval" != "xno" ; then
448                                               datadir=$withval
449                           fi
450                         ]
451 )
452 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
453
454 dnl Checks where to put our editor
455 AC_ARG_WITH(editordir, 
456                     [  --with-editordir             directory to put our editor],
457                         [ if test "x$withval" != "xno" ; then
458                                 editordir=$withval
459                           fi
460                         ]
461 )
462 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
463
464 ./mk_module_init.sh
465 AC_CONFIG_HEADER(sysdep.h)
466 AC_OUTPUT(Makefile po/Makefile )
467
468 echo ------------------------------------------------------------------------
469 echo 'Character set conversion support:' $ok_iconv
470 echo 'National language support:       ' $ok_nls
471 echo 'Compression support:             ' $ok_zlib
472 echo