1 # Process this file with autoconf to produce a configure script.
2 # Portions of this file were adapted from GIMP.
6 m4_define([tinyproxy_major_version], [1])
7 m4_define([tinyproxy_minor_version], [9])
8 m4_define([tinyproxy_micro_version], [0])
9 m4_define([tinyproxy_real_version],
10 [tinyproxy_major_version.tinyproxy_minor_version.tinyproxy_micro_version])
11 m4_define([tinyproxy_version], [tinyproxy_real_version])
13 # For overriding the version string. Comment out if not needed.
14 # m4_define([tinyproxy_version], [1.9.0])
16 m4_define([tinyproxy_unstable],
17 m4_if(m4_eval(tinyproxy_minor_version % 2), [1], [yes], [no]))
18 m4_define([tinyproxy_stable],
19 m4_if(m4_eval(tinyproxy_minor_version % 2), [0], [yes], [no]))
21 AC_INIT([Tinyproxy], [tinyproxy_version],
22 [https://www.banu.com/bugzilla/enter_bug.cgi?product=tinyproxy],
26 AM_INIT_AUTOMAKE([foreign dist-bzip2])
27 AM_CONFIG_HEADER(config.h)
28 AC_CONFIG_MACRO_DIR([m4macros])
30 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
32 TINYPROXY_MAJOR_VERSION=tinyproxy_major_version
33 TINYPROXY_MINOR_VERSION=tinyproxy_minor_version
34 TINYPROXY_MICRO_VERSION=tinyproxy_micro_version
35 TINYPROXY_REAL_VERSION=tinyproxy_real_version
36 TINYPROXY_VERSION=tinyproxy_version
37 TINYPROXY_UNSTABLE=tinyproxy_unstable
38 AC_SUBST(TINYPROXY_MAJOR_VERSION)
39 AC_SUBST(TINYPROXY_MINOR_VERSION)
40 AC_SUBST(TINYPROXY_MICRO_VERSION)
41 AC_SUBST(TINYPROXY_REAL_VERSION)
42 AC_SUBST(TINYPROXY_VERSION)
43 AC_SUBST(TINYPROXY_UNSTABLE)
45 dnl Temporarily defined here until we get tinyproxy-version.h
46 AC_DEFINE(TINYPROXY_VERSION, "tinyproxy_version", [Tinyproxy version number])
48 # The symbol TINYPROXY_UNSTABLE is defined above for substitution in
49 # Makefiles and conditionally defined here as a preprocessor symbol
50 # and automake conditional.
51 if test "x$TINYPROXY_UNSTABLE" = "xyes"; then
52 AC_DEFINE(TINYPROXY_UNSTABLE, 1,
53 [Define to 1 if this is an unstable version of Tinyproxy])
55 AM_CONDITIONAL(TINYPROXY_UNSTABLE, test "x$TINYPROXY_UNSTABLE" = "xyes")
58 dnl Check if we're compiling on a weird platform :)
59 AC_USE_SYSTEM_EXTENSIONS
62 dnl Set the domain name for find the statistics of tinyproxy
63 AH_TEMPLATE([TINYPROXY_STATHOST],
64 [This controls remote proxy stats display.])
66 [AC_HELP_STRING([--with-stathost=HOST], [Default status host])],
67 [AC_DEFINE_UNQUOTED(TINYPROXY_STATHOST, "$withval")
68 TINYPROXY_STATHOST="$withval"],
69 [AC_DEFINE_UNQUOTED(TINYPROXY_STATHOST, "tinyproxy.stats")
70 TINYPROXY_STATHOST="tinyproxy.stats"])
72 AC_SUBST(TINYPROXY_STATHOST)
74 dnl Add compiler-specific optimization flags
76 [Enable debugging support code and methods (default is NO)],
79 dnl Check to see if the XTinyproxy header is to be included
80 AH_TEMPLATE([XTINYPROXY_ENABLE],
81 [Define if you want to have the peer's IP address included in a XTinyproxy header sent to the server.])
82 TP_ARG_ENABLE(xtinyproxy,
83 [Include the X-Tinyproxy header (default is YES)],
86 if test x"$xtinyproxy_enabled" = x"yes"; then
87 AC_DEFINE(XTINYPROXY_ENABLE)
90 dnl Include filtering for domain/URLs
91 AH_TEMPLATE([FILTER_ENABLE],
92 [Defined if you would like filtering code included.])
94 [Enable filtering of domains/URLS (default is YES)],
97 if test x"$filter_enabled" = x"yes"; then
98 ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS filter.o"
99 AC_DEFINE(FILTER_ENABLE)
102 dnl Include support for upstream proxies?
103 AH_TEMPLATE([UPSTREAM_SUPPORT],
104 [Include support for connecting to an upstream proxy.])
105 TP_ARG_ENABLE(upstream,
106 [Enable upstream proxying (default is YES)],
108 if test x"$upstream_enabled" = x"yes"; then
109 AC_DEFINE(UPSTREAM_SUPPORT)
112 dnl Include support for reverse proxy?
113 AH_TEMPLATE([REVERSE_SUPPORT],
114 [Include support for reverse proxy.])
115 TP_ARG_ENABLE(reverse,
116 [Enable reverse proxying (default is NO)],
118 if test x"$reverse_enabled" = x"yes"; then
119 ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS reverse-proxy.o"
120 AC_DEFINE(REVERSE_SUPPORT)
123 dnl Include the transparent proxy support
124 AH_TEMPLATE([TRANSPARENT_PROXY],
125 [Include support for using tinyproxy as a transparent proxy.])
126 TP_ARG_ENABLE(transparent,
127 [Enable transparent proxying code (default is NO)],
129 if test x"$transparent_enabled" = x"yes"; then
130 ADDITIONAL_OBJECTS="$ADDITIONAL_OBJECTS transparent-proxy.o"
131 AC_DEFINE(TRANSPARENT_PROXY)
134 dnl Check for broken regex library
135 TP_ARG_ENABLE(regexcheck,
136 [Check for working regex library (default is YES)],
139 # This is required to build test programs below
143 dnl Checks for libraries
145 AC_CHECK_LIB(socket, socket, , [AC_CHECK_LIB(socket, htonl)])
147 dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to
148 dnl avoid -lnsl checks, if we already have the functions which are
149 dnl usually in libnsl
151 unset ac_cv_func_yp_get_default_domain
152 AC_CHECK_FUNC(yp_get_default_domain,
153 tinyproxy_no_nsl_checks=yes,
154 tinyproxy_no_nsl_checks=no)
155 unset ac_cv_func_yp_get_default_domain
157 if test x"$tinyproxy_no_nsl_checks" != x"yes"; then
158 AC_CHECK_LIB(nsl, gethostname, , [AC_CHECK_LIB(nsl, gethostbyaddr)])
161 AC_CHECK_LIB(resolv, inet_aton)
164 dnl Checks for headers
169 AC_CHECK_HEADERS([sys/ioctl.h sys/mman.h sys/resource.h \
170 sys/select.h sys/socket.h sys/time.h sys/uio.h \
171 sys/un.h arpa/inet.h netinet/in.h \
172 assert.h ctype.h errno.h fcntl.h grp.h io.h libintl.h \
173 netdb.h pwd.h regex.h signal.h stdarg.h stddef.h stdio.h \
174 sysexits.h syslog.h time.h wchar.h wctype.h \
177 dnl OpenBSD machines don't like having malloc included (even if it's present)
178 dnl as they expect you to use stdlib.h
181 *) AC_CHECK_HEADER(malloc.h);;
188 AC_UNP_CHECK_TYPE(uint8_t, unsigned char)
189 AC_UNP_CHECK_TYPE(int16_t, short)
190 AC_UNP_CHECK_TYPE(uint16_t, unsigned short)
191 AC_UNP_CHECK_TYPE(int32_t, int)
192 AC_UNP_CHECK_TYPE(uint32_t, unsigned int)
193 AC_UNP_CHECK_TYPE(ssize_t, int)
194 AC_UNP_CHECK_TYPE(socklen_t, unsigned int)
195 AC_UNP_CHECK_TYPE(in_addr_t, uint32_t)
198 dnl Checks for libary functions
199 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
203 AC_CHECK_FUNCS([gethostname inet_ntoa memchr memset select socket strcasecmp \
204 strchr strdup strerror strncasecmp strpbrk strstr strtol])
205 AC_CHECK_FUNCS([isascii memcpy setrlimit ftruncate regcomp regexec])
206 AC_CHECK_FUNCS([strlcpy strlcat])
209 dnl Enable extra warnings
210 DESIRED_FLAGS="-fdiagnostics-show-option -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wfloat-equal -Wundef -Wformat=2 -Wlogical-op -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Waggregate-return -Winit-self -Wpacked --std=c89 -ansi -pedantic -Wno-overlength-strings -Wc++-compat -Wno-long-long -Wno-overlength-strings -Wdeclaration-after-statement -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-qual -Wcast-align -Wwrite-strings -Wp,-D_FORTIFY_SOURCE=2 -fno-common"
212 if test -n "${MAINTAINER_MODE_FALSE}"; then
213 DESIRED_FLAGS="-Werror $DESIRED_FLAGS"
216 for flag in $DESIRED_FLAGS; do
217 AS_COMPILER_FLAG([$flag], [CFLAGS="$CFLAGS $flag"])
220 dnl Disable debugging if it's not specified
221 if test x"$debug_enabled" != x"yes" ; then
222 CFLAGS="-DNDEBUG $CFLAGS"
225 LDFLAGS="-Wl,-z,defs"
228 dnl Make sure we can actually handle the "--with-*" and "--enable-*" stuff.
231 dnl Handle the REGEX library
232 if test x"$ac_cv_func_regexec" != x"yes"; then
233 AC_MSG_ERROR([Could not locate the regexec() function])
235 if test x"$regexcheck_enabled" = x"yes" ; then
236 AC_MSG_CHECKING([whether the system's regex library is broken])
237 AC_CACHE_VAL(tinyproxy_cv_regex_broken,
240 # include <sys/types.h>
254 if (regcomp(&blah, "foo.*bar", REG_NOSUB) != 0)
256 if (regexec(&blah, "foobar", 0, NULL, 0) != 0)
264 tinyproxy_cv_regex_broken=no,
265 tinyproxy_cv_regex_broken=yes,
266 tinyproxy_cv_regex_broken=yes)])
268 AC_MSG_RESULT([$tinyproxy_cv_regex_broken])
270 if test x"$tinyproxy_cv_regex_broken" = x"yes" ; then
271 AC_MSG_ERROR([Your system's regexec() function is broken.])
277 dnl Substitute the variables into the various Makefiles
283 AC_SUBST(ADDITIONAL_OBJECTS)
285 # Check for xml tools
286 AC_PATH_PROG(XMLLINT, xmllint, no)
287 AM_CONDITIONAL(HAVE_XMLLINT, test "x$XMLLINT" != "xno")
288 AC_PATH_PROG(XSLTPROC, xsltproc, no)
289 AM_CONDITIONAL(HAVE_XSLTPROC, test "x$XSLTPROC" != "xno")
292 AC_PATH_PROG(A2X, a2x, no)
293 AM_CONDITIONAL(HAVE_A2X, test "x$A2X" != "xno")
294 if test x"$A2X" = x"no"; then
295 AC_MSG_ERROR([Test for asciidoc failed. See the file 'INSTALL' for help.])
302 data/templates/Makefile
306 docs/man5/tinyproxy.conf.txt
308 docs/man8/tinyproxy.txt
311 tests/scripts/Makefile