+ link gettext.c into setup, so we know the servers locales
[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                         SETUP_LIBS="-lcitadel $SETUP_LIBS"
187                 ],
188                 [
189                         AC_MSG_ERROR(libcitadel was not found or is not usable.  Please install libcitadel.)
190                 ]
191         ,
192         )],
193         [
194                 AC_MSG_ERROR(libcitadel.h was not found or is not usable.  Please install libcitadel.)
195         ]
196 )
197
198
199
200 found_ssl=no
201 # The big search for OpenSSL
202 if test "$with_ssl" != "no"; then
203         saved_LIBS="$LIBS"
204         saved_LDFLAGS="$LDFLAGS"
205         saved_CFLAGS="$CFLAGS"
206         if test "x$prefix" != "xNONE"; then
207                 tryssldir="$tryssldir $prefix"
208         fi
209         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
210                 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
211                         CFLAGS="$saved_CFLAGS"
212                         LDFLAGS="$saved_LDFLAGS"
213                         LIBS="$saved_LIBS -lssl -lcrypto"
214         
215                         # Skip directories if they don't exist
216                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
217                                 continue;
218                         fi
219                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
220                                 # Try to use $ssldir/lib if it exists, otherwise
221                                 # $ssldir
222                                 if test -d "$ssldir/lib" ; then
223                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
224                                         if test ! -z "$need_dash_r" ; then
225                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
226                                         fi
227                                 else
228                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
229                                         if test ! -z "$need_dash_r" ; then
230                                                 LDFLAGS="-R$ssldir $LDFLAGS"
231                                         fi
232                                 fi
233                                 # Try to use $ssldir/include if it exists, otherwise
234                                 # $ssldir
235                                 if test -d "$ssldir/include" ; then
236                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
237                                 else
238                                         CFLAGS="-I$ssldir $saved_CFLAGS"
239                                 fi
240                         fi
241         
242                         # Basic test to check for compatible version and correct linking
243                         # *does not* test for RSA - that comes later.
244                         AC_TRY_RUN(
245                                 [
246         #include <string.h>
247         #include <openssl/rand.h>
248         int main(void)
249         {
250                 char a[2048];
251                 memset(a, 0, sizeof(a));
252                 RAND_add(a, sizeof(a), sizeof(a));
253                 return(RAND_status() <= 0);
254         }
255                                 ],
256                                 [
257                                         found_crypto=1
258                                         break;
259                                 ], []
260                         )
261         
262                         if test ! -z "$found_crypto" ; then
263                                 break;
264                         fi
265                 done
266         
267                 if test -z "$ssldir" ; then
268                         ssldir="(system)"
269                 fi
270         
271                 if test ! -z "$found_crypto" ; then
272                         ac_cv_openssldir=$ssldir
273                 else
274                         ac_cv_openssldir="no"
275                 fi
276         ])
277         LIBS="$saved_LIBS"
278         LDFLAGS="$saved_LDFLAGS"
279         CFLAGS="$saved_CFLAGS"
280         
281         if test "x$ac_cv_openssldir" != "xno" ; then
282                 AC_DEFINE(HAVE_OPENSSL,[],[whethe we have openssl])
283                 found_ssl=yes
284                 LIBS="-lssl -lcrypto $LIBS"
285                 dnl Need to recover ssldir - test above runs in subshell
286                 ssldir=$ac_cv_openssldir
287                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
288                         # Try to use $ssldir/lib if it exists, otherwise
289                         # $ssldir
290                         if test -d "$ssldir/lib" ; then
291                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
292                                 if test ! -z "$need_dash_r" ; then
293                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
294                                 fi
295                         else
296                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
297                                 if test ! -z "$need_dash_r" ; then
298                                         LDFLAGS="-R$ssldir $LDFLAGS"
299                                 fi
300                         fi
301                         # Try to use $ssldir/include if it exists, otherwise
302                         # $ssldir
303                         if test -d "$ssldir/include" ; then
304                                 CFLAGS="-I$ssldir/include $saved_CFLAGS"
305                         else
306                                 CFLAGS="-I$ssldir $saved_CFLAGS"
307                         fi
308                 fi
309         fi
310 fi
311 dnl Checks for the SSLdir
312 dnl this is a bit different than the rest, 
313 dnl because of the citadel used to have a keys/ subdir.
314 AC_ARG_WITH(ssldir, 
315                     [  --with-ssldir          directory to store the ssl certificates under],
316                         [ if test "x$withval" != "xno" ; then
317                                               
318                                                   ssl_dir="$withval"
319                                                   if test "$found_ssl" = "no"; then
320                                                      echo "Your setup was incomplete; ssldir doesn't make sense without openssl"
321                                                      exit
322                                                   fi
323                           fi
324                         AC_SUBST(MAKE_SSL_DIR)
325                         ]
326 )
327 AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
328
329
330
331
332 AC_CHECK_FUNCS(strftime_l uselocale gettext)
333
334 if test "$ok_nls" != "no"; then
335         AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
336         ok_nls=$ok_xgettext
337 fi
338
339 if test "$ok_nls" != "no"; then
340         AC_CHECK_PROG(ok_msgmerge, msgmerge, yes, no)
341         ok_nls=$ok_msgmerge
342 fi
343
344 if test "$ok_nls" != "no"; then
345         AC_CHECK_PROG(ok_msgfmt, msgfmt, yes, no)
346         ok_nls=$ok_msgfmt
347 fi
348
349 if test "$ok_nls" != "no"; then
350         AC_MSG_RESULT(WebCit will be built with national language support.)
351         AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
352         PROG_SUBDIRS="$PROG_SUBDIRS po"
353 else
354         AC_MSG_RESULT(WebCit will be built without national language support.)
355 fi
356
357 AC_SUBST(SETUP_LIBS)
358
359 dnl disable backtrace if we don't want it.
360 AC_ARG_WITH(gprof, 
361                     [  --with-gprof          enable profiling],
362                         [ if test "x$withval" != "xno" ; then
363                              CFLAGS="$CFLAGS  -pg "
364                              LDFLAGS="$LDFLAGS  -pg "
365                           fi
366                         ]
367 )
368
369 dnl disable backtrace if we don't want it.
370 AC_ARG_WITH(backtrace, 
371                     [  --with-backtrace          enable backtrace dumps in the syslog],
372                         [ if test "x$withval" != "xno" ; then
373                              CFLAGS="$CFLAGS  -rdynamic "
374                              LDFLAGS="$LDFLAGS  -rdynamic "
375                              AC_CHECK_FUNCS(backtrace)
376                           fi
377                         ]
378 )
379
380 if test "$prefix" = NONE; then
381         datadir=$ac_default_prefix
382         localedir=$ac_default_prefix
383         wwwdir=$ac_default_prefix
384         rundir=$ac_default_prefix
385         editordir=$ac_default_prefix/tiny_mce
386 else
387         localedir=$prefix
388         wwwdir=$prefix
389         datadir=$prefix
390         rundir=$prefix
391         editordir=$prefix/tiny_mce
392 fi
393
394 dnl where to put the locale files
395 AC_ARG_WITH(localedir, 
396                     [  --with-localedir          directory to put the locale files to],
397                         [ if test "x$withval" != "xno" ; then
398                             localedir=$withval
399                           fi
400                         ]
401 )
402 AC_DEFINE_UNQUOTED(LOCALEDIR, "$localedir",[where to find our pot files])
403 LOCALEDIR=$localedir
404 AC_SUBST(LOCALEDIR)
405
406 dnl Checks where to put our templates
407 AC_ARG_WITH(wwwdir, 
408                     [  --with-wwwdir             directory to put our templates],
409                         [ if test "x$withval" != "xno" ; then
410                                 wwwdir=$withval
411                           fi
412                         ]
413 )
414 AC_DEFINE_UNQUOTED(WWWDIR, "$wwwdir", [where to find our templates and pics])
415 WWWDIR=$wwwdir
416 AC_SUBST(WWWDIR)
417
418
419 dnl Checks for the run-dir for the sockets
420 AC_ARG_WITH(rundir, 
421                         [  --with-rundir           directory to place runtime files (UDS) to?],
422                         [ if test "x$withval" != "xno" ; then
423                                             AC_DEFINE(HAVE_RUN_DIR, [], [should we put our non volatile files elsewhere?])
424                                                 
425                                                 rundir=$withval
426                                                 AC_SUBST(MAKE_RUN_DIR)
427                           fi
428                         ]
429 )
430 AC_DEFINE_UNQUOTED(RUNDIR, "$rundir", [define, where the config should go in unix style])
431
432 dnl Checks for the Datadir
433 AC_ARG_WITH(datadir, 
434                     [  --with-datadir          directory to store the databases under],
435                         [ if test "x$withval" != "xno" ; then
436                                               datadir=$withval
437                           fi
438                         ]
439 )
440 AC_DEFINE_UNQUOTED(DATADIR, "$datadir",[define, if the user suplied a data-directory to use.])
441
442 dnl Checks where to put our editor
443 AC_ARG_WITH(editordir, 
444                     [  --with-editordir             directory to put our editor],
445                         [ if test "x$withval" != "xno" ; then
446                                 editordir=$withval
447                           fi
448                         ]
449 )
450 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
451
452 ./mk_module_init.sh
453 AC_CONFIG_HEADER(sysdep.h)
454 AC_OUTPUT(Makefile po/Makefile )
455
456 echo ------------------------------------------------------------------------
457 echo 'Character set conversion support:' $ok_iconv
458 echo 'National language support:       ' $ok_nls
459 echo