Reducing length of URLs
[privoxy.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl 
3 dnl $Id: configure.in,v 1.26 2002/01/09 14:29:49 oes Exp $
4 dnl 
5 dnl Written by and Copyright (C) 2001 the SourceForge
6 dnl IJBSWA team.  http://ijbswa.sourceforge.net
7 dnl
8 dnl Based on the Internet Junkbuster originally written
9 dnl by and Copyright (C) 1997 Anonymous Coders and 
10 dnl Junkbusters Corporation.  http://www.junkbusters.com
11 dnl
12 dnl This program is free software; you can redistribute it 
13 dnl and/or modify it under the terms of the GNU General
14 dnl Public License as published by the Free Software
15 dnl Foundation; either version 2 of the License, or (at
16 dnl your option) any later version.
17 dnl 
18 dnl This program is distributed in the hope that it will
19 dnl be useful, but WITHOUT ANY WARRANTY; without even the
20 dnl implied warranty of MERCHANTABILITY or FITNESS FOR A
21 dnl PARTICULAR PURPOSE.  See the GNU General Public
22 dnl License for more details.
23 dnl 
24 dnl The GNU General Public License should be included with
25 dnl this file.  If not, you can view it at
26 dnl http://www.gnu.org/copyleft/gpl.html
27 dnl or write to the Free Software Foundation, Inc., 59
28 dnl Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29 dnl 
30 dnl $Log: configure.in,v $
31 dnl Revision 1.26  2002/01/09 14:29:49  oes
32 dnl - Added AC_CHECK_FUNC tests for the availability of
33 dnl   gethostbyname_r, gethostbyaddr_r, gmtime_r and
34 dnl   localtime_r, as well as AC_TRY_COMPILE tests to
35 dnl   determine their signatures.
36 dnl
37 dnl - Fixed a bug with the init of CFLAGS that was
38 dnl   reported by barsnick
39 dnl
40 dnl Revision 1.25  2002/01/04 15:27:18  oes
41 dnl Changed quoting of CODE_STATUS for use in make
42 dnl
43 dnl Revision 1.24  2001/12/30 14:07:31  steudten
44 dnl - Add signal handling (unix)
45 dnl - Add SIGHUP handler (unix)
46 dnl - Add creation of pidfile (unix)
47 dnl - Add action 'top' in rc file (RH)
48 dnl - Add entry 'SIGNALS' to manpage
49 dnl - Add exit message to logfile (unix)
50 dnl
51 dnl Revision 1.23  2001/12/09 20:24:42  david__schmidt
52 dnl Change from "alpha" to "beta" in configure.in
53 dnl
54 dnl Revision 1.22  2001/12/01 11:24:01  jongfoster
55 dnl Renaming Makefile.in to GNUmakefile.in so that non-GNU versions of
56 dnl make break in a more obvious way.
57 dnl
58 dnl Revision 1.21  2001/11/30 21:35:54  jongfoster
59 dnl Bumping version number to 2.9.10
60 dnl
61 dnl Revision 1.20  2001/10/23 21:24:09  jongfoster
62 dnl Support for FEATURE_CGI_EDIT_ACTIONS
63 dnl
64 dnl Revision 1.19  2001/10/07 15:33:14  oes
65 dnl Removed FEATURE_DENY_GZIP
66 dnl Bumped up version number
67 dnl
68 dnl Revision 1.18  2001/09/13 13:10:24  steudten
69 dnl
70 dnl PreWork for Debug Interface.
71 dnl Add new option "--with-debug" to enable debugging (flags aso.)
72 dnl
73 dnl Revision 1.17  2001/09/12 23:44:55  david__schmidt
74 dnl Mac OSX (Darwin) support added.
75 dnl
76 dnl Revision 1.16  2001/09/12 22:55:45  joergs
77 dnl AmigaOS support added.
78 dnl
79 dnl Revision 1.15  2001/09/12 17:28:59  david__schmidt
80 dnl
81 dnl OS/2 port: update autoconf'd support for the platform.
82 dnl
83 dnl Revision 1.14  2001/07/30 22:12:11  jongfoster
84 dnl Fixing Solaris build (I hope) and tidying up #defines:
85 dnl - All feature #defines are now of the form FEATURE_xxx
86 dnl - Permanently turned off WIN_GUI_EDIT
87 dnl - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
88 dnl
89 dnl Revision 1.13  2001/07/29 17:09:17  jongfoster
90 dnl Major changes to build system in order to fix these bugs:
91 dnl - pthreads under Linux was broken - changed -lpthread to -pthread
92 dnl - Compiling in MinGW32 mode under CygWin now correctly detects
93 dnl   which shared libraries are available
94 dnl - Solaris support (?) (Not tested under Solaris yet)
95 dnl
96 dnl Revision 1.12  2001/07/25 19:16:27  oes
97 dnl Bumping version number to 2.9.8
98 dnl
99 dnl Revision 1.11  2001/07/21 18:00:07  jongfoster
100 dnl Bumping version number to 2.9.7
101 dnl
102 dnl Revision 1.10  2001/07/18 17:25:04  oes
103 dnl Fixed a typo
104 dnl
105 dnl Revision 1.9  2001/07/15 19:45:13  jongfoster
106 dnl Added support for linking with POSIX threads library
107 dnl
108 dnl Revision 1.8  2001/07/15 17:54:29  jongfoster
109 dnl Renaming #define STATIC to STATIC_PCRE
110 dnl Adding new #define FEATURE_PTHREAD that will be used to enable
111 dnl POSIX threads support.
112 dnl
113 dnl Revision 1.7  2001/07/13 13:58:05  oes
114 dnl    Completely reorganized the selection scheme for
115 dnl    pcre, pcreposix, pcrs and gnu_regex:
116 dnl
117 dnl    The presence of shared pcre, pcreposix or pcrs
118 dnl    libraried is now autodetected. Additionally, the
119 dnl    user can enforce using the built-in static variants
120 dnl    by specifying --disable-dynamic-(pcre|pcrs).
121 dnl    Care is taken to avoid that pcre is dyn, while pcreposix
122 dnl    is static, if both are used and that pcrs is static if
123 dnl    pcrs is.
124 dnl
125 dnl    The choice between pcre, gnu or no regex for actionsfile
126 dnl    URL matching is now via
127 dnl    --(enable|disable)-regex-matching[=(gnu|pcre|no)] with the
128 dnl    default being pcre.
129 dnl
130 dnl Revision 1.6  2001/06/29 21:56:40  oes
131 dnl Version -> 2.9.5
132 dnl
133 dnl Revision 1.5  2001/06/29 13:26:27  oes
134 dnl Introduced #define CODE_STATUS
135 dnl
136 dnl Revision 1.4  2001/05/29 09:50:24  jongfoster
137 dnl Unified blocklist/imagelist/permissionslist.
138 dnl File format is still under discussion, but the internal changes
139 dnl are (mostly) done.
140 dnl
141 dnl Also modified interceptor behaviour:
142 dnl - We now intercept all URLs beginning with one of the following
143 dnl   prefixes (and *only* these prefixes):
144 dnl     * http://i.j.b/
145 dnl     * http://ijbswa.sf.net/config/
146 dnl     * http://ijbswa.sourceforge.net/config/
147 dnl - New interceptors "home page" - go to http://i.j.b/ to see it.
148 dnl - Internal changes so that intercepted and fast redirect pages
149 dnl   are not replaced with an image.
150 dnl - Interceptors now have the option to send a binary page direct
151 dnl   to the client. (i.e. ijb-send-banner uses this)
152 dnl - Implemented show-url-info interceptor.  (Which is why I needed
153 dnl   the above interceptors changes - a typical URL is
154 dnl   "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
155 dnl   The previous mechanism would not have intercepted that, and
156 dnl   if it had been intercepted then it then it would have replaced
157 dnl   it with an image.)
158 dnl
159 dnl Revision 1.3  2001/05/22 18:46:04  oes
160 dnl
161 dnl - Enabled filtering banners by size rather than URL
162 dnl   by adding patterns that replace all standard banner
163 dnl   sizes with the "Junkbuster" gif to the re_filterfile
164 dnl
165 dnl - Enabled filtering WebBugs by providing a pattern
166 dnl   which kills all 1x1 images
167 dnl
168 dnl - Added support for PCRE_UNGREEDY behaviour to pcrs,
169 dnl   which is selected by the (nonstandard and therefore
170 dnl   capital) letter 'U' in the option string.
171 dnl   It causes the quantifiers to be ungreedy by default.
172 dnl   Appending a ? turns back to greedy (!).
173 dnl
174 dnl - Added a new interceptor ijb-send-banner, which
175 dnl   sends back the "Junkbuster" gif. Without imagelist or
176 dnl   MSIE detection support, or if tinygif = 1, or the
177 dnl   URL isn't recognized as an imageurl, a lame HTML
178 dnl   explanation is sent instead.
179 dnl
180 dnl - Added new feature, which permits blocking remote
181 dnl   script redirects and firing back a local redirect
182 dnl   to the browser.
183 dnl   The feature is conditionally compiled, i.e. it
184 dnl   can be disabled with --disable-fast-redirects,
185 dnl   plus it must be activated by a "fast-redirects"
186 dnl   line in the config file, has its own log level
187 dnl   and of course wants to be displayed by show-proxy-args
188 dnl   Note: Boy, all the #ifdefs in 1001 locations and
189 dnl   all the fumbling with configure.in and acconfig.h
190 dnl   were *way* more work than the feature itself :-(
191 dnl
192 dnl - Because a generic redirect template was needed for
193 dnl   this, tinygif = 3 now uses the same.
194 dnl
195 dnl - Moved GIFs, and other static HTTP response templates
196 dnl   to project.h
197 dnl
198 dnl - Some minor fixes
199 dnl
200 dnl - Removed some >400 CRs again (Jon, you really worked
201 dnl   a lot! ;-)
202 dnl
203 dnl Revision 1.2  2001/05/20 01:21:20  jongfoster
204 dnl Version 2.9.4 checkin.
205 dnl - Merged popupfile and cookiefile, and added control over PCRS
206 dnl   filtering, in new "permissionsfile".
207 dnl - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
208 dnl   file error you now get a message box (in the Win32 GUI) rather
209 dnl   than the program exiting with no explanation.
210 dnl - Made killpopup use the PCRS MIME-type checking and HTTP-header
211 dnl   skipping.
212 dnl - Removed tabs from "config"
213 dnl - Moved duplicated url parsing code in "loaders.c" to a new funcition.
214 dnl - Bumped up version number.
215 dnl
216 dnl Revision 1.1.1.1  2001/05/15 13:58:50  oes
217 dnl Initial import of version 2.9.3 source tree
218 dnl
219 dnl 
220
221
222 dnl =================================================================
223 dnl AutoConf Initialization
224 dnl =================================================================
225
226 AC_REVISION($Revision: 1.26 $)
227 AC_INIT(jcc.c)
228 AC_CONFIG_HEADER(config.h)
229 AC_CANONICAL_HOST
230
231
232 dnl =================================================================
233 dnl Application version number
234 dnl =================================================================
235
236 VERSION_MAJOR=2
237 VERSION_MINOR=9
238 VERSION_POINT=10
239 CODE_STATUS="beta"
240
241 dnl CODE_STATUS can be "alpha", "beta", or "stable", and will be
242 dnl used for CGI output
243
244 dnl =================================================================
245 dnl Substitute the version numbers
246 dnl =================================================================
247
248 AC_SUBST(VERSION_MAJOR)
249 AC_SUBST(VERSION_MINOR)
250 AC_SUBST(VERSION_POINT)
251 AC_SUBST(CODE_STATUS)
252
253 dnl
254 AC_DEFINE_UNQUOTED(VERSION_MAJOR,${VERSION_MAJOR})
255 AC_DEFINE_UNQUOTED(VERSION_MINOR,${VERSION_MINOR})
256 AC_DEFINE_UNQUOTED(VERSION_POINT,${VERSION_POINT})
257 AC_DEFINE_UNQUOTED(VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_POINT}")
258 AC_DEFINE_UNQUOTED(CODE_STATUS,"${CODE_STATUS}")
259
260 dnl =================================================================
261 dnl pid file only for unix 
262 dnl =================================================================
263 dnl 
264 PID_FILE_PATH="\"/etc/junkbuster"\"
265
266 dnl =================================================================
267 dnl Checks for programs needed to build.
268 dnl =================================================================
269 AC_PROG_CC
270 AC_PROG_CPP
271 dnl AC_PROG_CXX
272 dnl AC_PROG_INSTALL
273 dnl AC_PROG_LN_S
274 dnl AC_PROG_MAKE_SET
275 dnl RANLIB is for PCRE:
276 dnl AC_PROG_RANLIB
277
278 AC_CHECK_PROG(GDB,gdb,yes,no)
279
280 dnl =================================================================
281 dnl debug, gcc and gdb support 
282 dnl =================================================================
283
284 AC_ARG_WITH(debug,
285         [  --with-debug            Enable debug mode],
286         [
287                 if test "x$withval" != "$xno" ; then
288                     if test $ac_cv_prog_cc_g = yes; then
289                       if test "$GCC" = yes; then
290                         if test "$GDB"; then
291                           CFLAGS="-ggdb"
292                         else
293                           CFLAGS="-g"
294                         fi
295                         CFLAGS="$CFLAGS -Wshadow  -Wconversion"
296                       else
297                         CFLAGS="-g"
298                       fi
299                    fi
300                    CFLAGS="$CFLAGS -D_DEBUG"
301                 fi
302         ],
303         [
304             if test "X$CFLAGS" = "X"; then # if CFLAGS are unset
305               if test "$GCC" = yes; then
306                 CFLAGS="-O2"
307               else
308                 CFLAGS=
309               fi
310             fi
311         ]
312 )
313
314 dnl =================================================================
315 dnl additional gcc flags
316 dnl =================================================================
317 dnl 
318 if test "$GCC"; then
319   CFLAGS="-pipe $CFLAGS"
320 fi
321
322
323 dnl =================================================================
324 dnl Build type
325 dnl =================================================================
326 dnl
327 dnl Must do this first.
328 dnl
329 dnl Reason: This sets CFLAGS in order to switch the Cygwin compiler
330 dnl into Cygwin or MinGW32 modes.  Depending on the mode selected,
331 dnl the compiler will use completely different sets of library
332 dnl and include files.
333 dnl 
334 dnl =================================================================
335
336 AC_MINGW32
337 AC_CYGWIN
338
339 if test "$MINGW32" = "yes"; then
340   target_type=mingw
341 else
342   if test "$CYGWIN" = "yes"; then
343     target_type=cygwin
344   else
345     target_type=unix
346   fi
347 fi
348
349 dnl Decide what to do based on target_type
350 dnl Note: PTHREAD_LIB is always set, even if pthread is disabled.
351 dnl This is because we don't know yet whether pthread is enabled.
352
353 AC_ARG_ENABLE(mingw32,
354 [  --enable-mingw32        Use mingw32 for a Windows GUI],
355 [if test $enableval = yes; then
356   target_type=mingw
357 fi])
358
359 if test $target_type = mingw; then
360   WIN_ONLY=
361   SPECIAL_CFLAGS="-mwindows -mno-cygwin"
362   PTHREAD_LIB=-lpthreadGC
363   echo "Using mingw32 (Win32 GUI)"
364 else
365   WIN_ONLY=#
366   if test $target_type = cygwin; then
367     SPECIAL_CFLAGS="-mno-win32"
368     PTHREAD_LIB=
369     echo "Using Cygnus (Win32 command line)"
370   else
371     SPECIAL_CFLAGS=
372     PTHREAD_LIB=-lpthread
373   fi
374 fi
375 AC_SUBST(WIN_ONLY)
376
377
378 dnl Save old CFLAGS so we can restore them later, then add SPECIAL_CFLAGS
379 old_CFLAGS_nospecial=$CFLAGS
380 CFLAGS="$CFLAGS $SPECIAL_CFLAGS"
381
382 # Hack to force AutoConf to use the CFLAGS we just set
383 dnl Warning: This may break with a future version of Autoconf
384 dnl          Tested with autoconf 2.13
385 ac_cpp='$CPP $CPPFLAGS $SPECIAL_CFLAGS'
386 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
387 ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
388
389
390 dnl =================================================================
391 dnl Thread support
392 dnl =================================================================
393
394 AC_CHECK_HEADER(pthread.h, [have_pthread=yes], [have_pthread=no])
395
396 AC_ARG_ENABLE(pthread,
397 [  --disable-pthread       Don't use POSIX threads (pthreads)],
398 [if test $enableval = no; then
399   # Disable pthreads
400   have_pthread=no
401 fi])
402
403 if test $have_pthread = yes; then
404   PTHREAD_ONLY=
405   AC_DEFINE(FEATURE_PTHREAD)
406   echo Using POSIX threads
407   if test "$GCC" = "yes"; then
408     # Set a GCC specific switch:
409     if test "$target_type" = "unix"; then
410       # This compiler switch makes Linux thread-safe
411       # Don't know about other OS's?  Is this switch
412       # supported?
413       PTHREAD_LIB=
414       SPECIAL_CFLAGS="-pthread"
415     fi
416   fi
417 else
418   PTHREAD_ONLY=#
419   echo Using native threads
420 fi
421
422 AC_SUBST(PTHREAD_ONLY)
423
424 dnl =================================================================
425 dnl Support for thread-safe versions of gethostbyaddr, gethostbyname,
426 dnl gmtime and localtime
427 dnl =================================================================
428
429 AC_CHECK_FUNC(gethostbyaddr_r, [
430   AC_MSG_CHECKING([signature of gethostbyaddr_r])
431   AC_TRY_COMPILE([
432 #   include <netdb.h>
433   ], [
434     struct hostent *h, *hp;
435     char *a, *b;
436     int l, bl, t, e;
437     (void) gethostbyaddr_r(a, l, t, h, b, bl, &hp, &e)
438   ], [
439     AC_DEFINE(HAVE_GETHOSTBYADDR_R_8_ARGS)
440     AC_MSG_RESULT([8 args])
441   ], [
442     AC_TRY_COMPILE([
443 #     include <netdb.h>
444     ], [
445       struct hostent *h;
446       char *a, *b;
447       int l, bl, t, e;
448       (void) gethostbyaddr_r(a, l, t, h, b, bl, &e)
449     ], [
450       AC_DEFINE(HAVE_GETHOSTBYADDR_R_7_ARGS)
451       AC_MSG_RESULT([7 args])
452     ], [
453       AC_TRY_COMPILE([
454 #       include <netdb.h>
455       ], [
456         struct hostent_data *d;
457         struct hostent *h;
458         char a,
459         int l, t;
460         (void) gethostbyaddr_r(a, l, t, h, d)
461       ], [
462         AC_DEFINE(HAVE_GETHOSTBYADDR_R_5_ARGS)
463         AC_MSG_RESULT([5 args])
464       ], [
465         AC_MSG_RESULT(unrecognised)
466       ])
467     ])
468   ])
469 ], [
470   AC_MSG_RESULT(no)
471 ])
472
473 AC_CHECK_FUNC(gethostbyname_r, [
474   AC_MSG_CHECKING([signature of gethostbyname_r])
475   AC_TRY_COMPILE([
476 #   include <netdb.h>
477   ], [
478     struct hostent *h, *r;
479     char *n, *b;
480     int bl, e;
481     (void) gethostbyname_r(n, h, b, bl, &r, &e)
482   ], [
483     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARGS)
484     AC_MSG_RESULT([6 args])
485   ], [
486     AC_TRY_COMPILE([
487 #     include <netdb.h>
488     ], [
489       struct hostent *h;
490       char *n, *b;
491       int bl, e;
492       (void) gethostbyname_r(n, h, b, bl, &e)
493     ], [
494       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARGS)
495       AC_MSG_RESULT([5 args])
496     ], [
497       AC_TRY_COMPILE([
498 #       include <netdb.h>
499       ], [
500         struct hostent_data *d;
501         struct hostent *h;
502         char *n,
503         (void) gethostbyname_r(n, h, d)
504       ], [
505         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARGS)
506         AC_MSG_RESULT([3 args])
507       ], [
508         AC_MSG_RESULT(unrecognised)
509       ])
510     ])
511   ])
512 ], [
513   AC_MSG_RESULT(no)
514 ])
515
516 AC_CHECK_FUNC(gmtime_r, [
517   AC_MSG_CHECKING([signature of gmtime_r])
518   AC_TRY_COMPILE([
519 #   include <time.h>
520   ], [
521     struct time *t;
522     struct tm *tm;
523     (void) gmtime_r(t, tm)
524   ], [
525     AC_MSG_RESULT(ok)
526     AC_DEFINE(HAVE_GMTIME_R)
527   ], [
528     AC_MSG_RESULT(unrecognised)
529   ])
530 ], [
531   AC_MSG_RESULT(no)
532 ])
533
534 AC_CHECK_FUNC(localtime_r, [
535   AC_MSG_CHECKING([signature of localtime_r])
536   AC_TRY_COMPILE([
537 #   include <time.h>
538   ], [
539     struct time *t;
540     struct tm *tm;
541     (void) localtime_r(t, tm)
542   ], [
543     AC_MSG_RESULT(ok)
544     AC_DEFINE(HAVE_LOCALTIME_R)
545   ], [
546     AC_MSG_RESULT(unrecognised)
547   ])
548 ], [
549   AC_MSG_RESULT(no)
550 ])
551
552 dnl =================================================================
553 dnl Solaris specific
554 dnl FIXME: Not tested on Solaris yet...
555 dnl =================================================================
556
557
558 SOCKET_LIB=
559
560 case "$host" in
561 *-solaris*) SOCKET_LIB="-lsocket -lnsl"
562             AC_DEFINE(__EXTENSIONS__)
563             if test "$GCC" = "yes"; then
564               # Set a GCC specific switch:
565               # This compiler switch makes Solaris thread-safe
566               PTHREAD_LIB=
567               SPECIAL_CFLAGS="-pthreads"
568             else
569               # What do we do without GCC? Guess this:
570               SPECIAL_CFLAGS="-D_REENTRANT"
571             fi
572 ;;
573 esac
574
575 AC_SUBST(SOCKET_LIB)
576
577 dnl =================================================================
578 dnl OS/2 specific
579 dnl =================================================================
580
581 case "$host" in
582 *-os2-emx*) SOCKET_LIB=-lsocket
583 ;;
584 esac
585
586 AC_SUBST(SOCKET_LIB)
587
588 dnl =================================================================
589 dnl AmigaOS specific
590 dnl =================================================================
591
592 AMIGAOS_ONLY=#
593
594 case "$host" in
595 *-amigaos) AMIGAOS_ONLY=
596 ;;
597 esac
598
599 AC_SUBST(AMIGAOS_ONLY)
600
601 dnl =================================================================
602 dnl Check for standard compiler stuff
603 dnl =================================================================
604
605 AC_EXEEXT
606 AC_OBJEXT
607 AC_HEADER_STDC
608 AC_C_CONST
609 AC_TYPE_SIZE_T
610 AC_CHECK_SIZEOF(int, 4)
611 AC_CHECK_SIZEOF(char *, 4)
612 AC_CHECK_SIZEOF(long, 4)
613 AC_CHECK_SIZEOF(long long, 8)
614 AC_CHECK_SIZEOF(size_t, 4)
615
616 dnl Checks for header files.
617 dnl AC_HEADER_SYS_WAIT
618 dnl AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/time.h unistd.h)
619
620 dnl Checks for library functions.
621 dnl AC_TYPE_SIGNAL
622 dnl AC_CHECK_FUNC(strstr)
623 dnl bcopy and memmove are for PCRE
624 AC_CHECK_FUNCS(strerror bcopy memmove)
625
626
627 dnl =================================================================
628 dnl Checks for libraries.
629 dnl =================================================================
630 dnl Note: Some systems may have the library but not the system header
631 dnl       file, so we must check for both.
632 AC_CHECK_LIB(pcre, pcre_compile, [AC_CHECK_HEADER(pcre.h, [have_pcre=yes], [have_pcre=no])], [have_pcre=no])
633 AC_CHECK_LIB(pcreposix, regcomp, [AC_CHECK_HEADER(pcreposix.h, [have_pcreposix=yes], [have_pcreposix=no])], [have_pcreposix=no], -lpcre)
634 AC_CHECK_LIB(pcrs, pcrs_compile, [AC_CHECK_HEADER(pcrs.h, [have_pcrs=yes], [have_pcrs=no])], [have_pcrs=no])
635
636
637 dnl =================================================================
638 dnl Always defined
639 dnl =================================================================
640
641 AC_DEFINE(__MT__)
642
643 dnl =================================================================
644 dnl Features
645 dnl =================================================================
646
647 AC_ARG_ENABLE(toggle,
648 [  --disable-toggle         Don't support temporary disable],
649 [if test $enableval = yes; then
650   AC_DEFINE(FEATURE_TOGGLE)
651 fi],AC_DEFINE(FEATURE_TOGGLE))
652
653 AC_ARG_ENABLE(force,
654 [  --disable-force          Don't allow single-page disable],
655 [if test $enableval = yes; then
656   AC_DEFINE(FEATURE_FORCE_LOAD)
657 fi],AC_DEFINE(FEATURE_FORCE_LOAD))
658
659 AC_ARG_ENABLE(fast-redirects,
660 [  --disable-fast-redirects Don't support fast redirects],
661 [if test $enableval = yes; then
662   AC_DEFINE(FEATURE_FAST_REDIRECTS)
663 fi], AC_DEFINE(FEATURE_FAST_REDIRECTS))
664
665 AC_ARG_ENABLE(killpopup,
666 [  --disable-killpopup      Never block popups],
667 [if test $enableval = yes; then
668   AC_DEFINE(FEATURE_KILL_POPUPS)
669 fi],AC_DEFINE(FEATURE_KILL_POPUPS))
670
671 AC_ARG_ENABLE(stats,
672 [  --disable-stats          Don't keep statistics],
673 [if test $enableval = yes; then
674   AC_DEFINE(FEATURE_STATISTICS)
675 fi],AC_DEFINE(FEATURE_STATISTICS))
676
677 AC_ARG_ENABLE(ie-images,
678 [  --disable-ie-images      Don't auto-detect whether a request from MS Internet
679                            Explorer is for an image or HTML.],
680 [if test $enableval = yes; then
681   AC_DEFINE(FEATURE_IMAGE_DETECT_MSIE)
682 fi],
683 AC_DEFINE(FEATURE_IMAGE_DETECT_MSIE))
684
685 AC_ARG_ENABLE(image-blocking,
686 [  --disable-image-blocking Don't try to figure out whether a request is 
687                            for an image or HTML - assume HTML.],
688 [if test $enableval = yes; then
689   AC_DEFINE(FEATURE_IMAGE_BLOCKING)
690 fi],
691 AC_DEFINE(FEATURE_IMAGE_BLOCKING))
692
693 AC_ARG_ENABLE(acl-files,
694 [  --disable-acl-files      Prevents the use of ACL files to control access to
695                            the proxy by IP address.],
696 [if test $enableval = yes; then
697   AC_DEFINE(FEATURE_ACL)
698 fi],
699 AC_DEFINE(FEATURE_ACL))
700
701 AC_ARG_ENABLE(trust-files,
702 [  --disable-trust-files    Prevents the use of trust files.],
703 [if test $enableval = yes; then
704   AC_DEFINE(FEATURE_TRUST)
705 fi],
706 AC_DEFINE(FEATURE_TRUST))
707
708 AC_ARG_ENABLE(jar-files,
709 [  --disable-jar-files      Prevents the use of jar files to capture cookies.],
710 [if test $enableval = yes; then
711   AC_DEFINE(FEATURE_COOKIE_JAR)
712 fi],
713 AC_DEFINE(FEATURE_COOKIE_JAR))
714
715 AC_ARG_ENABLE(editor,
716 [  --disable-editor         Prevents the use of the web-based actions file
717                            editor and web-based temporary disable setting.],
718 [if test $enableval = yes; then
719   AC_DEFINE(FEATURE_CGI_EDIT_ACTIONS)
720 fi],
721 AC_DEFINE(FEATURE_CGI_EDIT_ACTIONS))
722
723 dnl pcre/pcrs is needed for CGI anyway, so
724 dnl the choice is only between static and
725 dnl dynamic:
726
727 AC_ARG_ENABLE(regex-matching,
728 [  --enable-regex-matching=pcre  Use perl-compatible regex for actionsfile
729                                 pattern matching (default)
730   --enable-regex-matching=gnu   Use gnu style regex for actionsfile pattern
731                                 matching (-> bigger binary)
732   --disable-regex-matching      Don't use regex matching, compare URL
733                                 prefix instead (won't shrink birary)],
734 [ regex_matching=$enableval ],
735 [ regex_matching=pcre ])
736
737 AC_ARG_ENABLE(dynamic-pcre,
738 [  --disable-dynamic-pcre        Use the built-in, static pcre, even if
739                                 libpcre is available],
740 [ if test $enableval = "no"; then have_pcre=no; fi ])
741
742 AC_ARG_ENABLE(dynamic-pcrs,
743 [  --disable-dynamic-pcrs        Use the built-in, static pcrs, even if
744                                 libpcrs is available],
745 [ if test $enableval = "no"; then have_pcrs=no; fi ])
746
747
748 # Is the regex URL matching based on libpcreposix, but we
749 # don't have that library?
750 #
751 if test $have_pcreposix = "yes" -o $regex_matching != "pcre"; then
752   dont_miss_pcreposix=yes
753 else
754   dont_miss_pcreposix=no
755 fi
756
757 # If we have libpcre and either we also have pcreposix or
758 # we don't need pcreposix, then link pcre dynamically; else
759 # build it and link statically
760 #
761 if test $have_pcre = "yes" -a $dont_miss_pcreposix = "yes"; then
762   echo "using libpcre"
763   pcre_dyn=yes
764   STATIC_PCRE_ONLY=#
765   LIBS="$LIBS -lpcre"
766 else
767   echo "using built-in static pcre"
768   pcre_dyn=no
769   AC_DEFINE(STATIC_PCRE)
770   STATIC_PCRE_ONLY=
771 fi
772
773 # If we have libpcrs and pcre is linked dynamically
774 # then also link pcrs dynamically, else build and link
775 # pcrs statically
776 #
777 if test $have_pcrs = "yes" -a $pcre_dyn = "yes"; then
778   echo "using libpcrs"
779   STATIC_PCRS_ONLY=#
780   LIBS="$LIBS -lpcrs"
781 else
782   echo "using built-in static pcrs"
783   AC_DEFINE(STATIC_PCRS)
784   STATIC_PCRS_ONLY=
785 fi
786
787 # Which method should be used for URL matching?
788 # pcre, gnu regex or prefix matching?
789 #
790 if test $regex_matching = "gnu"; then
791   echo "using gnu regex for URL matching"
792   AC_DEFINE(REGEX_GNU)
793   GNU_REGEX_ONLY=
794   PCRE_REGEX_ONLY=#
795 elif test $regex_matching = "pcre"; then
796   echo "using pcre regex for URL matching"
797   AC_DEFINE(REGEX_PCRE)
798   GNU_REGEX_ONLY=#
799   PCRE_REGEX_ONLY=
800   if test $pcre_dyn = "yes"; then
801     LIBS="$LIBS -lpcreposix"
802   fi
803 else
804   echo -e "using prefix matching for URLs\nHint: This does NOT make the executable any smaller!"
805   GNU_REGEX_ONLY=#
806   PCRE_REGEX_ONLY=#
807 fi
808
809 AC_SUBST(GNU_REGEX_ONLY)
810 AC_SUBST(PCRE_REGEX_ONLY)
811 AC_SUBST(STATIC_PCRE_ONLY)
812 AC_SUBST(STATIC_PCRS_ONLY)
813
814 dnl =================================================================
815 dnl Final cleanup and output
816 dnl =================================================================
817
818 dnl Remove the SPECIAL_CFLAGS stuff from CFLAGS, and add it seperately
819 dnl in the Makefile
820 CFLAGS=$old_CFLAGS_nospecial
821 AC_SUBST(SPECIAL_CFLAGS)
822
823 AC_SUBST(PID_FILE_PATH)
824 AC_DEFINE_UNQUOTED(PID_FILE_PATH,${PID_FILE_PATH})
825
826 AC_SUBST(PTHREAD_LIB)
827
828 AC_OUTPUT(GNUmakefile)