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