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