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