root/trunk/varnish-cache/configure.ac

Revision 5146, 12.3 KB (checked in by phk, 3 days ago)

Add the VRT functions for importing a module.

Tie the vmod_std module into the build.

The initial VCC bits for modules snug into the previous commit.

  • Property svn:keywords set to Id
Line 
1# $Id$
2
3AC_PREREQ(2.59)
4AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS
5Copyright (c) 2006-2009 Linpro AS])
6AC_REVISION([$Id$])
7AC_INIT([Varnish], [trunk], [varnish-dev@varnish-cache.org])
8AC_CONFIG_SRCDIR(include/varnishapi.h)
9AM_CONFIG_HEADER(config.h)
10
11AC_CANONICAL_SYSTEM
12AC_LANG(C)
13
14AM_INIT_AUTOMAKE([foreign])
15
16# Checks for programs.
17AC_GNU_SOURCE
18AC_PROG_CC
19AC_PROG_CC_STDC
20if test "x$ac_cv_prog_cc_c99" = xno; then
21  AC_MSG_ERROR([Could not find a C99 compatible compiler])
22fi
23AC_PROG_CPP
24AC_PROG_INSTALL
25AC_PROG_LIBTOOL
26AC_PROG_MAKE_SET
27AC_CHECK_PROGS(XSLTPROC, [xsltproc], "no")
28if test "x$XSLTPROC" = "xno"; then
29   AC_MSG_WARN([xsltproc not found – not building documentation])
30fi
31AM_CONDITIONAL(HAVE_XSLTPROC,[test "x$XSLTPROC" != "xno"])
32AC_CHECK_PROGS(RST2MAN, [rst2man], "no")
33if test "x$RST2MAN" = "xno"; then
34   AC_MSG_WARN([rst2man not found – not building man pages])
35fi
36AM_CONDITIONAL(HAVE_RST2MAN,[test "x$RST2MAN" != "xno"])
37
38# Checks for libraries.
39save_LIBS="${LIBS}"
40LIBS=""
41AC_CHECK_LIB(rt, clock_gettime)
42RT_LIBS="${LIBS}"
43LIBS="${save_LIBS}"
44AC_SUBST(RT_LIBS)
45
46save_LIBS="${LIBS}"
47LIBS=""
48AC_CHECK_LIB(dl, dlopen)
49DL_LIBS="${LIBS}"
50LIBS="${save_LIBS}"
51AC_SUBST(DL_LIBS)
52
53save_LIBS="${LIBS}"
54LIBS=""
55AC_SEARCH_LIBS(initscr, [curses ncurses],
56        [have_curses=yes], [have_curses=no])
57CURSES_LIBS="${LIBS}"
58LIBS="${save_LIBS}"
59AC_SUBST(CURSES_LIBS)
60if test "$have_curses" = no; then
61        AC_MSG_WARN([curses not found; some tools will not be built])
62fi
63AM_CONDITIONAL([HAVE_CURSES], [test x$have_curses = xyes])
64
65save_LIBS="${LIBS}"
66LIBS=""
67AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])
68PTHREAD_LIBS="${LIBS}"
69LIBS="${save_LIBS}"
70AC_SUBST(PTHREAD_LIBS)
71
72save_LIBS="${LIBS}"
73LIBS=""
74AC_CHECK_LIB(socket, socket)
75AC_CHECK_LIB(nsl, getaddrinfo)
76NET_LIBS="${LIBS}"
77LIBS="${save_LIBS}"
78AC_SUBST(NET_LIBS)
79
80AC_CHECK_LIBM
81AC_SUBST(LIBM)
82
83m4_pattern_forbid([^_?PKG_[A-Z_]+$],[pkg.m4 missing, please install pkg-config])
84PKG_PROG_PKG_CONFIG
85if test -n $PKG_CONFIG; then
86   PKG_CHECK_MODULES([PCRE], [libpcre])
87else
88   AC_CHECK_PROG(PCRE_CONFIG, pcre-config, pcre-config)
89   AC_ARG_WITH(pcre-config,
90               AS_HELP_STRING([--with-pcre-config=PATH],
91                              [Location of PCRE pcre-config (auto)]),
92               [pcre_config="$withval"],
93               [pcre_config=""])
94
95  if test "x$pcre_config" != "x" ; then
96    AC_MSG_CHECKING(for $pcre_config)
97
98    if test -f $pcre_config ; then
99      PCRE_CONFIG=$pcre_config
100      AC_MSG_RESULT(yes)
101    else
102      AC_MSG_RESULT(no - searching PATH)
103    fi
104  fi
105  if test "x$PCRE_CONFIG" = "x"; then
106    AC_CHECK_PROGS(PCRE_CONFIG, pcre-config)
107  fi
108  PCRE_CFLAGS=`$PCRE_CONFIG --cflags`
109  PCRE_LIBS=`$PCRE_CONFIG --libs`
110fi
111AC_SUBST(PCRE_CFLAGS)
112AC_SUBST(PCRE_LIBS)
113
114
115# Checks for header files.
116AC_HEADER_STDC
117AC_HEADER_SYS_WAIT
118AC_HEADER_TIME
119AC_CHECK_HEADERS([sys/param.h])
120AC_CHECK_HEADERS([sys/types.h])
121AC_CHECK_HEADERS([sys/endian.h])
122AC_CHECK_HEADERS([sys/filio.h])
123AC_CHECK_HEADERS([sys/mount.h], [], [], [#include <sys/param.h>])
124AC_CHECK_HEADERS([sys/socket.h])
125AC_CHECK_HEADERS([sys/statvfs.h])
126AC_CHECK_HEADERS([sys/vfs.h])
127AC_CHECK_HEADERS([endian.h])
128AC_CHECK_HEADERS([execinfo.h])
129AC_CHECK_HEADERS([netinet/in.h])
130AC_CHECK_HEADERS([pthread_np.h])
131AC_CHECK_HEADERS([stddef.h])
132AC_CHECK_HEADERS([stdlib.h])
133AC_CHECK_HEADERS([unistd.h])
134AC_CHECK_HEADERS([priv.h])
135
136# Checks for typedefs, structures, and compiler characteristics.
137AC_C_CONST
138AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[
139#include <sys/types.h>
140#ifdef HAVE_SYS_SOCKET_H
141#include <sys/socket.h>
142#endif
143])
144
145# Checks for library functions.
146AC_TYPE_SIGNAL
147AC_TYPE_SIZE_T
148AC_FUNC_VPRINTF
149AC_CHECK_FUNCS([strerror])
150AC_FUNC_STRERROR_R
151AC_CHECK_FUNCS([dladdr])
152AC_CHECK_FUNCS([socket])
153AC_CHECK_FUNCS([strptime])
154AC_CHECK_FUNCS([fmtcheck])
155AC_CHECK_FUNCS([getdtablesize])
156AC_CHECK_FUNCS([abort2])
157AC_CHECK_FUNCS([timegm])
158AC_CHECK_FUNCS([nanosleep])
159AC_CHECK_FUNCS([setppriv])
160
161save_LIBS="${LIBS}"
162LIBS="${PTHREAD_LIBS}"
163AC_CHECK_FUNCS([pthread_set_name_np])
164AC_CHECK_FUNCS([pthread_mutex_isowned_np])
165LIBS="${save_LIBS}"
166
167# sendfile is tricky: there are multiple versions, and most of them
168# don't work.
169case $target in
170*-*-freebsd*)
171        AC_CACHE_CHECK([whether sendfile works],
172          [ac_cv_so_sendfile_works],
173          [AC_RUN_IFELSE(
174            [AC_LANG_PROGRAM([[
175        #include <sys/types.h>
176        #include <sys/socket.h>
177        #include <sys/uio.h>
178            ]],[[
179                return (SF_SYNC == 0);
180            ]])],
181            [ac_cv_so_sendfile_works=yes],
182            [ac_cv_so_sendfile_works=no])
183          ])
184        ;;
185#*-*-solaris*)
186#       save_LIBS="${LIBS}"
187#       LIBS="${NET_LIBS}"
188#       AC_CHECK_LIB(sendfile, sendfile)
189#       AC_CHECK_FUNCS([sendfile])
190#       AC_CHECK_FUNCS([sendfilev])
191#       NET_LIBS="${LIBS}"
192#       LIBS="${save_LIBS}"
193*)
194        AC_MSG_WARN([won't look for sendfile() on $target])
195        ;;
196esac
197if test "$ac_cv_so_sendfile_works" = yes; then
198        AC_DEFINE([SENDFILE_WORKS], [1], [Define if SENDFILE works])
199fi
200
201# Userland slab allocator, available only on Solaris
202case $target in
203*-*-solaris*)
204        AC_CHECK_HEADERS([umem.h])
205        if test "$ac_cv_have_umem_h" = yes; then
206                save_LIBS="${LIBS}"
207                LIBS=""
208                AC_CHECK_LIB(umem, umem_alloc)
209                LIBUMEM="${LIBS}"
210                LIBS="${save_LIBS}"
211        fi
212        ;;
213esac
214AC_SUBST(LIBUMEM)
215
216# These functions are provided by libcompat on platforms where they
217# are not available
218AC_CHECK_FUNCS([setproctitle])
219AC_CHECK_FUNCS([srandomdev])
220AC_CHECK_FUNCS([strlcat strlcpy])
221AC_CHECK_FUNCS([strndup])
222AC_CHECK_FUNCS([backtrace])
223# white lie - we don't actually test it
224AC_MSG_CHECKING([whether daemon() works])
225case $target in
226*-*-darwin*)
227        # present but not functional
228        AC_MSG_RESULT([no])
229        ac_cv_func_daemon=no
230        ;;
231*)
232        AC_CHECK_FUNCS([daemon])
233        ;;
234esac
235
236AC_SYS_LARGEFILE
237
238save_LIBS="${LIBS}"
239LIBS="${LIBS} ${RT_LIBS}"
240AC_CHECK_FUNCS([clock_gettime])
241AC_CHECK_FUNCS([gethrtime])
242LIBS="${save_LIBS}"
243
244# Check which mechanism to use for the acceptor.  We look for kqueue
245# only on platforms on which we know that it works, because there are
246# platforms where a simple AC_CHECK_FUNCS([kqueue]) would succeed but
247# the build would fail.  We also allow the user to disable mechanisms
248# he doesn't want to use.
249
250# --enable-kqueue
251AC_ARG_ENABLE(kqueue,
252    AS_HELP_STRING([--enable-kqueue],
253        [use kqueue if available (default is YES)]),
254    ,
255    [enable_kqueue=yes])
256
257if test "$enable_kqueue" = yes; then
258        case $target in
259        *-*-freebsd* | *-*-darwin9* )
260                AC_CHECK_FUNCS([kqueue])
261                ;;
262        *-*-bsd*)
263                # No other BSD has a sufficiently recent implementation
264                AC_MSG_WARN([won't look for kqueue() on $target])
265                ac_cv_func_kqueue=no
266                ;;
267        esac
268else
269        ac_cv_func_kqueue=no
270fi
271
272# --enable-epoll
273AC_ARG_ENABLE(epoll,
274    AS_HELP_STRING([--enable-epoll],
275        [use epoll if available (default is YES)]),
276    ,
277    [enable_epoll=yes])
278
279if test "$enable_epoll" = yes; then
280        AC_CHECK_FUNCS([epoll_ctl])
281else
282        ac_cv_func_epoll_ctl=no
283fi
284
285# --enable-ports
286AC_ARG_ENABLE(ports,
287    AS_HELP_STRING([--enable-ports],
288        [use ports if available (default is YES)]),
289    ,
290    [enable_ports=yes])
291
292if test "$enable_ports" = yes; then
293        AC_CHECK_FUNCS([port_create])
294else
295        ac_cv_func_port_create=no
296fi
297
298AM_MISSING_HAS_RUN
299AC_CHECK_PROGS(PYTHON, [python python2 python2.5 python2.6 python3 python3.1 python3.2], [AC_MSG_ERROR([Python is needed to build Varnish, please install python.])])
300
301# Solaris defines SO_{RCV,SND}TIMEO, but does not implement them.
302# Varnish will build and run without these, but connections will not
303# time out, which may leave Varnish vulnerable to denail-of-service
304# attacks which would not be possible on other platforms.
305
306AC_CACHE_CHECK([whether SO_RCVTIMEO works],
307  [ac_cv_so_rcvtimeo_works],
308  [AC_RUN_IFELSE(
309    [AC_LANG_PROGRAM([[
310#include <sys/types.h>
311#include <sys/socket.h>
312#include <sys/time.h>
313    ]],[[
314int sd = socket(AF_INET, SOCK_STREAM, 0);
315struct timeval tv = { 1, 0 };
316return !!setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
317    ]])],
318    [ac_cv_so_rcvtimeo_works=yes],
319    [ac_cv_so_rcvtimeo_works=no])
320  ])
321if test "$ac_cv_so_rcvtimeo_works" = yes; then
322   AC_DEFINE([SO_RCVTIMEO_WORKS], [1], [Define if SO_RCVTIMEO works])
323fi
324
325AC_CACHE_CHECK([whether SO_SNDTIMEO works],
326  [ac_cv_so_sndtimeo_works],
327  [AC_RUN_IFELSE(
328    [AC_LANG_PROGRAM([[
329#include <sys/types.h>
330#include <sys/socket.h>
331#include <sys/time.h>
332    ]],[[
333int sd = socket(AF_INET, SOCK_STREAM, 0);
334struct timeval tv = { 1, 0 };
335return !!setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
336    ]])],
337    [ac_cv_so_sndtimeo_works=yes],
338    [ac_cv_so_sndtimeo_works=no])
339  ])
340if test "$ac_cv_so_sndtimeo_works" = yes; then
341   AC_DEFINE([SO_SNDTIMEO_WORKS], [1], [Define if SO_SNDTIMEO works])
342fi
343
344if test "$ac_cv_so_rcvtimeo_works" = no ||
345   test "$ac_cv_so_sndtimeo_works" = no; then
346        AC_MSG_WARN([connection timeouts will not work])
347fi
348
349# Run-time directory
350VARNISH_STATE_DIR='${localstatedir}/varnish'
351AC_SUBST(VARNISH_STATE_DIR)
352
353# Default configuration directory.
354varnishconfdir='${sysconfdir}/varnish'
355AC_SUBST(varnishconfdir)
356# Now that we're done using the compiler to look for functions and
357# libraries, set CFLAGS to what we want them to be for our own code
358
359# This corresponds to FreeBSD's WARNS level 6
360DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat"
361
362# Additional flags for GCC 4
363EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare"
364
365# --enable-developer-warnings
366AC_ARG_ENABLE(developer-warnings,
367        AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]),
368        CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}")
369
370# --enable-debugging-symbols
371AC_ARG_ENABLE(debugging-symbols,
372        AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]),
373        CFLAGS="${CFLAGS} -O0 -g -fno-inline")
374
375# --enable-diagnostics
376AC_ARG_ENABLE(diagnostics,
377        AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]),
378        CFLAGS="${CFLAGS} -DDIAGNOSTICS")
379
380# --enable-extra-developer-warnings
381AC_ARG_ENABLE(extra-developer-warnings,
382        AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]),
383        CFLAGS="${CFLAGS} ${EXTRA_DEVELOPER_CFLAGS}")
384
385# --enable-stack-protector
386AC_ARG_ENABLE(stack-protector,
387        AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is NO)]),
388        CFLAGS="${CFLAGS} -fstack-protector-all")
389
390# --enable-tests
391AC_ARG_ENABLE(tests,
392        AS_HELP_STRING([--enable-tests],[build test programs (default is NO)]))
393AM_CONDITIONAL([ENABLE_TESTS], [test x$enable_tests = xyes])
394
395# --enable-werror
396AC_ARG_ENABLE(werror,
397        AS_HELP_STRING([--enable-werror],[use -Werror (default is NO)]),
398        CFLAGS="${CFLAGS} -Werror")
399
400# Command line for compiling VCL code.  I wish there were a simple way
401# to figure this out dynamically without introducing a run-time
402# dependency on libtool.
403AC_ARG_VAR([VCC_CC], [C compiler command line for VCL code])
404if test "$ac_cv_env_VCC_CC_set" = "set"; then
405        VCC_CC="$ac_cv_env_VCC_CC_value"
406else
407        case $target in
408        *-*-solaris*)
409                VCC_CC="cc -Kpic -G -o %o %s"
410                ;;
411        *-*-darwin*)
412                VCC_CC="exec cc -dynamiclib -Wl,-undefined,dynamic_lookup -o %o %s"
413                ;;
414        *)
415                VCC_CC="exec cc -fpic -shared -Wl,-x -o %o %s"
416                ;;
417        esac
418fi
419AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code])
420
421# Use jemalloc on Linux
422JEMALLOC_SUBDIR=
423JEMALLOC_LDADD=
424AC_ARG_ENABLE(jemalloc,
425AS_HELP_STRING([--disable-jemalloc],[do not use jemalloc (default is yes on Linux, no everywhere else)]),
426[if test "x$enableval" = "xyes"; then
427        JEMALLOC_SUBDIR=libjemalloc
428        JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
429fi],
430[case $target in #(
431*-*-linux*)
432        JEMALLOC_SUBDIR=libjemalloc
433        JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
434        ;; #(
435*)
436        true
437        ;;
438esac])
439
440AC_SUBST(JEMALLOC_SUBDIR)
441AC_SUBST(JEMALLOC_LDADD)
442
443# Generate output
444AC_CONFIG_FILES([
445    Makefile
446    bin/Makefile
447    bin/varnishadm/Makefile
448    bin/varnishd/Makefile
449    bin/varnishlog/Makefile
450    bin/varnishhist/Makefile
451    bin/varnishncsa/Makefile
452    bin/varnishreplay/Makefile
453    bin/varnishstat/Makefile
454    bin/varnishsizes/Makefile
455    bin/varnishtest/Makefile
456    bin/varnishtop/Makefile
457    doc/Makefile
458    etc/Makefile
459    include/Makefile
460    lib/Makefile
461    lib/libvarnish/Makefile
462    lib/libvarnishapi/Makefile
463    lib/libvarnishcompat/Makefile
464    lib/libvcl/Makefile
465    lib/libvmod_std/Makefile
466    lib/libjemalloc/Makefile
467    man/Makefile
468    redhat/Makefile
469    varnishapi.pc
470])
471AC_OUTPUT
Note: See TracBrowser for help on using the browser.