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