root/cherokee/trunk/configure.in @ 3948

Revision 3948, 42.9 KB (checked in by alo, 9 months ago)

Cherokee 0.99.32 released

  • Property svn:keywords set to Id
Line 
1dnl -*- mode: m4-mode -*-
2dnl Process this file with autoconf to produce a configure script.
3
4AC_COPYRIGHT([
5Copyright (C) 2001-2009 Alvaro Lopez Ortega
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of version 2 of the GNU General Public
9License as published by the Free Software Foundation.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19USA
20])
21
22dnl require autoconf 2.60
23AC_PREREQ([2.60])
24
25dnl Version
26m4_define([cherokee_major_version], [0])
27m4_define([cherokee_minor_version], [99])
28m4_define([cherokee_micro_version], [33])
29m4_define([cherokee_version], m4_format('%s.%s.%s', cherokee_major_version, cherokee_minor_version, cherokee_micro_version))
30
31dnl Init autoconf and automake
32AC_INIT([cherokee], [cherokee_version], [http://bugs.cherokee-project.com/], [cherokee])
33AC_CONFIG_SRCDIR([cherokee/server.c])
34AC_CONFIG_MACRO_DIR([m4])
35AM_INIT_AUTOMAKE([no-define])
36
37dnl Define version
38AC_DEFINE(PACKAGE_MAJOR_VERSION, "cherokee_major_version", [Version string])
39AC_DEFINE(PACKAGE_MINOR_VERSION, "cherokee_minor_version", [Version string])
40AC_DEFINE(PACKAGE_MICRO_VERSION, "cherokee_micro_version", [Version string])
41
42PACKAGE_MAJOR_VERSION="cherokee_major_version"
43PACKAGE_MINOR_VERSION="cherokee_minor_version"
44PACKAGE_MICRO_VERSION="cherokee_micro_version"
45AC_SUBST(PACKAGE_MAJOR_VERSION)
46AC_SUBST(PACKAGE_MINOR_VERSION)
47AC_SUBST(PACKAGE_MICRO_VERSION)
48
49dnl Define library soname
50CHEROKEE_AGE=0
51CHEROKEE_CURRENT=0
52CHEROKEE_REVISION=1
53AC_SUBST(CHEROKEE_AGE)
54AC_SUBST(CHEROKEE_CURRENT)
55AC_SUBST(CHEROKEE_REVISION)
56
57AC_DEFINE_UNQUOTED(CHEROKEE_CONFIG_ARGS, "$ac_configure_args", [configure arguments])
58
59dnl Check the SVN revision
60AC_ARG_ENABLE(beta, AC_HELP_STRING([--enable-beta], [Enable beta development]),
61                    is_beta="$enableval", is_beta="no")
62
63if test x"$is_beta" = "xyes"; then
64  if test -d ".svn"; then
65     svn_rev="`svn info -R | grep Revision | sort | tail -1 | sed 's/Revision: //'`";
66  else
67    if test -d ".git"; then
68          svn_rev="`git svn info | grep 'Last Changed Rev' | sed 's/Last Changed Rev: //'`";
69    fi
70  fi
71
72  PACKAGE_PATCH_VERSION="b$svn_rev"
73
74  dnl Redefine versions
75  PACKAGE_VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
76  AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "${PACKAGE_VERSION}", [Package version])
77
78  VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
79  AC_DEFINE(VERSION, $VERSION, [Software version])
80else
81
82  PACKAGE_PATCH_VERSION=""
83fi
84
85dnl Path version
86AC_SUBST(PACKAGE_PATCH_VERSION)
87AC_DEFINE_UNQUOTED(PACKAGE_PATCH_VERSION, "${PACKAGE_PATCH_VERSION}", [Version string])
88
89dnl Initial CFLAGS
90AC_MSG_CHECKING(initial CFLAGS)
91AC_MSG_RESULT($CFLAGS)
92
93dnl Check for CPU / vendor / OS
94AC_CANONICAL_HOST
95
96os_string="UNIX"
97so_suffix=so
98mod_suffix=$so_suffix
99
100AC_MSG_CHECKING([host platform characteristics])
101        case "$host" in
102        *-*-mingw*|*-*-cygwin*)
103                so_suffix=DLL
104                mod_suffix=$so_suffix
105             os_string="Win32"
106          libdl=
107          ;;
108        *-*-linux*)
109          libdl="-ldl"
110          ;;
111        *-*-solaris*)
112             AC_DEFINE(SOLARIS, 1, [It is Solaris])         
113                setenv_is_threadsafe="yes"
114          libdl="-ldl"
115          ;;
116        *-*-hpux*)
117          libdl="-ldl"
118          ;;
119        *-*-aix*)
120          libdl="-ldl"
121             ;;
122     *-*-irix6*)
123          AC_DEFINE(IRIX, 1, [It is SGI Irix])
124          setenv_is_threadsafe="yes"
125          libdl="-ldl"
126          ;;
127        *-*-*freebsd*|*-*-*openbsd*|*-*-*netbsd*|*-*-*dragonfly*)
128          libdl=
129          ;;
130        *-*-darwin*)
131                so_suffix=dylib
132                mod_suffix=so
133          libdl="-ldl"
134          ;;
135        *)
136                AC_MSG_WARN([*** Please add $host to configure.in checks!])
137          libdl="-ldl"
138          ;;
139esac
140AC_MSG_RESULT(ok)
141
142AC_MSG_CHECKING([L2 cache line size])
143case "$host_cpu" in
144        i386|i486)
145                CPU_CACHE_LINE=32
146        ;;
147        i586|i686)
148                CPU_CACHE_LINE=64
149        ;;
150        i786)   
151                CPU_CACHE_LINE=128
152        ;;
153        athlon)
154                CPU_CACHE_LINE=64
155        ;;
156        x86_64)
157                CPU_CACHE_LINE=64
158        ;;
159        sparc*)
160                CPU_CACHE_LINE=64
161        ;;
162        powerpc)
163                CPU_CACHE_LINE=128
164        ;;
165        *)
166                CPU_CACHE_LINE=128
167        ;;
168esac
169AC_DEFINE_UNQUOTED(CPU_CACHE_LINE, $CPU_CACHE_LINE, [L2 cache line size])
170AC_MSG_RESULT($CPU_CACHE_LINE)
171
172dnl
173dnl OS string
174dnl
175AC_ARG_ENABLE(os_string, AC_HELP_STRING([--enable-os-string=STR], [Set a customized OS type string]), [os_string="$enableval"])
176AC_DEFINE_UNQUOTED(OS_TYPE, "${os_string}", [OS type])
177
178AM_CONDITIONAL(PLATFORM_WIN32, test x"$os_string" = "xWin32")
179
180dnl
181dnl Tracing
182dnl
183AC_ARG_ENABLE(trace, AC_HELP_STRING([--enable-trace], [Enable trace facility]),
184   [enable_trace="$enableval"
185    AC_DEFINE(TRACE_ENABLED, 1, [Trace facility])
186   ], [enable_trace="no"])
187
188dnl
189dnl Backtraces
190dnl
191AC_ARG_ENABLE(backtraces, AC_HELP_STRING([--enable-backtraces], [Enable backtraces on error]),
192   [enable_backtraces="$enableval"
193    AC_DEFINE(BACKTRACES_ENABLED, 1, [Backtracing facility])
194   ], [enable_backtraces="no"])
195
196dnl
197dnl Dynamic library loading library
198dnl
199LIBS="$LIBS $libdl"
200AC_DEFINE_UNQUOTED(SO_SUFFIX, "${so_suffix}", [Dynamic loading libraries extension])
201AC_DEFINE_UNQUOTED(MOD_SUFFIX, "${mod_suffix}", [Dynamic modules extension])
202
203dnl
204dnl Libtool options
205dnl
206if test "$os_string" != "Win32"; then
207    # libtool option to control which symbols are exported
208    # right now, symbols starting with _ are not exported
209    LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
210else
211    LIBTOOL_EXPORT_OPTIONS=
212fi
213AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
214
215dnl Set the Version
216AM_INIT_AUTOMAKE(cherokee, $VERSION)
217AM_MAINTAINER_MODE
218
219AM_CONFIG_HEADER(config.h)
220AC_SUBST(VERSION)
221
222dnl Initialize Libtool
223m4_ifdef([LT_INIT],
224  [LT_INIT([dlopen shared static win32-dll])],
225  [AC_LIBTOOL_DLOPEN
226   AC_LIBTOOL_WIN32_DLL
227   ])
228
229dnl Paths
230AC_PROG_CC
231AC_PROG_CC_STDC
232AC_PROG_INSTALL
233AC_PROG_MAKE_SET
234AM_PROG_LIBTOOL
235
236AC_PATH_PROG(cherokeepath, cherokee)
237
238AC_FUNC_CLOSEDIR_VOID
239AC_FUNC_MALLOC
240AC_FUNC_REALLOC
241AC_FUNC_VPRINTF
242
243AC_C_CONST
244AC_C_BIGENDIAN
245AC_C_INLINE
246if test "$ac_cv_c_inline" != no; then
247  AC_DEFINE(HAVE_INLINE, 1, [Compile supports inline])
248fi
249
250dnl
251dnl Check for headers
252dnl
253AC_HEADER_STDC
254AC_HEADER_DIRENT
255AC_HEADER_TIME
256AC_HEADER_SYS_WAIT
257
258AC_CHECK_HEADERS(endian.h machine/endian.h sys/machine.h sys/endian.h sys/isa_defs.h sys/utsname.h sys/poll.h poll.h )
259AC_CHECK_HEADERS(sys/socket.h sys/un.h netinet/in.h arpa/inet.h netinet/tcp.h sys/ioctl.h fcntl.h sys/ofcntl.h sys/time.h)
260AC_CHECK_HEADERS(sys/resource.h resource.h unistd.h syslog.h stdint.h inttypes.h error.h pwd.h sys/uio.h)
261AC_CHECK_HEADERS(pthread.h netdb.h stdarg.h sys/filio.h sys/varargs.h sys/select.h sys/mman.h sys/uio.h grp.h winsock.h)
262AC_CHECK_HEADERS(winsock.h winsock2.h sched.h execinfo.h)
263
264AC_SYS_LARGEFILE
265
266AC_SIZE_T
267AC_TYPE_UID_T
268AC_TYPE_MODE_T
269AC_TYPE_OFF_T
270AC_TYPE_SIZE_T
271AC_TYPE_PID_T
272AC_STRUCT_ST_RDEV
273AC_CHECK_TYPE(ino_t, unsigned)
274AC_CHECK_TYPE(loff_t, off_t)
275AC_CHECK_TYPE(offset_t, loff_t)
276AC_CHECK_TYPE(ssize_t, int)
277AC_CHECK_TYPE(wchar_t, unsigned short)
278
279AC_CHECK_SIZEOF(int)
280AC_CHECK_SIZEOF(unsigned int)
281AC_CHECK_SIZEOF(unsigned long)
282AC_CHECK_SIZEOF(unsigned long long)
283AC_CHECK_SIZEOF(unsigned int)
284AC_CHECK_SIZEOF(off_t)
285AC_CHECK_SIZEOF(size_t)
286AC_CHECK_SIZEOF(sig_atomic_t)
287
288AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
289AC_TRY_RUN([#include <stdio.h>
290main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
291samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
292if test x"$samba_cv_have_longlong" = x"yes"; then
293    AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long'])
294fi
295
296AC_FUNC_MEMCMP
297AC_FUNC_MMAP
298AC_FUNC_FORK
299
300AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r getrlimit getdtablesize readdir readdir_r flockfile funlockfile strnstr backtrace)
301
302FW_CHECK_PWD
303FW_CHECK_GRP
304
305AC_CHECK_MEMBER(struct tm.tm_gmtoff,
306                AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm]),,[#include <time.h>])
307
308AH_BOTTOM([
309/* Give us an unsigned 32-bit data type. */
310#if SIZEOF_UNSIGNED_LONG==4
311#define UWORD32 unsigned long
312#elif SIZEOF_UNSIGNED_INT==4
313#define UWORD32 unsigned int
314#else
315#error I do not know what to use for a UWORD32.
316#endif
317])
318
319
320dnl Find socket()
321dnl Likely combinations:
322dnl             -lsocket [ -lnsl_s | -lnsl ]
323dnl             -linet
324AC_CHECK_LIB(ws2_32, main)
325AC_CHECK_LIB(advapi32, main)
326
327AC_CHECK_FUNC(socket, :, [     
328        AC_CHECK_LIB(socket, main)
329        AC_CHECK_LIB(net, main)
330        AC_CHECK_LIB(nsl_s, main)
331        AC_CHECK_LIB(nsl, main)
332        AC_CHECK_LIB(inet, socket)
333        AC_CHECK_LIB(gen, main)
334])
335
336AC_SEARCH_LIBS(accept, socket)
337AC_SEARCH_LIBS(bind, socket)
338AC_SEARCH_LIBS(listen, socket)
339AC_SEARCH_LIBS(setsockopt, socket)
340
341dnl
342dnl Check for fd events inspect functions
343dnl
344AC_CHECK_FUNC(poll, have_poll=yes)
345AC_CHECK_FUNC(kqueue, have_kqueue=yes)
346AC_CHECK_FUNC(select, have_select=yes)
347
348if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes"; then
349     AC_MSG_CHECKING([for select in ws2_32])
350     AC_TRY_LINK([#include <winsock2.h>],
351                                [select(0,0,0,0,0)],
352                                [AC_MSG_RESULT(yes)
353                                 have_win32_select=yes],
354                                [AC_MSG_RESULT(no)])
355fi
356
357dnl
358dnl Epoll
359dnl
360AC_CHECK_HEADER(sys/epoll.h, have_epoll_include=yes, have_epoll_include=no)
361
362AC_ARG_ENABLE(epoll, AC_HELP_STRING([--disable-epoll],[Disable epoll() support]),
363                    wants_epoll="$enableval", wants_epoll="yes")
364
365have_epoll=no
366if test "x$have_epoll_include" = "xyes" && test "x$wants_epoll" = "xyes"; then
367        AC_MSG_CHECKING(for epoll system call)
368
369     AC_RUN_IFELSE([
370                #include <stdint.h>
371                #include <sys/param.h>
372                #include <sys/types.h>
373                #include <sys/syscall.h>
374                #include <sys/epoll.h>
375                #include <unistd.h>
376
377                int epoll_create (int size) {
378                return (syscall(__NR_epoll_create, size));
379                }
380       
381                int main (int argc, char **argv) {
382                int epfd;
383                epfd = epoll_create(256);
384                   exit (epfd == -1 ? 1 : 0);
385                }
386        ],
387        have_epoll=yes,
388        have_epoll=no,
389        have_epoll=yes)
390        AC_MSG_RESULT($have_epoll)
391fi
392
393dnl
394dnl Solaris 10: Event ports
395dnl
396AC_CHECK_HEADER(port.h, have_port_include=yes, have_port_include=no)
397
398have_port=no
399if test "x$have_port_include" = "xyes"; then
400        AC_MSG_CHECKING(for event ports support)
401
402     AC_RUN_IFELSE([
403                #include <stdint.h>
404                #include <unistd.h>
405                #include <port.h>
406       
407                int main (int argc, char **argv) {
408                int port;
409                   port = port_create();
410                   exit (port < 0 ? 1 : 0);
411                }
412        ],
413        have_port=yes,
414        have_port=no,
415        have_port=cross)
416        AC_MSG_RESULT($have_port)
417fi
418
419
420
421if test "$have_epoll" = yes; then
422        AC_DEFINE(HAVE_EPOLL, 1, [Have epoll])
423fi
424AM_CONDITIONAL(COMPILE_EPOLL, test x"$have_epoll" = "xyes")
425
426if test "$have_kqueue" = yes; then
427        AC_DEFINE(HAVE_KQUEUE, 1, [Have kqueue])
428fi
429AM_CONDITIONAL(COMPILE_KQUEUE, test x"$have_kqueue" = "xyes")
430
431if test "$have_port" = yes; then
432        AC_DEFINE(HAVE_PORT, 1, [Have event ports])
433fi
434AM_CONDITIONAL(COMPILE_PORT, test x"$have_port" = "xyes")
435
436if test "$have_poll" = yes; then
437        AC_DEFINE(HAVE_POLL, 1, [Have poll])
438fi
439AM_CONDITIONAL(COMPILE_POLL, test x"$have_poll" = "xyes")
440
441if test "$have_win32_select" = yes; then
442        AC_DEFINE(HAVE_WIN32_SELECT, 1, [Have Win32 select])
443fi
444AM_CONDITIONAL(COMPILE_WIN32_SELECT, test x"$have_win32_select" = "xyes")
445
446if test "$have_select" = yes; then
447     AC_DEFINE(HAVE_SELECT, 1, [Have select])
448fi
449AM_CONDITIONAL(COMPILE_SELECT, test x"$have_select" = "xyes" -a x"$have_win32_select" != "xyes")
450
451
452dnl
453dnl Check for inet_pton.  We have our own, but on Solaris the version in
454dnl libresolv is more lenient in ways that Solaris's internal DNS resolution
455dnl code requires, so if we use our own *and* link with libresolv (which may
456dnl be forced by Perl) DNS resolution fails.
457dnl
458AC_SEARCH_LIBS(inet_pton, [socket nsl resolv])
459AC_CHECK_FUNCS(inet_pton inet_ntop inet_addr)
460
461AC_SEARCH_LIBS(gethostbyname, [socket nsl resolv])
462AC_CHECK_FUNCS(gethostbyname gethostbyname_r)
463
464AC_CHECK_HEADER(sys/utsname.h)
465AC_CHECK_FUNCS(gethostname uname)
466
467dnl
468dnl Check for inet_addr
469dnl
470AC_SEARCH_LIBS(inet_addr, xnet)
471AC_CHECK_FUNCS(inet_addr)
472
473dnl
474dnl TCP_CORK
475dnl
476HYDRA_TCP_CORK
477HYDRA_TCP_NOPUSH
478
479dnl
480dnl Check for GNU getopt_long()
481dnl
482AC_CHECK_HEADERS(getopt.h)
483AC_CHECK_FUNC(getopt_long, have_getopt_long="yes")
484AM_CONDITIONAL(HAVE_GETOPT_LONG, test "x$have_getopt_long" = "xyes")
485
486
487dnl
488dnl Pthread
489dnl
490with_pthread="yes"
491have_pthread="no"
492AC_ARG_ENABLE(pthread, AC_HELP_STRING([--disable-pthread],[Disable threading support]),
493                    with_pthread="$enableval", with_pthread="yes")
494
495AM_CONDITIONAL(USE_PTHREAD, test "x$with_pthread" = "xyes")
496if test "x$with_pthread" = "xyes"
497then
498        dnl
499     dnl Basic checkings (c&p'ed from squid)
500        dnl
501        AC_MSG_CHECKING([for special a pthread case])
502
503        oldcflags="$CFLAGS"
504     CFLAGS="$CFLAGS -D_REENTRANT"
505        PTHREAD_CFLAGS="-D_REENTRANT"
506
507        case "$host" in
508           i386-unknown-freebsd*)
509           if test "$GCC" = "yes" ; then
510              if test -z "$PRESET_LDFLAGS"; then
511                PTHREAD_LIBS="-pthread"
512                         have_pthread="yes"
513              fi
514           fi
515                 AC_MSG_RESULT([-pthread])
516           ;;
517       *-solaris2.*)
518           if test "$GCC" = "yes" ; then
519              CFLAGS="$CFLAGS -pthreads"
520              PTHREAD_CFLAGS="-pthreads"
521                    AC_MSG_RESULT([-pthreads])
522           else
523              CFLAGS="$CFLAGS -mt"
524              PTHREAD_CFLAGS="-mt"
525                    AC_MSG_RESULT([-mt])
526           fi
527              have_pthread="yes"
528           ;;
529          *)
530                 AC_MSG_RESULT([no])
531                 ;;
532     esac
533
534        if test "$have_pthread" != "yes"; then
535        AC_CHECK_LIB(pthread, main, have_pthread=yes, have_pthread=no)
536           if test "$have_pthread" = "yes"; then
537                 PTHREAD_LIBS="-lpthread"   
538           fi
539     fi
540
541        dnl
542        dnl More detailed checks on the pthread support
543        dnl
544        AC_MSG_CHECKING([for pthread_rwlock_t support])
545
546        have_pthread_rwlock_t=yes
547        AC_TRY_COMPILE([#include <pthread.h>],
548                        [pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
549                        compiled=yes, compiled=no)
550
551        if test "$compiled" = "yes"; then
552                AC_MSG_RESULT([ok])
553        else
554             dnl Didn't find rwlock_t.
555             dnl Try defining _XOPEN_SOURCE=500
556             dnl
557                oldcflags2="$CFLAGS"
558                CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"
559
560                AC_TRY_COMPILE([#include <pthread.h>],
561                            [pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
562                            compiled=yes, compiled=no)
563
564                if test "$compiled" = "yes"; then
565                    AC_MSG_RESULT([-D_XOPEN_SOURCE=500])
566                    PTHREAD_CFLAGS="-D_XOPEN_SOURCE=500"
567                else
568                    have_pthread_rwlock_t=no
569                    AC_MSG_RESULT([no])
570                fi
571
572                CFLAGS="$oldcflags2"
573        fi
574
575        if test "$have_pthread_rwlock_t" = "yes"; then
576                AC_DEFINE(HAVE_PTHREAD_RWLOCK_T, 1, [Define if your pthread library includes pthread_rwlock_t])
577        else
578                AC_MSG_ERROR([pthread_rwlock_t support missing])
579        fi
580
581        AC_CHECK_FUNC(pthread_attr_setschedpolicy, have_pthread_attr_setschedpolicy=yes)
582        if test x"$have_pthread_attr_setschedpolicy" = "xyes"; then
583             AC_DEFINE(HAVE_PTHREAD_SETSCHEDPOLICY, 1, [Pthread support pthread_attr_setschedpolicy])
584        fi
585
586        save_LIBS="$LIBS"
587        LIBS="$LIBS $PTHREAD_LIBS"
588
589        AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
590
591        dnl
592        dnl Yield
593        dnl
594        AC_CHECK_FUNCS(sched_yield, , [
595           AC_CHECK_LIB(rt, sched_yield, [
596               AC_DEFINE(HAVE_SCHED_YIELD)
597                  PTHREAD_LIBS="$PTHREAD_LIBS -lrt"
598           ],[
599               AC_CHECK_LIB(posix4, sched_yield, [
600                  AC_DEFINE(HAVE_SCHED_YIELD)
601          PTHREAD_LIBS="$PTHREAD_LIBS -lposix4"
602           ])])
603     ])
604
605        LIBS="$save_LIBS"
606        CFLAGS="$oldcflags"
607fi
608
609if test "$have_pthread" = "yes"; then
610        AC_DEFINE(HAVE_PTHREAD, 1, [Have pthread support])
611        AC_SUBST(PTHREAD_CFLAGS)
612        AC_SUBST(PTHREAD_LIBS)
613fi
614
615
616dnl
617dnl Is setenv() threadsafe?
618dnl
619if test "$setenv_is_threadsafe" = "yes"; then
620AC_DEFINE(SETENV_IS_THREADSAFE, 1, [setenv function is thread safe])
621fi
622
623dnl
624dnl Check for vsyslog
625dnl
626AC_CHECK_FUNCS(syslog vsyslog strsep strcasestr memmove strerror bcopy strlcat)
627
628dnl
629dnl Check for Glib (usually Linux)
630dnl
631AC_PREPROC_IFELSE([
632#include <features.h>
633#ifndef __GLIBC__
634    chokeme
635#endif
636], [
637    AC_DEFINE([HAVE_GLIBC], [1], [Define to 1 if you have glibc.])
638    AC_DEFINE([_GNU_SOURCE], [1], [Define to 1 if you have glibc.])
639])
640
641dnl
642dnl Does this platform require array notation to assign to a va_list?
643dnl If cross-compiling, we assume va_list is "normal".  If this breaks
644dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
645dnl also just to be sure.
646dnl
647AC_MSG_CHECKING(whether va_list assignments need array notation)
648AC_CACHE_VAL(ac_cv_valistisarray,
649        [AC_TRY_RUN([#include <stdlib.h>
650                     #include <stdarg.h>
651                     void foo(int i, ...) {
652                        va_list ap1, ap2;
653                        va_start(ap1, i);
654                        ap2 = ap1;
655                        if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
656                        va_end(ap1); va_end(ap2);
657                     }
658                     int main()
659                     { foo(0, 123); return(0); }],
660                    [ac_cv_valistisarray=false],
661                    [ac_cv_valistisarray=true],
662                    [ac_cv_valistisarray=false])])
663                                             
664if test "$ac_cv_valistisarray" = true ; then
665        AC_DEFINE(HAVE_VA_LIST_AS_ARRAY,,[va_list works copying an array])
666        AC_MSG_RESULT(yes)
667else
668        AC_MSG_RESULT(no)
669fi
670
671
672dnl
673dnl Check if the global variable `timezone' exists. If so, define
674dnl HAVE_INT_TIMEZONE.
675dnl
676AC_STRUCT_TIMEZONE
677
678AC_MSG_CHECKING(for global timezone)
679AC_TRY_LINK([#include <time.h>],
680[int res; res = timezone / 60;],
681[AC_MSG_RESULT(yes)
682AC_DEFINE(HAVE_INT_TIMEZONE,, [Set to 1 if you have the global variable timezone])],
683AC_MSG_RESULT(no))
684
685
686dnl
687dnl Check for RTDL constants (from Haskell code)
688dnl
689dnl ** check for libdl & RTLD_NEXT
690dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
691AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
692AC_EGREP_CPP(yes,
693[
694 #include <dlfcn.h>
695 #ifdef RTLD_NEXT
696        yes
697 #endif
698], [
699  AC_MSG_RESULT(yes)
700  AC_DEFINE(HAVE_RTLDNEXT,,[Have RTDL_NEXT])
701  HaveRtldNext=YES
702], [
703  AC_MSG_RESULT(no)
704  HaveRtldNext=NO
705  ])   
706AC_SUBST(HaveRtldNext)
707
708dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
709AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
710AC_EGREP_CPP(yes,
711[
712 #include <dlfcn.h>
713 #ifdef RTLD_LOCAL
714        yes
715 #endif
716], [
717  AC_MSG_RESULT(yes)
718  AC_DEFINE(HAVE_RTLDLOCAL,,[Have RTDL_LOCAL])
719  HaveRtldLocal=YES
720], [
721  AC_MSG_RESULT(no)
722  HaveRtldLocal=NO
723  ])   
724AC_SUBST(HaveRtldLocal)
725
726dnl ** RTLD_GLOBAL isn't available on openbsd
727AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
728AC_EGREP_CPP(yes,
729[
730 #include <dlfcn.h>
731 #ifdef RTLD_GLOBAL
732        yes
733 #endif
734], [
735  AC_MSG_RESULT(yes)
736  AC_DEFINE(HAVE_RTLDGLOBAL,,[Have RTDL_GLOBAL])
737  HaveRtldGlobal=YES
738], [
739  AC_MSG_RESULT(no)
740  HaveRtldGlobal=NO
741  ])   
742AC_SUBST(HaveRtldGlobal)
743
744dnl ** RTLD_NOW isn't available on openbsd
745AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
746AC_EGREP_CPP(yes,
747[
748 #include <dlfcn.h>
749 #ifdef RTLD_NOW
750        yes
751 #endif
752], [
753  AC_MSG_RESULT(yes)
754  AC_DEFINE(HAVE_RTLDNOW,,[Have RTDL_NOW])
755  HaveRtldNow=YES
756], [
757  AC_MSG_RESULT(no)
758  HaveRtldNow=NO
759  ])   
760AC_SUBST(HaveRtldNow)
761
762
763dnl
764dnl Check of off64_t
765dnl
766AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
767AC_TRY_RUN([
768#if defined(HAVE_UNISTD_H)
769#include <unistd.h>
770#endif
771#include <stdio.h>
772#include <sys/stat.h>
773main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
774samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
775if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
776    AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
777fi
778
779dnl
780dnl Shared Memory
781dnl
782AC_CHECK_FUNC(shm_open, have_shm_open=yes)
783
784RT_LIBS=
785if test "$have_shm_open" != "yes"; then
786  AC_CHECK_LIB(rt, shm_open, [
787                            RT_LIBS="-lrt"
788                            have_shm_open=yes])
789fi
790if test "$have_shm_open" != "yes"; then
791  AC_CHECK_LIB(rt, shm_open, [
792                            RT_LIBS="-lposix4"
793                            have_shm_open=yes])
794fi
795AC_SUBST(RT_LIBS)
796
797if test "$have_shm_open" = "yes"; then
798   AC_DEFINE(HAVE_POSIX_SHM, 1, [Define to 1 to use POSIX shared memory])
799fi
800AM_CONDITIONAL(USE_POSIX_SHM, test "$have_shm_open" = "yes")
801
802
803dnl
804dnl SYSV Semaphores
805dnl
806AC_CHECK_HEADER(sys/sem.h, sysv_sem=yes, sysv_sem=no)
807
808if test "x$sysv_sem" = "xyes"; then
809   AC_CHECK_FUNC(semget, , sysv_sem=no)
810   AC_CHECK_FUNC(semop, , sysv_sem=no)
811   AC_CHECK_FUNC(semctl, , sysv_sem=no)
812fi
813
814if test "x$sysv_sem" = xyes; then
815   AC_DEFINE(HAVE_SYSV_SEMAPHORES, 1, [Define to 1 to use SYSV semaphores])
816fi
817AM_CONDITIONAL(USE_SYSV_SEMAPHORES, test "x$sysv_sem" = xyes)
818
819dnl union semun
820dnl
821AC_MSG_CHECKING([for union semun])
822AC_CACHE_VAL(ac_cv_struct_semun, [
823   AC_TRY_COMPILE(
824        [
825           #include <sys/types.h>
826           #include <sys/ipc.h>
827           #include <sys/sem.h>;
828     ],[
829           union semun semdat;
830        ],
831           ac_cv_struct_semun=yes,
832           ac_cv_struct_semun=no
833     )
834])
835AC_MSG_RESULT($ac_cv_struct_semun)
836if test "$ac_cv_struct_semun" = "yes"; then
837        AC_DEFINE(HAVE_SEMUN, 1, [Define if sys/sem.h defines struct semun])
838fi
839
840
841# From etr_socket_nsl.m4
842ETR_SOCKET_NSL
843
844# From sendfile_samba.m4
845SENDFILE_CHECK
846
847# readdir_r()
848LIBWWW_READDIR_R_TYPE
849
850
851dnl
852dnl IPv6 Support
853dnl I got this mostly from Apache's tests
854dnl
855
856AC_ARG_ENABLE(ipv6,
857  AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support]),
858  [ if test "$enableval" = "no"; then
859       disabled_ipv6=1
860    fi ],
861  [ disabled_ipv6=0 ] )
862
863AC_SEARCH_LIBS(getaddrinfo, socket inet6)
864AC_SEARCH_LIBS(getnameinfo, socket inet6)
865AC_SEARCH_LIBS(gai_strerror, socket inet6)
866AC_CHECK_FUNC(gai_strerror)
867
868APR_CHECK_WORKING_GETADDRINFO
869APR_CHECK_WORKING_GETNAMEINFO
870
871AC_ACME_SOCKADDR_UN
872AC_ACME_SOCKADDR_IN6
873AC_ACME_SOCKADDR_STORAGE
874
875AC_MSG_CHECKING(if the system supports IPv6)
876have_ipv6="no"
877
878if test "$disabled_ipv6" = 1; then
879    AC_MSG_RESULT([no -- disabled by user])
880else
881    if test "x$ac_cv_acme_sockaddr_in6" = "xyes"; then
882        if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
883            if test "x$ac_cv_working_getnameinfo" = "xyes"; then
884                have_ipv6="yes"
885                AC_MSG_RESULT([yes])
886                      AC_DEFINE(HAVE_IPV6, 1, [Define if you have IPv6 support.])
887            else
888                AC_MSG_RESULT([no -- no getnameinfo])
889            fi
890        else
891            AC_MSG_RESULT([no -- no working getaddrinfo])
892        fi
893    else
894        AC_MSG_RESULT([no -- no sockaddr_in6])
895    fi
896fi
897
898dnl
899dnl Test whether SO_RCVTIMEO is broken
900dnl
901AC_CACHE_CHECK([whether setsockopt(SO_RCVTIMEO) is broken],
902  ac_cv_so_rcvtimeo_broken, [dnl
903    AC_RUN_IFELSE([AC_LANG_SOURCE([[
904#if defined(HAVE_SYS_TYPES_H)
905#include <sys/types.h>
906#endif
907
908#if defined(HAVE_SYS_SOCKET_H)
909#include <sys/socket.h>
910#endif
911
912#if defined(HAVE_SYS_TIME_H)
913#include <sys/time.h>
914#endif
915
916int main(void) {
917        int fd;
918        int ret;
919        struct timeval new_tv;
920
921        /* Open the socket (INET/TCP).*/
922        fd = socket(AF_INET, SOCK_STREAM, 0);
923
924        /* set the timeout for the incoming queue */
925        /* 1 second for example */
926        new_tv.tv_sec = 1;
927        new_tv.tv_usec = 0;
928
929        ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &new_tv, sizeof(new_tv));
930        return ret;
931}
932]])],[ac_cv_so_rcvtimeo_broken=no],[ac_cv_so_rcvtimeo_broken=yes],[ac_cv_so_rcvtimeo_broken=cross])])
933if test x"$ac_cv_so_rcvtimeo_broken" = x"yes"; then
934  AC_DEFINE(HAVE_BROKEN_SO_RCVTIMEO, 1, [Define if setsockopt(SO_RCVTIMEO) is broken])
935fi
936
937
938dnl
939dnl Look for socklen_t
940dnl
941AC_MSG_CHECKING([for socklen_t])
942AC_TRY_COMPILE(
943 [#include <sys/types.h>
944  #include <sys/socket.h>],
945 [socklen_t len = 42; return 0;],
946 ac_cv_type_socklen_t=yes,
947 ac_cv_type_socklen_t=no
948)
949
950if test $ac_cv_type_socklen_t != yes; then
951  AC_DEFINE(socklen_t, int, [Substitute for socklen_t])
952  AC_MSG_RESULT(int)
953else
954  AC_MSG_RESULT(yes)
955fi
956
957dnl
958dnl Check of __func__ and co..
959dnl
960AC_MSG_CHECKING([whether our compiler supports __func__])
961AC_TRY_COMPILE([],
962 [const char *cp = __func__;],
963 AC_MSG_RESULT([yes]),
964 AC_MSG_RESULT([no])
965 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
966 AC_TRY_COMPILE([],
967   [const char *cp = __FUNCTION__;],
968   AC_MSG_RESULT([yes])
969   AC_DEFINE(__func__, __FUNCTION__,
970         [Define to appropriate substitue if compiler doesnt have __func__]),
971   AC_MSG_RESULT([no])
972   AC_DEFINE(__func__, __FILE__,
973         [Define to appropriate substitue if compiler doesnt have __func__])))
974
975dnl
976dnl Check for pcre library
977dnl
978have_pcre="built-in"
979
980AC_ARG_ENABLE(internal_pcre,
981                    AC_HELP_STRING([--enable-internal-pcre],[Enable internal PCRE]),
982                    use_internal_pcre="$enableval", use_internal_pcre="no")
983
984if test "x$use_internal_pcre" != "xyes"; then
985  AC_CHECK_LIB(pcre, pcre_compile, have_pcre_lib=yes, have_pcre_lib=no)
986  AC_CHECK_HEADER(pcre.h, have_pcre_include=yes, have_pcre_include=no)
987  if test "$have_pcre_lib $have_pcre_include" = "yes yes"; then
988     have_pcre="yes"
989  fi
990fi
991
992AM_CONDITIONAL(USE_INTERNAL_PCRE, test "x$have_pcre" = "xbuilt-in")
993
994dnl
995dnl PAM
996dnl
997AC_ARG_ENABLE(pam, AC_HELP_STRING([--disable-pam],[Disable PAM support]), use_pam="$enableval", use_pam="yes")
998if test "x$use_pam" = "xyes"; then
999     AC_CHECK_LIB(pam, pam_start, have_pam_lib=yes, have_pam_lib=no)
1000     AC_CHECK_LIB(pam, _pam_dispatch, have_pam_dispatch=yes, have_pam_dispatch=no)
1001     AC_CHECK_HEADER(security/pam_modules.h, have_pam_include=yes, have_pam_include=no, [[
1002#ifdef HAVE_SECURITY_PAM_MODULES_H
1003# include <security/pam_modules.h>
1004#endif   
1005        ]])
1006     AC_CHECK_HEADERS(security/_pam_macros.h security/pam_appl.h)
1007fi
1008
1009if test "$use_pam $have_pam_lib $have_pam_include" = "yes yes yes"; then
1010   have_pam="yes"
1011else
1012   have_pam="no"
1013fi
1014AM_CONDITIONAL(HAVE_PAM, test "x$have_pam" = "xyes")
1015
1016if test "$have_pam_dispatch" = "yes"; then
1017        AC_DEFINE(HAVE_PAM_DISPATCH, 1, [Have _pam_dispatch function])
1018fi
1019
1020dnl
1021dnl crypt()
1022dnl
1023AC_CHECK_HEADERS(crypt.h)
1024
1025AC_CHECK_FUNC(crypt, system_crypt="yes", system_crypt="no")
1026AC_CHECK_LIB(crypt, crypt, have_crypt_lib="yes", have_crypt_lib="no")
1027if test "x$have_crypt_lib" = "xyes"; then
1028        CRYPT_LIBS="-lcrypt"
1029        AC_SUBST(CRYPT_LIBS)
1030fi
1031
1032use_crypt="no"
1033if test "$system_crypt $have_crypt_lib" != "no no"; then
1034   use_crypt="yes"
1035   AC_DEFINE(HAVE_CRYPT, 1, [Have crypt function])
1036fi
1037
1038dnl
1039dnl crypt_r()
1040dnl
1041AC_CHECK_FUNC(crypt_r, system_crypt_r="yes", system_crypt_r="no")
1042AC_CHECK_LIB(crypt, crypt_r, have_crypt_r_lib="yes", have_crypt_r_lib="no")
1043
1044use_crypt_r="no"
1045if test "$system_crypt_r $have_crypt_r_lib" != "no no"; then
1046   use_crypt_r="yes"
1047   AC_DEFINE(HAVE_CRYPT_R, 1, [Have crypt_r function])
1048fi
1049
1050dnl
1051dnl crypt_r and pthread
1052dnl
1053if test "$use_crypt_r" = "yes"; then
1054   dnl
1055   dnl crypt_r style
1056   dnl
1057   AC_MSG_CHECKING([crypt_r style])
1058   crypt_r_style=none
1059
1060   # pthread.h is needed on AIX
1061   AC_TRY_COMPILE([#include <pthread.h>
1062                   #include <crypt.h>],
1063                           [CRYPTD buffer;],
1064                           crypt_r_style=cryptd)
1065
1066   if test "$crypt_r_style" = "none"; then
1067      AC_TRY_COMPILE([#include <crypt.h>],
1068                                 [struct crypt_data buffer;],
1069                                 crypt_r_style=struct_crypt_data)
1070   fi
1071
1072   if test "$crypt_r_style" = "none"; then
1073      AC_TRY_COMPILE([#define _GNU_SOURCE
1074                                  #include <crypt.h>],
1075                                 [struct crypt_data buffer;],
1076                                 [crypt_r_style=struct_crypt_data
1077                               CRYPT_CFLAGS="-D_GNU_SOURCE"
1078                                  AC_SUBST(CRYPT_CFLAGS)])
1079   fi                                 
1080   
1081   AC_MSG_RESULT([$crypt_r_style])
1082
1083   if test "$crypt_r_style" = "cryptd"; then
1084     AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])   
1085   fi
1086
1087   if test "$crypt_r_style" = "struct_crypt_data"; then
1088     AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
1089   fi
1090
1091   if test "$crypt_r_style" = "none"; then
1092     AC_MSG_ERROR([Unable to detect data struct is used by crypt_r])
1093   fi
1094fi
1095
1096AM_CONDITIONAL(USE_CRYPT, test "x$use_crypt x$use_crypt_r" != "xno xno")
1097
1098
1099dnl
1100dnl OpenSSL
1101dnl
1102AC_ARG_WITH(libssl,
1103    AC_HELP_STRING([--with-libssl@<:@=DIR@:>@],[Include libssl/OpenSSL support (default yes)]),
1104    [WITH_OPENSSL=$withval],[WITH_OPENSSL=yes])
1105
1106have_openssl=no
1107
1108if test "$WITH_OPENSSL" != "no"; then
1109    if test "$WITH_OPENSSL" != "yes"; then
1110        LIBSSL_CFLAGS="-I$WITH_OPENSSL/include"
1111        LIBSSL_LIBS="-L$WITH_OPENSSL/lib"
1112    fi
1113
1114    AC_CHECK_LIB(crypto, BN_init)
1115    AC_CHECK_HEADERS([openssl/engine.h])
1116    AC_CHECK_LIB(ssl, SSL_accept, [have_openssl=yes], [have_openssl=no], $LIBSSL_LIBS)
1117
1118    if test "$have_openssl" = "yes"; then
1119        LIBSSL_LIBS="$LIBSSL_LIBS -lssl"
1120
1121           AC_SUBST(LIBSSL_LIBS)
1122           AC_SUBST(LIBSSL_CFLAGS)
1123
1124           AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL library])
1125    fi
1126fi
1127AC_MSG_CHECKING(for libssl)
1128AC_MSG_RESULT([$have_openssl])
1129
1130AM_CONDITIONAL(USE_OPENSSL, test "x$have_openssl" = "xyes")
1131
1132
1133dnl
1134dnl Native Language Support
1135dnl
1136AM_PO_SUBDIRS
1137
1138if test "x$USE_NLS" = "xyes"; then
1139   AC_CHECK_PROG(HAVE_MSGFMT, msgfmt,yes,no)
1140
1141   if test "x$HAVE_MSGFMT" = "xno"; then
1142      AC_MSG_ERROR([msgfmt not found. You need to install the 'gettext' package, or pass --enable-nls=no to configure.])
1143   fi
1144fi
1145
1146AM_CONDITIONAL(NLS_ENABLED, test "x$USE_NLS" = "xyes")
1147AC_CONFIG_FILES([po/admin/Makefile.in])
1148
1149dnl
1150dnl LDAP
1151dnl
1152AC_ARG_WITH([ldap],
1153        AC_HELP_STRING([--with-ldap=@<:@ARG@:>@],
1154            [use OpenLDAP development library @<:@default=yes@:>@, optionally specify path to dev libs]
1155        ),
1156        [
1157        if test "$withval" = "no"; then
1158            want_ldap="no"
1159        elif test "$withval" = "yes"; then
1160            want_ldap="yes"
1161        else
1162            want_ldap="yes"
1163            LDAP_CONFIG="$withval"
1164        fi
1165        ],
1166        [want_ldap="yes"]
1167)
1168
1169if test "$want_ldap" = "yes"; then
1170       AC_CHECK_LIB(ldap, ldap_init, have_ldap_lib=yes, have_ldap_lib=no)
1171       AC_CHECK_HEADER(ldap.h, have_ldap_include=yes, have_ldap_include=no)
1172
1173          AC_CHECK_LIB(ldap, ldap_start_tls_s, [
1174                AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
1175          ])
1176
1177       if test "$have_ldap_lib $have_ldap_include" = "yes yes"; then
1178          have_ldap="yes"
1179       else
1180          have_ldap="no"
1181       fi
1182else
1183       have_ldap="no"
1184fi
1185
1186AM_CONDITIONAL(HAVE_LDAP, test "x$have_ldap" = "xyes")
1187
1188
1189dnl
1190dnl Check for MySQL: Execution of a string containing multiple
1191dnl statements was introduced in the MySQL release 5.0.0
1192dnl
1193AX_LIB_MYSQL(5.0.0)
1194
1195
1196dnl
1197dnl GeoIP library
1198dnl
1199AC_ARG_WITH([geoip],
1200        AC_HELP_STRING([--with-geoip=@<:@ARG@:>@],
1201            [use the GeoIP library @<:@default=yes@:>@, optionally specify path to dev libs]
1202        ),
1203        [
1204        if test "$withval" = "no"; then
1205            want_geoip="no"
1206        elif test "$withval" = "yes"; then
1207            want_geoip="yes"
1208        else
1209            want_geoip="yes"
1210            GEOIP_CONFIG="$withval"
1211        fi
1212        ],
1213        [want_geoip="yes"]
1214)
1215
1216if test "x$want_geoip" = "xyes"; then
1217   AC_CHECK_LIB(GeoIP, GeoIP_new, have_geoip_lib=yes, have_geoip_lib=no)
1218   AC_CHECK_HEADERS(GeoIP.h, have_geoip_include=yes, have_geoip_include=no)
1219fi
1220
1221have_geoip="no"
1222if test "$have_geoip_lib $have_geoip_include" = "yes yes"; then
1223   have_geoip="yes"
1224fi
1225
1226AM_CONDITIONAL(HAVE_GEOIP, test "x$have_geoip" = "xyes")
1227
1228
1229dnl
1230dnl FFMpeg library
1231dnl
1232AC_ARG_WITH([ffmpeg],
1233        AC_HELP_STRING([--with-ffmpeg=@<:@ARG@:>@],
1234            [use the FFMpeg library @<:@default=yes@:>@, optionally specify path to dev libs]
1235        ),
1236        [
1237        if test "$withval" = "no"; then
1238            want_ffmpeg="no"
1239        elif test "$withval" = "yes"; then
1240            want_ffmpeg="yes"
1241        else
1242            want_ffmpeg="yes"
1243            FFMPEG_CONFIG="$withval"
1244        fi
1245        ],
1246        [want_ffmpeg="yes"]
1247)
1248
1249if test "x$want_ffmpeg" = "xyes"; then
1250   AC_CHECK_LIB([avformat], [main], [
1251         FFMPEG_LIBS="-lavformat -lavcodec -lavutil"
1252         have_ffmpeg_lib=yes
1253   ],[have_ffmpeg_lib=no])
1254
1255   AC_CHECK_LIB([bz2], [BZ2_bzdopen], [
1256         FFMPEG_LIBS="$FFMPEG_LIBS -lbz2"
1257   ])
1258
1259   AC_CHECK_LIB([m], [cos], [
1260         FFMPEG_LIBS="$FFMPEG_LIBS -lm"
1261   ])
1262
1263   AC_CHECK_HEADERS([libavformat/avformat.h], [
1264      have_ffmpeg_include=yes
1265   ],[have_ffmpeg_include=no])
1266fi
1267
1268have_ffmpeg="no"
1269if test "$have_ffmpeg_lib $have_ffmpeg_include" = "yes yes"; then
1270   have_ffmpeg="yes"
1271   AC_SUBST(FFMPEG_LIBS)
1272   AC_SUBST(FFMPEG_CFLAGS)
1273   AC_DEFINE([USE_FFMPEG], 1, [Whether to use FFMpeg])
1274fi
1275
1276AM_CONDITIONAL(HAVE_FFMPEG, test "x$have_ffmpeg" = "xyes")
1277
1278
1279dnl
1280dnl WWW root directory, and user/group
1281dnl
1282AC_ARG_WITH(wwwroot, AC_HELP_STRING([--with-wwwroot=DIR], [Set the WWW root directory]),
1283                  WWW_ROOT="$withval", WWW_ROOT="$localstatedir/www")
1284AC_SUBST(WWW_ROOT)
1285
1286AC_ARG_WITH(wwwuser, AC_HELP_STRING([--with-wwwuser=USER], [Set default execution user]),
1287                  WWW_USER="$withval", WWW_USER="")
1288AC_SUBST(WWW_USER)
1289
1290AC_ARG_WITH(wwwgroup, AC_HELP_STRING([--with-wwwgroup=GROUP], [Set default execution group]),
1291                  WWW_GROUP="$withval", WWW_GROUP="")
1292AC_SUBST(WWW_GROUP)
1293
1294
1295dnl
1296dnl Look for misc binaries
1297dnl
1298AC_PATH_PROG(PHPCGI, php-cgi)
1299AC_ARG_VAR(PHPCGI, [path to PHP-cgi])
1300
1301AC_MSG_CHECKING([$PHPCGI supports FastCGI])
1302if test "x$PHPCGI" = "x"; then
1303   AC_MSG_RESULT([no])
1304else
1305   $PHPCGI -v -d session.save_path=/tmp | grep 'cgi-fcgi' >/dev/null 2>/dev/null
1306   if test $? != 0; then
1307      PHPCGI=""
1308      AC_MSG_RESULT([no])
1309   else
1310      AC_MSG_RESULT([yes])
1311   fi
1312fi
1313
1314if test "x$PHPCGI" = "x"; then
1315   for n in php-cgi php; do
1316     for p in /usr/lib/cgi-bin /usr/bin /usr/local/bin; do
1317       phpcgi_path="$p/php-cgi"
1318          AC_MSG_CHECKING([for $phpcgi_path])
1319          if test -x "$phpcgi_path"; then
1320             $phpcgi_path -v | grep 'cgi-fcgi' >/dev/null 2>/dev/null
1321                if test $? = 0; then
1322                  PHPCGI=$phpcgi_path
1323               AC_MSG_RESULT([yes])
1324                else
1325               AC_MSG_RESULT([not fcgi])
1326                fi
1327                break
1328          else
1329             AC_MSG_RESULT([no])
1330          fi
1331     done
1332        if test "x$PHPCGI" != x; then
1333          break;
1334        fi
1335   done
1336fi
1337
1338if test "x$PHPCGI" = "x"; then
1339   PHPCGI="php-cgi"
1340fi
1341
1342AC_SUBST(PHPCGI)
1343
1344
1345dnl
1346dnl Cherokee admin
1347dnl
1348AC_ARG_ENABLE(admin,
1349           AC_HELP_STRING([--disable-admin],[Disable Cherokee-admin installation]),
1350           wants_admin="$enableval", wants_admin="yes")
1351AM_CONDITIONAL(INSTALL_ADMIN, test "x$wants_admin" != "xno")
1352
1353dnl
1354dnl Clean files generated from *.pre
1355dnl
1356pres="constants.h cherokee.conf.sample performance.conf.sample http-cherokee.xml admin/configured.py contrib/cherokee"
1357AC_MSG_NOTICE([Deleting .pre files])
1358rm -f $pres
1359
1360dnl
1361dnl Options
1362dnl
1363use_static_module=""
1364AC_ARG_ENABLE(static-module,
1365           AC_HELP_STRING([--enable-static-module=MODULE][]),
1366           [use_static_module="$use_static_module $enableval "],[])
1367
1368modules="error_redir error_nn server_info file admin dirlist fcgi fastcgi scgi uwsgi redir common cgi proxy ssi secdownload empty_gif custom_error dbslayer streaming gzip deflate ncsa combined custom pam ldap mysql htpasswd plain htdigest authlist round_robin ip_hash directory extensions request header exists fullpath method from bind geoip url_arg wildcard rehost target_ip evhost libssl render_rrd rrd not and or"
1369
1370# Remove modules that will not be compiles
1371#
1372if test "x$have_pam" != "xyes"; then
1373        modules=`echo $modules | sed s/pam//`
1374fi
1375if test "x$have_ldap" != "xyes"; then
1376        modules=`echo $modules | sed s/ldap//`
1377fi
1378if test "x$have_mysql" != "xyes"; then
1379        modules=`echo $modules | sed s/mysql//`
1380        modules=`echo $modules | sed s/dbslayer//`
1381fi
1382if test "x$have_geoip" != "xyes"; then
1383        modules=`echo $modules | sed s/geoip//`
1384fi
1385if test "$use_crypt" != "yes"; then
1386        modules=`echo $modules | sed s/htpasswd//`
1387fi
1388if test "$have_openssl" != "yes"; then
1389        modules=`echo $modules | sed s/libssl//`
1390fi
1391
1392add_calls=""
1393init_calls=""
1394headers=""
1395ext_defs=""
1396
1397for mod in $modules; do
1398        AC_MSG_CHECKING([module "$mod"])
1399
1400        if echo $use_static_module | grep -w $mod >/dev/null || echo $use_static_module | grep all >/dev/null; then
1401                 ext_defs="$ext_defs \n extern cherokee_plugin_info_t cherokee_${mod}_info;"
1402
1403                 headers="$headers \n void PLUGIN_INIT_NAME($mod) (cherokee_plugin_loader_t *loader);"
1404                 add_calls="$add_calls \n add_static_entry (loader, \"$mod\", PLUGIN_INFO_PTR($mod));"
1405                 init_calls="$init_calls \n PLUGIN_INIT_NAME($mod)(loader);"
1406
1407              AC_MSG_RESULT([static])
1408        else
1409              AC_MSG_RESULT([dynamic])
1410        fi
1411done
1412
1413AC_MSG_CHECKING([loader.autoconf files])
1414mkdir cherokee 2>/dev/null
1415printf "$ext_defs\n"                                 > cherokee/loader.autoconf.h
1416printf "$headers \n\n $add_calls \n\n $init_calls\n" > cherokee/loader.autoconf.inc
1417AC_MSG_RESULT([done])
1418
1419dnl
1420dnl Static/Dynamic modules
1421dnl
1422conf_h="cherokee/loader.autoconf.h"
1423AM_CONDITIONAL(STATIC_HANDLER_SERVER_INFO,    grep server_info    $conf_h >/dev/null)
1424AM_CONDITIONAL(STATIC_HANDLER_FILE,           grep file           $conf_h >/dev/null)
1425AM_CONDITIONAL(STATIC_HANDLER_ADMIN,          grep admin          $conf_h >/dev/null)
1426AM_CONDITIONAL(STATIC_HANDLER_DIRLIST,        grep dirlist        $conf_h >/dev/null)
1427AM_CONDITIONAL(STATIC_HANDLER_FCGI,           grep fcgi           $conf_h >/dev/null)
1428AM_CONDITIONAL(STATIC_HANDLER_FASTCGI,        grep fastcgi        $conf_h >/dev/null)
1429AM_CONDITIONAL(STATIC_HANDLER_SCGI,           grep scgi           $conf_h >/dev/null)
1430AM_CONDITIONAL(STATIC_HANDLER_UWSGI,          grep uwsgi          $conf_h >/dev/null)
1431AM_CONDITIONAL(STATIC_HANDLER_REDIR,          grep redir          $conf_h >/dev/null)
1432AM_CONDITIONAL(STATIC_HANDLER_ERROR_REDIR,    grep error_redir    $conf_h >/dev/null)
1433AM_CONDITIONAL(STATIC_HANDLER_ERROR_NN,       grep error_nn       $conf_h >/dev/null)
1434AM_CONDITIONAL(STATIC_HANDLER_COMMON,         grep common         $conf_h >/dev/null)
1435AM_CONDITIONAL(STATIC_HANDLER_CGI,            grep cgi            $conf_h >/dev/null)
1436AM_CONDITIONAL(STATIC_HANDLER_PROXY,          grep proxy          $conf_h >/dev/null)
1437AM_CONDITIONAL(STATIC_HANDLER_SSI,            grep ssi            $conf_h >/dev/null)
1438AM_CONDITIONAL(STATIC_HANDLER_SECDOWNLOAD,    grep secdownload    $conf_h >/dev/null)
1439AM_CONDITIONAL(STATIC_HANDLER_EMPTY_GIF,      grep empty_gif      $conf_h >/dev/null)
1440AM_CONDITIONAL(STATIC_HANDLER_CUSTOM_ERROR,   grep custom_error   $conf_h >/dev/null)
1441AM_CONDITIONAL(STATIC_HANDLER_DBSLAYER,       grep dbslayer       $conf_h >/dev/null)
1442AM_CONDITIONAL(STATIC_HANDLER_STREAMING,      grep streaming      $conf_h >/dev/null)
1443AM_CONDITIONAL(STATIC_HANDLER_RENDER_RRD,     grep render_rrd     $conf_h >/dev/null)
1444AM_CONDITIONAL(STATIC_ENCODER_GZIP,           grep gzip           $conf_h >/dev/null)
1445AM_CONDITIONAL(STATIC_ENCODER_DEFLATE,        grep deflate        $conf_h >/dev/null)
1446AM_CONDITIONAL(STATIC_LOGGER_NCSA,            grep ncsa           $conf_h >/dev/null)
1447AM_CONDITIONAL(STATIC_LOGGER_COMBINED,        grep combined       $conf_h >/dev/null)
1448AM_CONDITIONAL(STATIC_LOGGER_CUSTOM,          grep custom         $conf_h >/dev/null)
1449AM_CONDITIONAL(STATIC_VALIDATOR_PAM,          grep pam            $conf_h >/dev/null)
1450AM_CONDITIONAL(STATIC_VALIDATOR_LDAP,         grep ldap           $conf_h >/dev/null)
1451AM_CONDITIONAL(STATIC_VALIDATOR_MYSQL,        grep mysql          $conf_h >/dev/null)
1452AM_CONDITIONAL(STATIC_VALIDATOR_HTPASSWD,     grep htpasswd       $conf_h >/dev/null)
1453AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN,        grep plain          $conf_h >/dev/null)
1454AM_CONDITIONAL(STATIC_VALIDATOR_HTDIGEST,     grep htdigest       $conf_h >/dev/null)
1455AM_CONDITIONAL(STATIC_VALIDATOR_AUTHLIST,     grep authlist       $conf_h >/dev/null)
1456AM_CONDITIONAL(STATIC_BALANCER_ROUND_ROBIN,   grep round_robin    $conf_h >/dev/null)
1457AM_CONDITIONAL(STATIC_BALANCER_IP_HASH,       grep ip_hash        $conf_h >/dev/null)
1458AM_CONDITIONAL(STATIC_CRYPTOR_LIBSSL,         grep libssl         $conf_h >/dev/null)
1459AM_CONDITIONAL(STATIC_RULE_DIRECTORY,         grep directory      $conf_h >/dev/null)
1460AM_CONDITIONAL(STATIC_RULE_EXTENSIONS,        grep extensions     $conf_h >/dev/null)
1461AM_CONDITIONAL(STATIC_RULE_REQUEST,           grep request        $conf_h >/dev/null)
1462AM_CONDITIONAL(STATIC_RULE_HEADER,            grep header         $conf_h >/dev/null)
1463AM_CONDITIONAL(STATIC_RULE_EXISTS,               grep exists         $conf_h >/dev/null)
1464AM_CONDITIONAL(STATIC_RULE_FULL_PATH,         grep fullpath       $conf_h >/dev/null)
1465AM_CONDITIONAL(STATIC_RULE_BIND,                 grep bind           $conf_h >/dev/null)
1466AM_CONDITIONAL(STATIC_RULE_METHOD,               grep method         $conf_h >/dev/null)
1467AM_CONDITIONAL(STATIC_RULE_FROM,                 grep from           $conf_h >/dev/null)
1468AM_CONDITIONAL(STATIC_RULE_GEOIP,             grep geoip          $conf_h >/dev/null)
1469AM_CONDITIONAL(STATIC_RULE_URL_ARG,              grep url_arg        $conf_h >/dev/null)
1470AM_CONDITIONAL(STATIC_VRULE_WILDCARD,         grep wildcard       $conf_h >/dev/null)
1471AM_CONDITIONAL(STATIC_VRULE_REHOST,           grep rehost         $conf_h >/dev/null)
1472AM_CONDITIONAL(STATIC_VRULE_TARGET_IP,        grep target_ip      $conf_h >/dev/null)
1473AM_CONDITIONAL(STATIC_GEN_EVHOST,             grep evhost         $conf_h >/dev/null)
1474AM_CONDITIONAL(STATIC_COLLECTOR_RRD,          grep rrd            $conf_h >/dev/null)
1475# These must be at the end
1476AM_CONDITIONAL(STATIC_RULE_NOT,               grep _not_          $conf_h >/dev/null)
1477AM_CONDITIONAL(STATIC_RULE_AND,               grep _and_          $conf_h >/dev/null)
1478AM_CONDITIONAL(STATIC_RULE_OR,                grep _or_           $conf_h >/dev/null)
1479
1480AC_OUTPUT([
1481Makefile
1482cget/Makefile
1483cherokee-config
1484cherokee.pc
1485cherokee.spec
1486cherokee/Makefile
1487contrib/Makefile
1488icons/Makefile
1489m4/Makefile
1490qa/Makefile
1491doc/Makefile
1492themes/Makefile
1493themes/default/Makefile
1494themes/firefox3/Makefile
1495themes/plain/Makefile
1496packages/Makefile
1497packages/osx/Makefile
1498packages/osx/Info.plist
1499packages/osx/Description.plist
1500packages/windows/Makefile
1501packages/windows/cherokee.nsi
1502www/Makefile
1503dbslayer/Makefile
1504admin/Makefile
1505admin/static/Makefile
1506admin/static/js/Makefile
1507admin/static/css/Makefile
1508admin/static/images/Makefile
1509admin/static/images/flags/Makefile
1510admin/static/images/wizards/Makefile
1511po/Makefile
1512])
1513
1514
1515methods=""
1516if test "$have_epoll"        = yes; then methods="${methods}epoll ";  fi
1517if test "$have_kqueue"       = yes; then methods="${methods}kqueue "; fi
1518if test "$have_poll"         = yes; then methods="${methods}poll ";   fi
1519if test "$have_port"         = yes; then methods="${methods}port ";   fi
1520if test "$have_win32_select" = yes; then methods="${methods}win32 ";  fi
1521if test "$have_select"       = yes; then methods="${methods}select";  fi
1522
1523if test "$use_crypt_r" = "yes"; then
1524        crypt_type="multithread"
1525elif test "$use_crypt" = "yes"; then
1526        crypt_type="single thread"
1527else
1528        crypt_type="no"
1529fi
1530
1531echo
1532echo ============================
1533echo "Install prefix        $prefix"
1534echo "CFLAGS                $CFLAGS"
1535echo "trace                 $enable_trace"
1536echo "backtracing           $enable_backtraces"
1537echo "sendfile()            $with_sendfile_support"
1538echo "IPv6 support          $have_ipv6"
1539i=1
1540for m in $methods; do
1541        echo "Polling method $i      $m"
1542        i=`expr $i + 1`
1543done
1544echo "Threading support     $have_pthread"
1545echo "OpenSSL support       $have_openssl"
1546echo "PCRE library          $have_pcre"
1547echo "Compatible PAM        $have_pam"
1548echo "LDAP                  $have_ldap"
1549echo "MySQL                 $have_mysql"
1550echo "GeoIP                 $have_geoip"
1551echo "FFMpeg                $have_ffmpeg"
1552echo "crypt support         $crypt_type"
1553if test "x$is_beta" = "xyes"; then
1554echo "Beta release          $svn_rev"
1555fi
1556echo
1557eval eval echo "Installation dir      $bindir"
1558echo ============================
1559echo
1560if test "x$cherokeepath" != "x" ; then
1561        echo Warning: You have an old copy of Cherokee at $cherokeepath.
1562        echo   
1563fi
1564
1565cat <<THEEND
1566+------------------------------------------------------------------+
1567| License:                                                         |
1568| This software is subject to the GPL License, available in this   |
1569| distribution in the file COPYING. Please, remember that any copy |
1570| distribution or modification of the software is subject to it.   |
1571+------------------------------------------------------------------+
1572
1573Thank you for using Cherokee.
1574THEEND
Note: See TracBrowser for help on using the browser.