root/cherokee/trunk/configure.in

Revision 1887, 35.8 kB (checked in by alo, 2 weeks ago)

--

  • Property svn:keywords set to Id
Line 
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_COPYRIGHT([
5 Copyright (C) 2001-2008 Alvaro Lopez Ortega
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of version 2 of the GNU General Public
9 License as published by the Free Software Foundation.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA
20 ])
21
22 dnl require autoconf 2.56
23 AC_PREREQ(2.56)
24
25 dnl Version
26 m4_define([cherokee_major_version], [0])
27 m4_define([cherokee_minor_version], [9])
28 m4_define([cherokee_micro_version], [0])
29 m4_define([cherokee_version], m4_format('%s.%s.%s', cherokee_major_version, cherokee_minor_version, cherokee_micro_version))
30
31 dnl Init autoconf and automake
32 AC_INIT([cherokee], [cherokee_version], [http://bugs.cherokee-project.com], [cherokee])
33 AC_CONFIG_SRCDIR([cherokee/server.c])
34 AM_INIT_AUTOMAKE([no-define])
35
36 dnl Define version
37 AC_DEFINE(PACKAGE_MAJOR_VERSION, "cherokee_major_version", [Version string])
38 AC_DEFINE(PACKAGE_MINOR_VERSION, "cherokee_minor_version", [Version string])
39 AC_DEFINE(PACKAGE_MICRO_VERSION, "cherokee_micro_version", [Version string])
40
41 PACKAGE_MAJOR_VERSION="cherokee_major_version"
42 PACKAGE_MINOR_VERSION="cherokee_minor_version"
43 PACKAGE_MICRO_VERSION="cherokee_micro_version"
44 AC_SUBST(PACKAGE_MAJOR_VERSION)
45 AC_SUBST(PACKAGE_MINOR_VERSION)
46 AC_SUBST(PACKAGE_MICRO_VERSION)
47
48 dnl Define library soname
49 CHEROKEE_AGE=0
50 CHEROKEE_CURRENT=0
51 CHEROKEE_REVISION=1
52 AC_SUBST(CHEROKEE_AGE)
53 AC_SUBST(CHEROKEE_CURRENT)
54 AC_SUBST(CHEROKEE_REVISION)
55
56 AC_DEFINE_UNQUOTED(CHEROKEE_CONFIG_ARGS, "$ac_configure_args", [configure arguments])
57
58 dnl Check the SVN revision
59 AC_ARG_ENABLE(beta, AC_HELP_STRING([--enable-beta], [Enable beta development]),
60                     is_beta="$enableval", is_beta="no")
61
62 if test x"$is_beta" = "xyes"; then
63   if test -d ".svn"; then
64      svn_rev="`svn info -R | grep Revision | sort | tail -1 | sed 's/Revision: //'`";   
65   fi
66
67   PACKAGE_PATCH_VERSION="b$svn_rev"
68
69   dnl Redefine versions
70   PACKAGE_VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
71   AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "${PACKAGE_VERSION}", [Package version])
72
73   VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
74   AC_DEFINE(VERSION, $VERSION, [Software version])
75 else
76
77   PACKAGE_PATCH_VERSION=""
78 fi
79
80 dnl Path version
81 AC_SUBST(PACKAGE_PATCH_VERSION)
82 AC_DEFINE_UNQUOTED(PACKAGE_PATCH_VERSION, "${PACKAGE_PATCH_VERSION}", [Version string])
83
84 dnl Initial CFLAGS
85 AC_MSG_CHECKING(initial CFLAGS)
86 AC_MSG_RESULT($CFLAGS)
87
88 dnl Check for CPU / vendor / OS
89 AC_CANONICAL_HOST
90
91 os_string="UNIX"
92 so_suffix=so
93 mod_suffix=$so_suffix
94
95 AC_MSG_CHECKING([host platform characteristics])
96         case "$host" in
97         *-*-mingw*|*-*-cygwin*)
98                 so_suffix=DLL
99                 mod_suffix=$so_suffix
100              os_string="Win32"
101           libdl=
102           ;;
103         *-*-linux*)
104           libdl="-ldl"
105           ;;
106         *-*-solaris*)
107              AC_DEFINE(SOLARIS, 1, [It is Solaris])         
108                 setenv_is_threadsafe="yes"
109           libdl="-ldl"
110           ;;
111         *-*-hpux*)
112           libdl="-ldl"
113           ;;
114      *-*-irix6*)
115           AC_DEFINE(IRIX, 1, [It is SGI Irix])
116           setenv_is_threadsafe="yes"
117           libdl="-ldl"
118           ;;
119         *-*-*freebsd*|*-*-*openbsd*|*-*-*netbsd*|*-*-*dragonfly*)
120           libdl=
121           ;;
122         *-*-darwin*)
123                 so_suffix=dylib
124                 mod_suffix=so
125           libdl="-ldl"
126           ;;
127         *)
128                 AC_MSG_WARN([*** Please add $host to configure.in checks!])
129           libdl="-ldl"
130           ;;
131 esac
132 AC_MSG_RESULT(ok)
133
134 AC_MSG_CHECKING([L2 cache line size])
135 case "$host_cpu" in
136         i386|i486)
137                 CPU_CACHE_LINE=32
138         ;;
139         i586|i686)
140                 CPU_CACHE_LINE=64
141         ;;
142         i786)   
143                 CPU_CACHE_LINE=128
144         ;;
145         athlon)
146                 CPU_CACHE_LINE=64
147         ;;
148         x86_64)
149                 CPU_CACHE_LINE=64
150         ;;
151         sparc*)
152                 CPU_CACHE_LINE=64
153         ;;
154         powerpc)
155                 CPU_CACHE_LINE=128
156         ;;
157         *)
158                 CPU_CACHE_LINE=128
159         ;;
160 esac
161 AC_DEFINE_UNQUOTED(CPU_CACHE_LINE, $CPU_CACHE_LINE, [L2 cache line size])
162 AC_MSG_RESULT($CPU_CACHE_LINE)
163
164 dnl
165 dnl OS string
166 dnl
167 AC_ARG_ENABLE(os_string, AC_HELP_STRING([--enable-os-string=STR], [Set a customized OS type string]), [os_string="$enableval"])
168 AC_DEFINE_UNQUOTED(OS_TYPE, "${os_string}", [OS type])
169
170 AM_CONDITIONAL(PLATFORM_WIN32, test x"$os_string" = "xWin32")
171
172 dnl
173 dnl Tracing
174 dnl
175 AC_ARG_ENABLE(trace, AC_HELP_STRING([--enable-trace], [Enable trace facility]),
176    [enable_trace="$enableval"
177     AC_DEFINE(TRACE_ENABLED, 1, [Trace facility])
178    ], [enable_trace="no"])
179
180
181 dnl
182 dnl Dynamic library loading library
183 dnl
184 LIBS="$LIBS $libdl"
185 AC_DEFINE_UNQUOTED(SO_SUFFIX, "${so_suffix}", [Dynamic loading libraries extension])
186 AC_DEFINE_UNQUOTED(MOD_SUFFIX, "${mod_suffix}", [Dynamic modules extension])
187
188 dnl
189 dnl Libtool options
190 dnl
191 if test "$os_string" != "Win32"; then
192     # libtool option to control which symbols are exported
193     # right now, symbols starting with _ are not exported
194     LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
195 else
196     LIBTOOL_EXPORT_OPTIONS=
197 fi
198 AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
199
200 dnl Set the Version
201 AM_INIT_AUTOMAKE(cherokee, $VERSION)
202 AM_MAINTAINER_MODE
203
204 AM_CONFIG_HEADER(config.h)
205 AC_SUBST(VERSION)
206
207 dnl Initialize Libtool
208 m4_ifdef([LT_INIT],
209   [LT_INIT([dlopen C shared static win32-dll])],
210   [AC_LIBTOOL_DLOPEN
211    AC_LIBTOOL_WIN32_DLL
212    ])
213
214 dnl Paths
215 AC_PROG_CC
216 AC_PROG_CC_STDC
217 AC_PROG_INSTALL
218 AC_PROG_MAKE_SET
219 AC_PROG_LIBTOOL
220
221 AC_PATH_PROG(cherokeepath, cherokee)
222
223 AC_FUNC_CLOSEDIR_VOID
224 AC_FUNC_MALLOC
225 AC_FUNC_REALLOC
226 AC_FUNC_VPRINTF
227
228 AC_C_CONST
229 AC_C_BIGENDIAN
230 AC_C_INLINE
231 if test "$ac_cv_c_inline" != no; then
232   AC_DEFINE(HAVE_INLINE, 1, [Compile supports inline])
233 fi
234
235 dnl
236 dnl Check for headers
237 dnl
238 AC_HEADER_STDC
239 AC_HEADER_DIRENT
240 AC_HEADER_TIME
241 AC_HEADER_SYS_WAIT
242
243 AC_CHECK_HEADERS(endian.h machine/endian.h sys/endian.h sys/isa_defs.h sys/utsname.h sys/poll.h poll.h )
244 AC_CHECK_HEADERS(sys/socket.h sys/un.h netinet/in.h arpa/inet.h netinet/tcp.h sys/ioctl.h fcntl.h sys/time.h)
245 AC_CHECK_HEADERS(sys/resource.h resource.h unistd.h syslog.h stdint.h inttypes.h error.h pwd.h sys/uio.h)
246 AC_CHECK_HEADERS(pthread.h netdb.h stdarg.h sys/filio.h sys/varargs.h sys/select.h sys/mman.h grp.h winsock.h)
247 AC_CHECK_HEADERS(winsock.h winsock2.h)
248
249 AC_SYS_LARGEFILE
250
251 AC_SIZE_T
252 AC_TYPE_SIGNAL
253 AC_TYPE_UID_T
254 AC_TYPE_MODE_T
255 AC_TYPE_OFF_T
256 AC_TYPE_SIZE_T
257 AC_TYPE_PID_T
258 AC_STRUCT_ST_RDEV
259 AC_CHECK_TYPE(ino_t, unsigned)
260 AC_CHECK_TYPE(loff_t, off_t)
261 AC_CHECK_TYPE(offset_t, loff_t)
262 AC_CHECK_TYPE(ssize_t, int)
263 AC_CHECK_TYPE(wchar_t, unsigned short)
264
265 AC_CHECK_SIZEOF(int)
266 AC_CHECK_SIZEOF(unsigned int)
267 AC_CHECK_SIZEOF(unsigned long)
268 AC_CHECK_SIZEOF(unsigned long long)
269 AC_CHECK_SIZEOF(unsigned int)
270 AC_CHECK_SIZEOF(off_t)
271 AC_CHECK_SIZEOF(size_t)
272
273 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
274 AC_TRY_RUN([#include <stdio.h>
275 main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
276 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
277 if test x"$samba_cv_have_longlong" = x"yes"; then
278     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long'])
279 fi
280
281 AC_FUNC_MEMCMP
282 AC_FUNC_MMAP
283 AC_FUNC_FORK
284
285 AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r getrlimit getdtablesize readdir readdir_r flockfile funlockfile)
286
287 FW_CHECK_PWD
288 FW_CHECK_GRP
289
290 AC_CHECK_MEMBER(struct tm.tm_gmtoff,
291                 AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm]),,[#include <time.h>])
292
293 AH_BOTTOM([
294 /* Give us an unsigned 32-bit data type. */
295 #if SIZEOF_UNSIGNED_LONG==4
296 #define UWORD32 unsigned long
297 #elif SIZEOF_UNSIGNED_INT==4
298 #define UWORD32 unsigned int
299 #else
300 #error I do not know what to use for a UWORD32.
301 #endif
302 ])
303
304
305 dnl Find socket()
306 dnl Likely combinations:
307 dnl             -lsocket [ -lnsl_s | -lnsl ]
308 dnl             -linet
309 AC_CHECK_LIB(ws2_32, main)
310 AC_CHECK_LIB(advapi32, main)
311
312 AC_CHECK_FUNC(socket, :, [     
313         AC_CHECK_LIB(socket, main)
314         AC_CHECK_LIB(net, main)
315         AC_CHECK_LIB(nsl_s, main)
316         AC_CHECK_LIB(nsl, main)
317         AC_CHECK_LIB(inet, socket)
318         AC_CHECK_LIB(gen, main)
319 ])
320
321 AC_SEARCH_LIBS(accept, socket)
322 AC_SEARCH_LIBS(bind, socket)
323 AC_SEARCH_LIBS(listen, socket)
324 AC_SEARCH_LIBS(setsockopt, socket)
325
326 dnl
327 dnl Check for fd events inspect functions
328 dnl
329 AC_CHECK_FUNC(poll, have_poll=yes)
330 AC_CHECK_FUNC(kqueue, have_kqueue=yes)
331 AC_CHECK_FUNC(select, have_select=yes)
332
333 if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes"; then
334      AC_MSG_CHECKING([for select in ws2_32])
335      AC_TRY_LINK([#include <winsock2.h>],
336                                 [select(0,0,0,0,0)],
337                                 [AC_MSG_RESULT(yes)
338                                  have_win32_select=yes],
339                                 [AC_MSG_RESULT(no)])
340 fi
341
342 dnl
343 dnl Epoll
344 dnl
345 AC_CHECK_HEADER(sys/epoll.h, have_epoll_include=yes, have_epoll_include=no)
346
347 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--disable-epoll],[Disable epoll() support]),
348                     wants_epoll="$enableval", wants_epoll="yes")
349
350 have_epoll=no
351 if test "x$have_epoll_include" = "xyes" && test "x$wants_epoll" = "xyes"; then
352         AC_MSG_CHECKING(for epoll system call)
353
354      AC_RUN_IFELSE([
355                 #include <stdint.h>
356                 #include <sys/param.h>
357                 #include <sys/types.h>
358                 #include <sys/syscall.h>
359                 #include <sys/epoll.h>
360                 #include <unistd.h>
361
362                 int epoll_create (int size) {
363                 return (syscall(__NR_epoll_create, size));
364                 }
365        
366                 int main (int argc, char **argv) {
367                 int epfd;
368                 epfd = epoll_create(256);
369                    exit (epfd == -1 ? 1 : 0);
370                 }
371         ],
372         have_epoll=yes,
373         have_epoll=no,
374         have_epoll=yes)
375         AC_MSG_RESULT($have_epoll)
376 fi
377
378 dnl
379 dnl Solaris 10: Event ports
380 dnl
381 AC_CHECK_HEADER(port.h, have_port_include=yes, have_port_include=no)
382
383 have_port=no
384 if test "x$have_port_include" = "xyes"; then
385         AC_MSG_CHECKING(for event ports support)
386
387      AC_RUN_IFELSE([
388                 #include <stdint.h>
389                 #include <unistd.h>
390                 #include <port.h>
391        
392                 int main (int argc, char **argv) {
393                 int port;
394                    port = port_create();
395                    exit (port < 0 ? 1 : 0);
396                 }
397         ],
398         have_port=yes,
399         have_port=no,
400         have_port=cross)
401         AC_MSG_RESULT($have_port)
402 fi
403
404
405
406 if test "$have_epoll" = yes; then
407         AC_DEFINE(HAVE_EPOLL, 1, [Have epoll])
408 fi
409 AM_CONDITIONAL(COMPILE_EPOLL, test x"$have_epoll" = "xyes")
410
411 if test "$have_kqueue" = yes; then
412         AC_DEFINE(HAVE_KQUEUE, 1, [Have kqueue])
413 fi
414 AM_CONDITIONAL(COMPILE_KQUEUE, test x"$have_kqueue" = "xyes")
415
416 if test "$have_port" = yes; then
417         AC_DEFINE(HAVE_PORT, 1, [Have event ports])
418 fi
419 AM_CONDITIONAL(COMPILE_PORT, test x"$have_port" = "xyes")
420
421 if test "$have_poll" = yes; then
422         AC_DEFINE(HAVE_POLL, 1, [Have poll])
423 fi
424 AM_CONDITIONAL(COMPILE_POLL, test x"$have_poll" = "xyes")
425
426 if test "$have_win32_select" = yes; then
427         AC_DEFINE(HAVE_WIN32_SELECT, 1, [Have Win32 select])
428 fi
429 AM_CONDITIONAL(COMPILE_WIN32_SELECT, test x"$have_win32_select" = "xyes")
430
431 if test "$have_select" = yes; then
432      AC_DEFINE(HAVE_SELECT, 1, [Have select])
433 fi
434 AM_CONDITIONAL(COMPILE_SELECT, test x"$have_select" = "xyes" -a x"$have_win32_select" != "xyes")
435
436
437 dnl
438 dnl Check for inet_pton.  We have our own, but on Solaris the version in
439 dnl libresolv is more lenient in ways that Solaris's internal DNS resolution
440 dnl code requires, so if we use our own *and* link with libresolv (which may
441 dnl be forced by Perl) DNS resolution fails.
442 dnl
443 AC_SEARCH_LIBS(inet_pton, [socket nsl resolv])
444 AC_CHECK_FUNCS(inet_pton inet_ntop inet_addr)
445
446 AC_SEARCH_LIBS(gethostbyname, [socket nsl resolv])
447 AC_CHECK_FUNCS(gethostbyname gethostbyname_r)
448
449 dnl
450 dnl Check for inet_addr
451 dnl
452 AC_SEARCH_LIBS(inet_addr, xnet)
453 AC_CHECK_FUNCS(inet_addr)
454
455 dnl
456 dnl TCP_CORK
457 dnl
458 HYDRA_TCP_CORK
459 HYDRA_TCP_NOPUSH
460
461 dnl
462 dnl Check for GNU getopt_long()
463 dnl
464 AC_CHECK_HEADERS(getopt.h)
465 AC_CHECK_FUNC(getopt_long, have_getopt_long="yes")
466 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x"$have_getopt_long" = "xyes")
467
468
469 dnl
470 dnl Pthread
471 dnl
472 with_pthread="yes"
473 have_pthread="no"
474 AC_ARG_ENABLE(pthread, AC_HELP_STRING([--disable-pthread],[Disable threading support]),
475                     with_pthread="$enableval", with_pthread="yes")
476
477 AM_CONDITIONAL(USE_PTHREAD, test "x$with_pthread" = "xyes")
478 if test "x$with_pthread" = "xyes"
479 then
480         dnl
481      dnl Basic checkings (c&p'ed from squid)
482         dnl
483         AC_MSG_CHECKING([for special a pthread case])
484
485         oldcflags="$CFLAGS"
486      CFLAGS="$CFLAGS -D_REENTRANT"
487         PTHREAD_CFLAGS="-D_REENTRANT"
488
489         case "$host" in
490            i386-unknown-freebsd*)
491            if test "$GCC" = "yes" ; then
492               if test -z "$PRESET_LDFLAGS"; then
493                 PTHREAD_LIBS="-pthread"
494                          have_pthread="yes"
495               fi
496            fi
497                  AC_MSG_RESULT([-pthread])
498            ;;
499        *-solaris2.*)
500            if test "$GCC" = "yes" ; then
501               CFLAGS="$CFLAGS -pthreads"
502               PTHREAD_CFLAGS="-pthreads"
503                     AC_MSG_RESULT([-pthreads])
504            else
505               CFLAGS="$CFLAGS -mt"
506               PTHREAD_CFLAGS="-mt"
507                     AC_MSG_RESULT([-mt])
508            fi
509               have_pthread="yes"
510            ;;
511           *)
512                  AC_MSG_RESULT([no])
513                  ;;
514      esac
515
516         if test "$have_pthread" != "yes"; then
517         AC_CHECK_LIB(pthread, main, have_pthread=yes, have_pthread=no)
518            if test "$have_pthread" = "yes"; then
519                  PTHREAD_LIBS="-lpthread"   
520            fi
521      fi
522
523         dnl
524         dnl More detailed checks on the pthread support
525         dnl
526         AC_MSG_CHECKING([for pthread_rwlock_t support])
527
528         have_pthread_rwlock_t=yes
529         AC_TRY_COMPILE([#include <pthread.h>],
530                         [pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
531                         compiled=yes, compiled=no)
532
533         if test "$compiled" = "yes"; then
534                 AC_MSG_RESULT([ok])
535         else
536              dnl Didn't find rwlock_t.
537              dnl Try defining _XOPEN_SOURCE=500
538              dnl
539                 oldcflags2="$CFLAGS"
540                 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"
541
542                 AC_TRY_COMPILE([#include <pthread.h>],
543                             [pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
544                             compiled=yes, compiled=no)
545
546                 if test "$compiled" = "yes"; then
547                     AC_MSG_RESULT([-D_XOPEN_SOURCE=500])
548                     PTHREAD_CFLAGS="-D_XOPEN_SOURCE=500"
549                 else
550                     have_pthread_rwlock_t=no
551                     AC_MSG_RESULT([no])
552                 fi
553
554                 CFLAGS="$oldcflags2"
555         fi
556
557         if test "$have_pthread_rwlock_t" = "yes"; then
558                 AC_DEFINE(HAVE_PTHREAD_RWLOCK_T, 1, [Define if your pthread library includes pthread_rwlock_t])
559         else
560                 AC_MSG_ERROR([pthread_rwlock_t support missing])
561         fi
562
563         AC_CHECK_FUNC(pthread_attr_setschedpolicy, have_pthread_attr_setschedpolicy=yes)
564         if test x"$have_pthread_attr_setschedpolicy" = "xyes"; then
565              AC_DEFINE(HAVE_PTHREAD_SETSCHEDPOLICY, 1, [Pthread support pthread_attr_setschedpolicy])
566         fi
567
568         CFLAGS="$oldcflags"
569 fi
570
571 if test "$have_pthread" = "yes"; then
572         AC_DEFINE(HAVE_PTHREAD, 1, [Have pthread support])
573         AC_SUBST(PTHREAD_CFLAGS)
574         AC_SUBST(PTHREAD_LIBS)
575 fi
576
577 dnl
578 dnl Is setenv() threadsafe?
579 dnl
580 if test "$setenv_is_threadsafe" = "yes"; then
581 AC_DEFINE(SETENV_IS_THREADSAFE, 1, [setenv function is thread safe])
582 fi
583
584 dnl
585 dnl Check for vsyslog
586 dnl
587 AC_CHECK_FUNCS(syslog vsyslog strsep strcasestr memmove strerror bcopy strlcat)
588
589 dnl
590 dnl Check for Glib (usually Linux)
591 dnl
592 AC_PREPROC_IFELSE([
593 #include <features.h>
594 #ifndef __GLIBC__
595     chokeme
596 #endif
597 ], [
598     AC_DEFINE([HAVE_GLIBC], [1], [Define to 1 if you have glibc.])
599     AC_DEFINE([_GNU_SOURCE], [1], [Define to 1 if you have glibc.])
600 ])
601
602 dnl
603 dnl Does this platform require array notation to assign to a va_list?
604 dnl If cross-compiling, we assume va_list is "normal".  If this breaks
605 dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
606 dnl also just to be sure.
607 dnl
608 AC_MSG_CHECKING(whether va_list assignments need array notation)
609 AC_CACHE_VAL(ac_cv_valistisarray,
610         [AC_TRY_RUN([#include <stdlib.h>
611                      #include <stdarg.h>
612                      void foo(int i, ...) {
613                         va_list ap1, ap2;
614                         va_start(ap1, i);
615                         ap2 = ap1;
616                         if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
617                         va_end(ap1); va_end(ap2);
618                      }
619                      int main()
620                      { foo(0, 123); return(0); }],
621                     [ac_cv_valistisarray=false],
622                     [ac_cv_valistisarray=true],
623                     [ac_cv_valistisarray=false])])
624                                              
625 if test "$ac_cv_valistisarray" = true ; then
626         AC_DEFINE(HAVE_VA_LIST_AS_ARRAY,,[va_list works copying an array])
627         AC_MSG_RESULT(yes)
628 else
629         AC_MSG_RESULT(no)
630 fi
631
632
633 dnl
634 dnl Check if the global variable `timezone' exists. If so, define
635 dnl HAVE_INT_TIMEZONE.
636 dnl
637 AC_STRUCT_TIMEZONE
638
639 AC_MSG_CHECKING(for global timezone)
640 AC_TRY_LINK([#include <time.h>],
641 [int res; res = timezone / 60;],
642 [AC_MSG_RESULT(yes)
643 AC_DEFINE(HAVE_INT_TIMEZONE,, [Set to 1 if you have the global variable timezone])],
644 AC_MSG_RESULT(no))
645
646
647 dnl
648 dnl Check for RTDL constants (from Haskell code)
649 dnl
650 dnl ** check for libdl & RTLD_NEXT
651 dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
652 AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
653 AC_EGREP_CPP(yes,
654 [
655  #include <dlfcn.h>
656  #ifdef RTLD_NEXT
657         yes
658  #endif
659 ], [
660   AC_MSG_RESULT(yes)
661   AC_DEFINE(HAVE_RTLDNEXT,,[Have RTDL_NEXT])
662   HaveRtldNext=YES
663 ], [
664   AC_MSG_RESULT(no)
665   HaveRtldNext=NO
666   ])   
667 AC_SUBST(HaveRtldNext)
668
669 dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
670 AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
671 AC_EGREP_CPP(yes,
672 [
673  #include <dlfcn.h>
674  #ifdef RTLD_LOCAL
675         yes
676  #endif
677 ], [
678   AC_MSG_RESULT(yes)
679   AC_DEFINE(HAVE_RTLDLOCAL,,[Have RTDL_LOCAL])
680   HaveRtldLocal=YES
681 ], [
682   AC_MSG_RESULT(no)
683   HaveRtldLocal=NO
684   ])   
685 AC_SUBST(HaveRtldLocal)
686
687 dnl ** RTLD_GLOBAL isn't available on openbsd
688 AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
689 AC_EGREP_CPP(yes,
690 [
691  #include <dlfcn.h>
692  #ifdef RTLD_GLOBAL
693         yes
694  #endif
695 ], [
696   AC_MSG_RESULT(yes)
697   AC_DEFINE(HAVE_RTLDGLOBAL,,[Have RTDL_GLOBAL])
698   HaveRtldGlobal=YES
699 ], [
700   AC_MSG_RESULT(no)
701   HaveRtldGlobal=NO
702   ])   
703 AC_SUBST(HaveRtldGlobal)
704
705 dnl ** RTLD_NOW isn't available on openbsd
706 AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
707 AC_EGREP_CPP(yes,
708 [
709  #include <dlfcn.h>
710  #ifdef RTLD_NOW
711         yes
712  #endif
713 ], [
714   AC_MSG_RESULT(yes)
715   AC_DEFINE(HAVE_RTLDNOW,,[Have RTDL_NOW])
716   HaveRtldNow=YES
717 ], [
718   AC_MSG_RESULT(no)
719   HaveRtldNow=NO
720   ])   
721 AC_SUBST(HaveRtldNow)
722
723
724 dnl
725 dnl Check of off64_t
726 dnl
727 AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
728 AC_TRY_RUN([
729 #if defined(HAVE_UNISTD_H)
730 #include <unistd.h>
731 #endif
732 #include <stdio.h>
733 #include <sys/stat.h>
734 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
735 samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
736 if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
737     AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
738 fi
739
740
741 # From etr_socket_nsl.m4
742 ETR_SOCKET_NSL
743
744 # From sendfile_samba.m4
745 SENDFILE_CHECK
746
747 # readdir_r()
748 LIBWWW_READDIR_R_TYPE
749
750
751 dnl
752 dnl IPv6 Support
753 dnl I got this mostly from Apache's tests
754 dnl
755
756 AC_ARG_ENABLE(ipv6,
757   AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support]),
758   [ if test "$enableval" = "no"; then
759        disabled_ipv6=1
760     fi ],
761   [ disabled_ipv6=0 ] )
762
763 AC_SEARCH_LIBS(getaddrinfo, socket inet6)
764 AC_SEARCH_LIBS(getnameinfo, socket inet6)
765 AC_SEARCH_LIBS(gai_strerror, socket inet6)
766 AC_CHECK_FUNC(gai_strerror)
767
768 APR_CHECK_WORKING_GETADDRINFO
769 APR_CHECK_WORKING_GETNAMEINFO
770
771 AC_ACME_SOCKADDR_UN
772 AC_ACME_SOCKADDR_IN6
773 AC_ACME_SOCKADDR_STORAGE
774
775 AC_MSG_CHECKING(if the system supports IPv6)
776 have_ipv6="no"
777
778 if test "$disabled_ipv6" = 1; then
779     AC_MSG_RESULT([no -- disabled by user])
780 else
781     if test "x$ac_cv_acme_sockaddr_in6" = "xyes"; then
782         if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
783             if test "x$ac_cv_working_getnameinfo" = "xyes"; then
784                 have_ipv6="yes"
785                 AC_MSG_RESULT([yes])
786                       AC_DEFINE(HAVE_IPV6, 1, [Define if you have IPv6 support.])
787             else
788                 AC_MSG_RESULT([no -- no getnameinfo])
789             fi
790         else
791             AC_MSG_RESULT([no -- no working getaddrinfo])
792         fi
793     else
794         AC_MSG_RESULT([no -- no sockaddr_in6])
795     fi
796 fi
797
798 dnl
799 dnl Test whether SO_RCVTIMEO is broken
800 dnl
801 AC_CACHE_CHECK([whether setsockopt(SO_RCVTIMEO) is broken],
802   ac_cv_so_rcvtimeo_broken, [dnl
803     AC_RUN_IFELSE([AC_LANG_SOURCE([[
804 #if defined(HAVE_SYS_TYPES_H)
805 #include <sys/types.h>
806 #endif
807
808 #if defined(HAVE_SYS_SOCKET_H)
809 #include <sys/socket.h>
810 #endif
811
812 #if defined(HAVE_SYS_TIME_H)
813 #include <sys/time.h>
814 #endif
815
816 int main(void) {
817         int fd;
818         int ret;
819         struct timeval new_tv;
820
821         /* Open the socket (INET/TCP).*/
822         fd = socket(AF_INET, SOCK_STREAM, 0);
823
824         /* set the timeout for the incoming queue */
825         /* 1 second for example */
826         new_tv.tv_sec = 1;
827         new_tv.tv_usec = 0;
828
829         ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &new_tv, sizeof(new_tv));
830         return ret;
831 }
832 ]])],[ac_cv_so_rcvtimeo_broken=no],[ac_cv_so_rcvtimeo_broken=yes],[ac_cv_so_rcvtimeo_broken=cross])])
833 if test x"$ac_cv_so_rcvtimeo_broken" = x"yes"; then
834   AC_DEFINE(HAVE_BROKEN_SO_RCVTIMEO, 1, [Define if setsockopt(SO_RCVTIMEO) is broken])
835 fi
836
837
838 dnl
839 dnl Look for socklen_t
840 dnl
841 AC_MSG_CHECKING([for socklen_t])
842 AC_TRY_COMPILE(
843  [#include <sys/types.h>
844   #include <sys/socket.h>],
845  [socklen_t len = 42; return 0;],
846  ac_cv_type_socklen_t=yes,
847  ac_cv_type_socklen_t=no
848 )
849
850 if test $ac_cv_type_socklen_t != yes; then
851   AC_DEFINE(socklen_t, int, [Substitute for socklen_t])
852   AC_MSG_RESULT(int)
853 else
854   AC_MSG_RESULT(yes)
855 fi
856
857 dnl
858 dnl Check of __func__ and co..
859 dnl
860 AC_MSG_CHECKING([whether our compiler supports __func__])
861 AC_TRY_COMPILE([],
862  [const char *cp = __func__;],
863  AC_MSG_RESULT([yes]),
864  AC_MSG_RESULT([no])
865  AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
866  AC_TRY_COMPILE([],
867    [const char *cp = __FUNCTION__;],
868    AC_MSG_RESULT([yes])
869    AC_DEFINE(__func__, __FUNCTION__,
870          [Define to appropriate substitue if compiler doesnt have __func__]),
871    AC_MSG_RESULT([no])
872    AC_DEFINE(__func__, __FILE__,
873          [Define to appropriate substitue if compiler doesnt have __func__])))
874
875 dnl
876 dnl Check for pcre library
877 dnl
878 have_pcre="built-in"
879
880 AC_ARG_ENABLE(internal_pcre,
881                     AC_HELP_STRING([--enable-internal-pcre],[Enable internal PCRE]),
882                     use_internal_pcre="$enableval", use_internal_pcre="no")
883
884 if test "x$use_internal_pcre" != "xyes"; then
885   AC_CHECK_LIB(pcre, pcre_compile, have_pcre_lib=yes, have_pcre_lib=no)
886   AC_CHECK_HEADER(pcre.h, have_pcre_include=yes, have_pcre_include=no)
887   if test "$have_pcre_lib $have_pcre_include" = "yes yes"; then
888      have_pcre="yes"
889   fi
890 fi
891
892 AM_CONDITIONAL(USE_INTERNAL_PCRE, test $have_pcre = "built-in")
893
894 dnl
895 dnl PAM
896 dnl
897 AC_ARG_ENABLE(pam, AC_HELP_STRING([--disable-pam],[Disable PAM support]), use_pam="$enableval", use_pam="yes")
898 if test "x$use_pam" = "xyes"; then
899      AC_CHECK_LIB(pam, pam_start, have_pam_lib=yes, have_pam_lib=no)
900      AC_CHECK_LIB(pam, _pam_dispatch, have_pam_dispatch=yes, have_pam_dispatch=no)
901      AC_CHECK_HEADER(security/pam_modules.h, have_pam_include=yes, have_pam_include=no)
902      AC_CHECK_HEADERS(security/_pam_macros.h security/pam_appl.h)
903 fi
904
905 if test "$use_pam $have_pam_lib $have_pam_include" = "yes yes yes"; then
906    have_pam="yes"
907 else
908    have_pam="no"
909 fi
910 AM_CONDITIONAL(HAVE_PAM, test "x$have_pam" = "xyes")
911
912 if test "$have_pam_dispatch" = "yes"; then
913         AC_DEFINE(HAVE_PAM_DISPATCH, 1, [Have _pam_dispatch function])
914 fi
915
916 dnl
917 dnl crypt()
918 dnl
919 AC_CHECK_HEADERS(crypt.h)
920
921 AC_CHECK_FUNC(crypt, system_crypt="yes", system_crypt="no")
922 AC_CHECK_LIB(crypt, crypt, have_crypt_lib="yes", have_crypt_lib="no")
923 if test "x$have_crypt_lib" = "xyes"; then
924         CRYPT_LIBS="-lcrypt"
925         AC_SUBST(CRYPT_LIBS)
926 fi
927
928 use_crypt="no"
929 if test "$system_crypt $have_crypt_lib" != "no no"; then
930    use_crypt="yes"
931    AC_DEFINE(HAVE_CRYPT, 1, [Have crypt function])
932 fi
933
934 dnl
935 dnl crypt_r()
936 dnl
937 AC_CHECK_FUNC(crypt_r, system_crypt_r="yes", system_crypt_r="no")
938 AC_CHECK_LIB(crypt, crypt_r, have_crypt_r_lib="yes", have_crypt_r_lib="no")
939
940 use_crypt_r="no"
941 if test "$system_crypt_r $have_crypt_r_lib" != "no no"; then
942    use_crypt_r="yes"
943    AC_DEFINE(HAVE_CRYPT_R, 1, [Have crypt_r function])
944 fi
945
946 dnl
947 dnl crypt_r and pthread
948 dnl
949 if test "$use_crypt_r" = "yes"; then
950         dnl
951         dnl struct crypt_data
952         dnl
953         oldcflags="$CFLAGS"
954         CFLAGS="$CFLAGS -D_GNU_SOURCE"
955
956         AC_MSG_CHECKING([for struct crypt_data])
957         AC_TRY_COMPILE([#include <crypt.h>],
958                                 [struct crypt_data data;]
959                             ,
960                                 AC_MSG_RESULT([-D_GNU_SOURCE])
961                                 CRYPT_CFLAGS="-D_GNU_SOURCE"
962                                 AC_SUBST(CRYPT_CFLAGS)
963                             ,
964                                 AC_MSG_ERROR([struct crypt_data is not known]))
965
966         CFLAGS="$oldcflags"
967 fi
968
969 AM_CONDITIONAL(USE_CRYPT, test "x$use_crypt x$use_crypt_r" != "xno xno")
970
971
972 dnl
973 dnl SSL and TLS
974 dnl
975 AC_ARG_ENABLE([tls],
976 [AC_HELP_STRING([--disable-tls],[Disable TLS/SSL support])
977 AC_HELP_STRING([--enable-tls=[gnutls|openssl]])],
978                     enable_tls="$enableval", enable_tls="undef")
979
980 case "$enable_tls" in
981         no)
982                 check_gnutls=no
983                 check_openssl=no
984                 ;;
985         undef|yes)
986                 check_gnutls=yes
987                 check_openssl=yes
988                 ;;
989         gnu*)
990                 check_gnutls=yes
991                 check_openssl=no
992                 ;;
993         open*)
994                 check_gnutls=no
995                 check_openssl=yes
996                 ;;     
997         *)
998                 AC_MSG_ERROR([Incorrect TLS library])
999                 ;;
1000 esac
1001
1002 have_tls="no"
1003
1004 if test "$check_gnutls" = "yes"  && test "$have_tls" = "no"
1005 then
1006                 dnl
1007                 dnl GNUTLS
1008                 dnl
1009                 PKG_CHECK_MODULES(GNUTLS, gnutls >= "1.0.4", [have_gnutls=yes], [have_gnutls=no])
1010                 if test "$have_gnutls" = "yes"
1011                 then
1012                            TLS_LIBS="$GNUTLS_LIBS"
1013                            TLS_CFLAGS="$GNUTLS_CFLAGS"
1014
1015                            AC_CHECK_LIB(gcrypt, gcry_control, [TLS_LIBS="$TLS_LIBS -lgcrypt"])
1016                            AC_CHECK_LIB(gpg-error, gpg_strerror, [TLS_LIBS="$TLS_LIBS -lgpg-error"])
1017
1018                            AC_SUBST(TLS_LIBS)
1019                            AC_SUBST(TLS_CFLAGS)
1020
1021                            AC_DEFINE(HAVE_TLS, 1, [Have TLS support])
1022                            AC_DEFINE(HAVE_GNUTLS, 1, [Have libgnutls])
1023                            have_tls="gnutls"
1024                 else
1025                            enable_tls=no
1026                 fi
1027 fi
1028
1029 if test "$check_openssl" = "yes" && test "$have_tls" = "no"
1030 then
1031                 dnl
1032                 dnl OpenSSL
1033                 dnl
1034                 AC_CHECK_LIB(crypto, BN_init)
1035
1036                 AC_CHECK_HEADERS([openssl/engine.h])
1037                 AC_CHECK_LIB(ssl, SSL_accept, [have_openssl=yes], [have_openssl=no])
1038                 if test "$have_openssl" = "yes"
1039                 then
1040                         TLS_LIBS="-lssl"
1041                         AC_SUBST(TLS_LIBS)
1042
1043                         AC_DEFINE(HAVE_TLS, 1, [Have TLS support])
1044                         AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL library])
1045                         have_tls="openssl"
1046                 else
1047                         enable_tls=no
1048                 fi
1049 fi
1050
1051 dnl
1052 dnl LDAP
1053 dnl
1054 AC_ARG_WITH([ldap],
1055         AC_HELP_STRING([--with-ldap=@<:@ARG@:>@],
1056             [use OpenLDAP development library @<:@default=yes@:>@, optionally specify path to dev libs]
1057         ),
1058         [
1059         if test "$withval" = "no"; then
1060             want_ldap="no"
1061         elif test "$withval" = "yes"; then
1062             want_ldap="yes"
1063         else
1064             want_ldap="yes"
1065             LDAP_CONFIG="$withval"
1066         fi
1067         ],
1068         [want_ldap="yes"]
1069 )
1070
1071 if test "$want_ldap" = "yes"; then
1072        AC_CHECK_LIB(ldap, ldap_init, have_ldap_lib=yes, have_ldap_lib=no)
1073        AC_CHECK_HEADER(ldap.h, have_ldap_include=yes, have_ldap_include=no)
1074
1075           AC_CHECK_LIB(ldap, ldap_start_tls_s, [
1076                 AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
1077           ])
1078
1079        if test "$have_ldap_lib $have_ldap_include" = "yes yes"; then
1080           have_ldap="yes"
1081        else
1082           have_ldap="no"
1083        fi
1084 else
1085        have_ldap="no"
1086 fi
1087
1088 AM_CONDITIONAL(HAVE_LDAP, test $have_ldap = "yes")
1089
1090
1091 dnl
1092 dnl Check for MySQL 4.0.0 support
1093 dnl
1094 AX_LIB_MYSQL(4.0.0)
1095
1096 dnl
1097 dnl GeoIP library
1098 dnl
1099 AC_ARG_WITH([geoip],
1100         AC_HELP_STRING([--with-geoip=@<:@ARG@:>@],
1101             [use the GeoIP library @<:@default=yes@:>@, optionally specify path to dev libs]
1102         ),
1103         [
1104         if test "$withval" = "no"; then
1105             want_geoip="no"
1106         elif test "$withval" = "yes"; then
1107             want_geoip="yes"
1108         else
1109             want_geoip="yes"
1110             GEOIP_CONFIG="$withval"
1111         fi
1112         ],
1113         [want_geoip="yes"]
1114 )
1115
1116 if test "$want_geoip" = "yes"; then
1117    AC_CHECK_LIB(GeoIP, GeoIP_new, have_geoip_lib=yes, have_geoip_lib=no)
1118    AC_CHECK_HEADERS(GeoIP.h, have_geoip_include=yes, have_geoip_include=no)
1119 fi
1120
1121 have_geoip="no"
1122 if test "$have_geoip_lib $have_geoip_include" = "yes yes"; then
1123    have_geoip="yes"
1124 fi
1125
1126 AM_CONDITIONAL(HAVE_GEOIP, test $have_geoip = "yes")
1127
1128
1129 dnl
1130 dnl WWW root directory
1131 dnl
1132 AC_ARG_WITH(wwwroot, AC_HELP_STRING([--with-wwwroot=DIR], [Set the WWW root directory]),
1133                   WWW_ROOT="$withval", WWW_ROOT="$localstatedir/www")
1134
1135 AC_SUBST(WWW_ROOT)
1136
1137
1138 dnl
1139 dnl Look for misc binaries
1140 dnl
1141 AC_PATH_PROG(PHPCGI, php-cgi)
1142 AC_ARG_VAR(PHPCGI, [path to PHP-cgi])
1143
1144 AC_MSG_CHECKING([$PHPCGI supports FastCGI])
1145 if test "x$PHPCGI" = "x"; then
1146    AC_MSG_RESULT([no])
1147 else
1148    $PHPCGI -v | grep 'cgi-fcgi' >/dev/null 2>/dev/null
1149    if test $? != 0; then
1150       PHPCGI=""
1151       AC_MSG_RESULT([no])
1152    else
1153       AC_MSG_RESULT([yes])
1154    fi
1155 fi
1156
1157 if test "x$PHPCGI" = "x"; then
1158    for n in php-cgi php; do
1159      for p in /usr/lib/cgi-bin /usr/bin /usr/local/bin; do
1160        phpcgi_path="$p/php-cgi"
1161           AC_MSG_CHECKING([for $phpcgi_path])
1162           if test -x "$phpcgi_path"; then
1163              $phpcgi_path -v | grep 'cgi-fcgi' >/dev/null 2>/dev/null
1164                 if test $? = 0; then
1165                   PHPCGI=$phpcgi_path
1166                AC_MSG_RESULT([yes])
1167                 else
1168                AC_MSG_RESULT([not fcgi])
1169                 fi
1170                 break
1171           else
1172              AC_MSG_RESULT([no])
1173           fi
1174      done
1175         if test "x$PHPCGI" != x; then
1176           break;
1177         fi
1178    done
1179 fi
1180
1181 if test "x$PHPCGI" = "x"; then
1182    PHPCGI="php-cgi"
1183 fi
1184
1185 AC_SUBST(PHPCGI)
1186
1187
1188 dnl
1189 dnl Options
1190 dnl
1191 use_static_module=""
1192 AC_ARG_ENABLE(static-module,
1193            AC_HELP_STRING([--enable-static-module=MODULE][]),
1194            [use_static_module="$use_static_module $enableval "],[])
1195
1196 modules="error_redir error_nn server_info file admin dirlist fcgi fastcgi scgi redir common cgi phpcgi proxy mirror custom_error gzip deflate ncsa combined w3c pam ldap mysql htpasswd plain htdigest round_robin directory extensions request header geoip not and or"
1197
1198 # Remove modules that will not be compiles
1199 #
1200 if test "x$have_pam" != "xyes"; then
1201         modules=`echo $modules | sed s/pam//`
1202 fi
1203 if test "x$have_ldap" != "xyes"; then
1204         modules=`echo $modules | sed s/ldap//`
1205 fi
1206 if test "x$have_mysql" != "xyes"; then
1207         modules=`echo $modules | sed s/mysql//`
1208 fi
1209 if test "x$have_geoip" != "xyes"; then
1210         modules=`echo $modules | sed s/geoip//`
1211 fi
1212 if test "$use_crypt" != "yes"; then
1213         modules=`echo $modules | sed s/htpasswd//`
1214 fi
1215
1216 add_calls=""
1217 init_calls=""
1218 headers=""
1219 ext_defs=""
1220
1221 for mod in $modules; do
1222         AC_MSG_CHECKING([module "$mod"])
1223
1224         if echo $use_static_module | grep -w $mod >/dev/null || echo $use_static_module | grep all >/dev/null; then
1225