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