]> code.citadel.org Git - citadel.git/blob - webcit/configure.in
* "make install"
[citadel.git] / webcit / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id$
3 AC_INIT(webserver.c)
4
5 AC_CANONICAL_HOST
6 AC_PROG_INSTALL
7 AC_PREFIX_DEFAULT(/usr/local/webcit)
8
9 AC_ARG_WITH(with_libical, [  --with-libical          use libical calendaring library])
10 AC_ARG_WITH(with_newt, [  --with-newt          use newt window library])
11 AC_ARG_WITH(ssl,
12         [  --with-ssl=PATH     Specify path to OpenSSL installation ],
13         [
14                 if test "x$withval" != "xno" ; then
15                         tryssldir=$withval
16                 fi
17         ]
18 )
19 dnl Set some system-specific variables which are OK to set before compiler
20 dnl checks:
21 PTHREAD_DEFS=-D_REENTRANT
22 case "$host" in
23         dnl Tru64 Unix requires we use -pthread instead of linking the threads
24         dnl libraries directly, and we can't build threaded programs with gcc
25         dnl due to header file problems.
26         alpha*-dec-osf*)
27                 test -z "$CC" && CC=cc
28                 LIBS=-pthread
29         ;;
30         dnl FreeBSD is similar:
31         *-*-freebsd*)
32                 LIBS=-pthread
33                 PTHREAD_DEFS=-D_THREAD_SAFE
34         ;;
35         *-*-solaris*)
36                 PTHREAD_DEFS='-D_REENTRANT -D_PTHREADS'
37         ;;
38 esac
39 AC_SUBST(PTHREAD_DEFS)
40
41 dnl Checks for programs.
42 AC_PROG_CC
43
44 dnl Configure compiler flags for GCC
45 if test "$GCC" = yes; then
46         case "$host" in
47                 *-*-solaris*)
48                         CFLAGS="$CFLAGS -Wall -Wno-char-subscripts"
49                 ;;
50                 *)
51                         CFLAGS="$CFLAGS -Wall"
52                 ;;
53         esac
54 fi
55
56 missing_dir=`cd $ac_aux_dir && pwd`
57 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
58
59 dnl Checks for libraries.
60 if test "$LIBS" != -pthread; then
61         AC_CHECK_LIB(pthread, pthread_create)
62         AC_CHECK_LIB(pthreads, pthread_create)
63 fi
64 AC_SEARCH_LIBS(gethostbyname, nsl)
65 AC_SEARCH_LIBS(connect, socket)
66
67 dnl Checks for header files.
68 AC_HEADER_STDC
69 dnl AC_HEADER_SYS_WAIT
70 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h)
71
72 dnl Checks for typedefs, structures, and compiler characteristics.
73 AC_C_CONST
74 AC_TYPE_OFF_T
75 AC_TYPE_SIZE_T
76 dnl AC_HEADER_TIME
77
78 dnl Checks for library functions.
79 AC_TYPE_SIGNAL
80 dnl AC_FUNC_VPRINTF
81 dnl AC_CHECK_FUNCS(strerror)
82 AC_REPLACE_FUNCS(snprintf)
83
84 dnl Checks for the libical calendaring library.
85 if test "x$with_libical" != xno ; then
86         AC_CHECK_HEADERS(ical.h,
87                 [AC_CHECK_LIB(ical, icalcomponent_new,
88                         [ok_libical=yes],,
89         )])
90 fi
91
92 if test "x$ok_libical" = xyes ; then
93
94         AC_TRY_RUN(
95                 [
96 #include <ical.h>
97 main() {
98         float v;
99         int i;
100         sscanf(ICAL_VERSION, "%f", &v);
101         printf("libical version: %0.2f\n", v);
102         v = v * 100.0;
103         i = (int) v;
104         if (i >= 24) {
105                 printf("This version is ok.\n");
106                 printf("WebCit will be built with calendar support.\n");
107                 return(0);
108         }
109         printf("libical 0.24 or newer is required.\n");
110         printf("WebCit will be built without calendar support.\n");
111         return(1);
112 }
113                 ], 
114                 [
115                         LIBS="-lical $LIBS"
116                         AC_DEFINE(HAVE_LIBICAL)
117                 ]
118         )
119 fi
120
121 dnl Checks for the newt window library.
122 if test "x$with_newt" != xno ; then
123         AC_CHECK_HEADERS(newt.h,
124                 [AC_CHECK_LIB(newt, newtInit,
125                         [ok_newt=yes],,
126         )])
127 fi
128
129 if test "x$ok_newt" = xyes ; then
130         SETUP_LIBS="-lnewt $SETUP_LIBS"
131         AC_DEFINE(HAVE_NEWT)
132 fi
133
134 # The big search for OpenSSL
135 if test "$with_ssl" != "no"; then
136         saved_LIBS="$LIBS"
137         saved_LDFLAGS="$LDFLAGS"
138         saved_CFLAGS="$CFLAGS"
139         if test "x$prefix" != "xNONE"; then
140                 tryssldir="$tryssldir $prefix"
141         fi
142         AC_CACHE_CHECK([for OpenSSL], ac_cv_openssldir, [
143                 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
144                         CFLAGS="$saved_CFLAGS"
145                         LDFLAGS="$saved_LDFLAGS"
146                         LIBS="$saved_LIBS -lssl -lcrypto"
147         
148                         # Skip directories if they don't exist
149                         if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
150                                 continue;
151                         fi
152                         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
153                                 # Try to use $ssldir/lib if it exists, otherwise
154                                 # $ssldir
155                                 if test -d "$ssldir/lib" ; then
156                                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
157                                         if test ! -z "$need_dash_r" ; then
158                                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
159                                         fi
160                                 else
161                                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
162                                         if test ! -z "$need_dash_r" ; then
163                                                 LDFLAGS="-R$ssldir $LDFLAGS"
164                                         fi
165                                 fi
166                                 # Try to use $ssldir/include if it exists, otherwise
167                                 # $ssldir
168                                 if test -d "$ssldir/include" ; then
169                                         CFLAGS="-I$ssldir/include $saved_CFLAGS"
170                                 else
171                                         CFLAGS="-I$ssldir $saved_CFLAGS"
172                                 fi
173                         fi
174         
175                         # Basic test to check for compatible version and correct linking
176                         # *does not* test for RSA - that comes later.
177                         AC_TRY_RUN(
178                                 [
179         #include <string.h>
180         #include <openssl/rand.h>
181         int main(void)
182         {
183                 char a[2048];
184                 memset(a, 0, sizeof(a));
185                 RAND_add(a, sizeof(a), sizeof(a));
186                 return(RAND_status() <= 0);
187         }
188                                 ],
189                                 [
190                                         found_crypto=1
191                                         break;
192                                 ], []
193                         )
194         
195                         if test ! -z "$found_crypto" ; then
196                                 break;
197                         fi
198                 done
199         
200                 if test -z "$ssldir" ; then
201                         ssldir="(system)"
202                 fi
203         
204                 if test ! -z "$found_crypto" ; then
205                         ac_cv_openssldir=$ssldir
206                 else
207                         ac_cv_openssldir="no"
208                 fi
209         ])
210         LIBS="$saved_LIBS"
211         LDFLAGS="$saved_LDFLAGS"
212         CFLAGS="$saved_CFLAGS"
213         
214         if test "x$ac_cv_openssldir" != "xno" ; then
215                 AC_DEFINE(HAVE_OPENSSL)
216                 LIBS="-lssl -lcrypto $LIBS"
217                 dnl Need to recover ssldir - test above runs in subshell
218                 ssldir=$ac_cv_openssldir
219                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; 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         fi
242 fi
243
244
245
246 AC_SUBST(SETUP_LIBS)
247
248 AC_OUTPUT(Makefile)
249