source: configure.ac @ 8d8af6

Revision 8d8af6, 9.2 KB checked in by Poul-Henning Kamp <phk@…>, 6 years ago (diff)

Integrate Solaris patches, with a bit of polishing.

Don't look for umem on FreeBSD, which have dummy stub version for
dtrace or ZFS compatibility.

Generally restrict probes for Solaris specific stuff to when we
run on solaris, no need to make configure slower than it is.

Don't pretend we can get anywhere without poll(2) we use it for
lots of things: Remove #if conditionals around poll-acceptor.

Sort a couple of lists, before they get too unsorted.

Submitted by: Theo Schlossnagle

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

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