root/trunk/varnish-cache/configure.ac

Revision 4581, 12.0 KB (checked in by phk, 3 weeks ago)

Evict the [v]asprintf compat & configure stuff, we have stopped using
these functions.

The [v]asprintf() functions are convenient shorthand, but suffer from
a number of problems, portability, cornercases and performance being
the most relevant to Varnish.

Static buffers on the stack (see [v]bprintf macros, or sbufs (vsb)
are always better choices for us.

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