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