source: configure.ac @ 64b0c4

Revision 64b0c4, 11.0 KB checked in by Poul-Henning Kamp <phk@…>, 5 years ago (diff)

Reorder libraries

add "-Wl,--as-needed" to EXTRA_DEVELOPER_CFLAGS to try to prevent
future unordering.

Fixes #486

git-svn-id:  http://www.varnish-cache.org/svn/trunk/varnish-cache@4039 d4fa192b-c00b-0410-8231-f00ffab90ce4

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