]> granicus.if.org Git - apache/blob - acinclude.m4
Always emit Vary header if mod_deflate is involved in the request.
[apache] / acinclude.m4
1
2 dnl APACHE_HELP_STRING(LHS, RHS)
3 dnl Autoconf 2.50 can not handle substr correctly.  It does have 
4 dnl AC_HELP_STRING, so let's try to call it if we can.
5 dnl Note: this define must be on one line so that it can be properly returned
6 dnl as the help string.
7 AC_DEFUN(APACHE_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING($1,$2),[  ]$1 substr([                       ],len($1))$2)])dnl
8
9 dnl APACHE_SUBST(VARIABLE)
10 dnl Makes VARIABLE available in generated files
11 dnl (do not use @variable@ in Makefiles, but $(variable))
12 AC_DEFUN(APACHE_SUBST,[
13   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
14   AC_SUBST($1)
15 ])
16
17 dnl APACHE_FAST_OUTPUT(FILENAME)
18 dnl Perform substitutions on FILENAME (Makefiles only)
19 AC_DEFUN(APACHE_FAST_OUTPUT,[
20   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
21 ])
22
23 dnl APACHE_GEN_CONFIG_VARS
24 dnl Creates config_vars.mk
25 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
26   APACHE_SUBST(abs_srcdir)
27   APACHE_SUBST(bindir)
28   APACHE_SUBST(sbindir)
29   APACHE_SUBST(cgidir)
30   APACHE_SUBST(logfiledir)
31   APACHE_SUBST(exec_prefix)
32   APACHE_SUBST(datadir)
33   APACHE_SUBST(localstatedir)
34   APACHE_SUBST(mandir)
35   APACHE_SUBST(libdir)
36   APACHE_SUBST(libexecdir)
37   APACHE_SUBST(htdocsdir)
38   APACHE_SUBST(manualdir)
39   APACHE_SUBST(includedir)
40   APACHE_SUBST(errordir)
41   APACHE_SUBST(iconsdir)
42   APACHE_SUBST(sysconfdir)
43   APACHE_SUBST(installbuilddir)
44   APACHE_SUBST(runtimedir)
45   APACHE_SUBST(proxycachedir)
46   APACHE_SUBST(other_targets)
47   APACHE_SUBST(progname)
48   APACHE_SUBST(prefix)
49   APACHE_SUBST(AWK)
50   APACHE_SUBST(CC)
51   APACHE_SUBST(CPP)
52   APACHE_SUBST(CXX)
53   APACHE_SUBST(CPPFLAGS)
54   APACHE_SUBST(CFLAGS)
55   APACHE_SUBST(CXXFLAGS)
56   APACHE_SUBST(LTFLAGS)
57   APACHE_SUBST(LDFLAGS)
58   APACHE_SUBST(LT_LDFLAGS)
59   APACHE_SUBST(SH_LDFLAGS)
60   APACHE_SUBST(HTTPD_LDFLAGS)
61   APACHE_SUBST(UTIL_LDFLAGS)
62   APACHE_SUBST(LIBS)
63   APACHE_SUBST(DEFS)
64   APACHE_SUBST(INCLUDES)
65   APACHE_SUBST(NOTEST_CPPFLAGS)
66   APACHE_SUBST(NOTEST_CFLAGS)
67   APACHE_SUBST(NOTEST_CXXFLAGS)
68   APACHE_SUBST(NOTEST_LDFLAGS)
69   APACHE_SUBST(NOTEST_LIBS)
70   APACHE_SUBST(EXTRA_CPPFLAGS)
71   APACHE_SUBST(EXTRA_CFLAGS)
72   APACHE_SUBST(EXTRA_CXXFLAGS)
73   APACHE_SUBST(EXTRA_LDFLAGS)
74   APACHE_SUBST(EXTRA_LIBS)
75   APACHE_SUBST(EXTRA_INCLUDES)
76   APACHE_SUBST(LIBTOOL)
77   APACHE_SUBST(SHELL)
78   APACHE_SUBST(MODULE_DIRS)
79   APACHE_SUBST(MODULE_CLEANDIRS)
80   APACHE_SUBST(PORT)
81   APACHE_SUBST(CORE_IMPLIB_FILE)
82   APACHE_SUBST(CORE_IMPLIB)
83   APACHE_SUBST(SH_LIBS)
84   APACHE_SUBST(SH_LIBTOOL)
85   APACHE_SUBST(MK_IMPLIB)
86   APACHE_SUBST(INSTALL_PROG_FLAGS)
87   APACHE_SUBST(DSO_MODULES)
88   APACHE_SUBST(APR_BINDIR)
89   APACHE_SUBST(APU_BINDIR)
90
91   abs_srcdir="`(cd $srcdir && pwd)`"
92
93   echo creating config_vars.mk
94   test -d build || $mkdir_p build
95   > build/config_vars.mk
96   for i in $APACHE_VAR_SUBST; do
97     eval echo "$i = \$$i" >> build/config_vars.mk
98   done
99 ])
100
101 dnl APACHE_GEN_MAKEFILES
102 dnl Creates Makefiles
103 AC_DEFUN(APACHE_GEN_MAKEFILES,[
104   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
105 ])
106
107 dnl ## APACHE_OUTPUT(file)
108 dnl ## adds "file" to the list of files generated by AC_OUTPUT
109 dnl ## This macro can be used several times.
110 AC_DEFUN(APACHE_OUTPUT, [
111   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
112 ])
113
114 dnl
115 dnl APACHE_TYPE_RLIM_T
116 dnl
117 dnl If rlim_t is not defined, define it to int
118 dnl
119 AC_DEFUN(APACHE_TYPE_RLIM_T, [
120   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
121     AC_TRY_COMPILE([
122 #include <sys/types.h>
123 #include <sys/time.h>
124 #include <sys/resource.h>
125 ], [rlim_t spoon;], [
126       ac_cv_type_rlim_t=yes
127     ],[ac_cv_type_rlim_t=no
128     ])
129   ])
130   if test "$ac_cv_type_rlim_t" = "no" ; then
131       AC_DEFINE(rlim_t, int,
132           [Define to 'int' if <sys/resource.h> doesn't define it for us])
133   fi
134 ])
135
136 dnl APACHE_MODPATH_INIT(modpath)
137 AC_DEFUN(APACHE_MODPATH_INIT,[
138   current_dir=$1
139   modpath_current=modules/$1
140   modpath_static=
141   modpath_shared=
142   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
143   > $modpath_current/modules.mk
144 ])dnl
145 dnl
146 AC_DEFUN(APACHE_MODPATH_FINISH,[
147   echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
148   echo "static = $modpath_static" >> $modpath_current/modules.mk
149   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
150   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
151     MODULE_DIRS="$MODULE_DIRS $current_dir"
152   else
153     MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
154   fi
155   APACHE_FAST_OUTPUT($modpath_current/Makefile)
156 ])dnl
157 dnl
158 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
159 AC_DEFUN(APACHE_MODPATH_ADD,[
160   if test -z "$3"; then
161     objects="mod_$1.lo"
162   else
163     objects="$3"
164   fi
165
166   if test -z "$module_standalone"; then
167     if test -z "$2"; then
168       libname="mod_$1.la"
169       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
170       modpath_static="$modpath_static $libname"
171       cat >>$modpath_current/modules.mk<<EOF
172 $libname: $objects
173         \$(MOD_LINK) $objects
174 EOF
175     else
176       apache_need_shared=yes
177       libname="mod_$1.la"
178       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
179       modpath_shared="$modpath_shared $libname"
180       cat >>$modpath_current/modules.mk<<EOF
181 $libname: $shobjects
182         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
183 EOF
184     fi
185   fi
186 ])dnl
187
188 dnl
189 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
190 dnl
191 dnl default is one of:
192 dnl   yes    -- enabled by default. user must explicitly disable.
193 dnl   no     -- disabled under default, most, all. user must explicitly enable.
194 dnl   most   -- disabled by default. enabled explicitly or with most or all.
195 dnl   static -- enabled as static by default, must be explicitly changed.
196 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
197 dnl
198 dnl basically: yes/no is a hard setting. "most" means follow the "most"
199 dnl            setting. otherwise, fall under the "all" setting.
200 dnl            explicit yes/no always overrides.
201 dnl
202 AC_DEFUN(APACHE_MODULE,[
203   AC_MSG_CHECKING(whether to enable mod_$1)
204   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
205   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
206   undefine([optname])dnl
207   _apmod_extra_msg=""
208   dnl When --enable-modules=most is set and the module was not explicitly
209   dnl requested, allow a module to disable itself if its pre-reqs fail.
210   if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
211     _apmod_error_fatal="no"
212   else
213     _apmod_error_fatal="yes"
214   fi
215   if test "$enable_$1" = "static"; then
216     enable_$1=yes
217   elif test "$enable_$1" = "yes"; then
218     enable_$1=$module_default
219     _apmod_extra_msg=" ($module_selection)"
220   elif test "$enable_$1" = "most"; then
221     if test "$module_selection" = "most" -o "$module_selection" = "all"; then
222       enable_$1=$module_default
223       _apmod_extra_msg=" ($module_selection)"
224     elif test "$enable_$1" != "yes"; then
225       enable_$1=no
226     fi
227   elif test "$enable_$1" = "maybe-all"; then
228     if test "$module_selection" = "all"; then
229       enable_$1=$module_default
230       _apmod_extra_msg=" (all)"
231     else
232       enable_$1=no
233     fi
234   fi
235   if test "$enable_$1" != "no"; then
236     dnl If we plan to enable it, allow the module to run some autoconf magic
237     dnl that may disable it because of missing dependencies.
238     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
239                     $6
240                     AC_MSG_CHECKING(whether to enable mod_$1)
241                     if test "$enable_$1" = "no"; then
242                       if test "$_apmod_error_fatal" = "no"; then
243                         _apmod_extra_msg=" (disabled)"
244                       else
245                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
246                       fi
247                     fi])
248   fi
249   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
250   if test "$enable_$1" != "no"; then
251     case "$enable_$1" in
252     shared*)
253       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
254       sharedobjs=yes
255       shared=yes
256       DSO_MODULES="$DSO_MODULES $1"
257       ;;
258     *)
259       MODLIST="$MODLIST ifelse($4,,$1,$4)"
260       if test "$1" = "so"; then
261           sharedobjs=yes
262       fi
263       shared="";;
264     esac
265     APACHE_MODPATH_ADD($1, $shared, $3)
266   fi
267 ])dnl
268
269 dnl
270 dnl APACHE_LAYOUT(configlayout, layoutname)
271 dnl
272 AC_DEFUN(APACHE_LAYOUT,[
273   if test ! -f $srcdir/config.layout; then
274     echo "** Error: Layout file $srcdir/config.layout not found"
275     echo "** Error: Cannot use undefined layout '$LAYOUT'"
276     exit 1
277   fi
278   pldconf=./config.pld
279   changequote({,})
280   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
281       -e '/[    ]*<\/Layout>[   ]*/,$d' \
282       -e "s/^[  ]*//g" \
283       -e "s/:[  ]*/=\'/g" \
284       -e "s/[   ]*$/'/g" \
285       $1 > $pldconf
286   layout_name=$2
287   . $pldconf
288   rm $pldconf
289   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
290              sysconfdir datadir errordir iconsdir htdocsdir cgidir \
291              includedir localstatedir runtimedir logfiledir libdir \
292              manualdir proxycachedir installbuilddir; do
293     eval "val=\"\$$var\""
294     case $val in
295       *+)
296         val=`echo $val | sed -e 's;\+$;;'`
297         eval "$var=\"\$val\""
298         autosuffix=yes
299         ;;
300       *)
301         autosuffix=no
302         ;;
303     esac
304     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
305     val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
306     if test "$autosuffix" = "yes"; then
307       if echo $val | grep apache >/dev/null; then
308         addtarget=no
309       else
310         addtarget=yes
311       fi
312       if test "$addtarget" = "yes"; then
313         val="$val/apache2"
314       fi
315     fi
316     eval "$var='$val'"
317   done
318   changequote([,])
319 ])dnl
320
321 dnl
322 dnl APACHE_ENABLE_LAYOUT
323 dnl
324 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
325 AC_ARG_ENABLE(layout,
326 [  --enable-layout=LAYOUT],[
327   LAYOUT=$enableval
328 ])
329
330 if test -z "$LAYOUT"; then
331   LAYOUT="Apache"
332 fi
333 APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
334
335 AC_MSG_CHECKING(for chosen layout)
336 AC_MSG_RESULT($layout_name)
337 ])
338
339 dnl
340 dnl APACHE_ENABLE_MODULES
341 dnl
342 AC_DEFUN(APACHE_ENABLE_MODULES,[
343   module_selection=default
344   module_default=yes
345
346   AC_ARG_ENABLE(modules,
347   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
348     for i in $enableval; do
349       if test "$i" = "all" -o "$i" = "most"; then
350         module_selection=$i
351       else
352         eval "enable_$i=yes"
353       fi
354     done
355   ])
356   
357   AC_ARG_ENABLE(mods-shared,
358   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
359     for i in $enableval; do
360       if test "$i" = "all" -o "$i" = "most"; then
361         module_selection=$i
362         module_default=shared
363       else
364         i=`echo $i | sed 's/-/_/g'`
365         eval "enable_$i=shared"
366       fi
367     done
368   ])
369 ])
370
371 AC_DEFUN(APACHE_REQUIRE_CXX,[
372   if test -z "$apache_cxx_done"; then
373     AC_PROG_CXX
374     AC_PROG_CXXCPP
375     apache_cxx_done=yes
376   fi
377 ])
378
379 dnl
380 dnl APACHE_CHECK_SSL_TOOLKIT
381 dnl
382 dnl Find the openssl toolkit installation and check it for the right
383 dnl version, then add its flags to INCLUDES and LIBS.  This should
384 dnl really be using a custom AC_TRY_COMPILE function to test the includes
385 dnl and then AC_TRY_LINK to test the libraries directly for the version,
386 dnl but that will require someone who knows how to program openssl.
387 dnl
388 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
389 if test "x$ap_ssltk_base" = "x"; then
390   AC_MSG_CHECKING(for SSL/TLS toolkit base)
391   ap_ssltk_base=""
392   AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
393     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
394       ap_ssltk_base="$withval"
395       if test -f "$ap_ssltk_base/bin/openssl"; then
396           ap_ssltk_version="`$ap_ssltk_base/bin/openssl version`"
397       else
398           ap_ssltk_version="unknown"
399       fi
400     fi
401   ])
402   if test "x$ap_ssltk_base" = "x"; then
403     AC_CACHE_VAL(ap_cv_ssltk,[
404       #
405       # shotgun approach: find all occurrences of the openssl program
406       #
407       # The IFS=... trick eliminates the colons from $PATH, without using an external program
408       for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
409         if test -f "$p/openssl"; then
410           ap_ssltk_version="`$p/openssl version`"
411           if test "x$ap_ssltk_version" != "x"; then
412             ap_cv_ssltk="`(cd $p/.. && pwd)`"
413             break
414           fi
415         fi
416       done
417       if test "x$ap_cv_ssltk" = "x"; then
418         AC_MSG_ERROR([requires OpenSSL 0.9.6e or higher])
419       fi
420     ])
421     ap_ssltk_base="$ap_cv_ssltk"
422   fi
423   if test ! -d $ap_ssltk_base; then
424     AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
425   fi
426   AC_MSG_RESULT($ap_ssltk_base)
427     
428   AC_MSG_CHECKING(for SSL/TLS toolkit version)
429   AC_MSG_RESULT($ap_ssltk_version)
430   case "$ap_ssltk_version" in
431     "OpenSSL "[[1-9]]* | \
432     "OpenSSL "0.9.6[[e-z]]* | \
433     "OpenSSL "0.9.[[7-9]]* | \
434     "OpenSSL "0.[[1-9]][[0-9]]* )
435        # okay versions that do not have known security holes
436        ;;
437     "OpenSSL"*)
438        AC_MSG_WARN([OpenSSL versions prior to 0.9.6e have known security holes])
439        ;;
440     *)
441        # unknown version -- assume the user knows what they are doing
442        ;;
443   esac
444     
445   AC_MSG_CHECKING(for SSL/TLS toolkit includes)
446   ap_ssltk_incdir=""
447   for p in $ap_ssltk_base/include /usr/local/openssl/include \
448            /usr/local/ssl/include /usr/local/include /usr/include; do
449     if test -f "$p/openssl/ssl.h"; then
450       ap_ssltk_incdir="$p"
451       break
452     elif test -f "$p/ssl.h"; then
453       ap_ssltk_incdir="$p"
454       break
455     fi
456   done
457   if test "x$ap_ssltk_incdir" = "x"; then
458     AC_MSG_ERROR([OpenSSL headers not found])
459   fi
460   AC_MSG_RESULT($ap_ssltk_incdir)
461
462   AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
463   ap_ssltk_libdir=""
464   for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
465            /usr/local/ssl/lib /usr/local/lib /usr/lib /lib /usr/lib64; do
466     if test -f "$p/libssl.a" -o -f "$p/libssl.so" -o -f "$p/libssl.dylib"; then
467       ap_ssltk_libdir="$p"
468       break
469     fi
470   done
471   if test ".$ap_ssltk_libdir" = .; then
472     AC_MSG_ERROR([OpenSSL libraries not found])
473   fi
474   AC_MSG_RESULT($ap_ssltk_libdir)
475
476   dnl #  annotate the Apache build environment with determined information
477   APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
478   if test "x$ap_ssltk_incdir" != "x/usr/include"; then
479     APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
480   fi
481   if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
482     APR_ADDTO(LDFLAGS, [-L$ap_ssltk_libdir])
483     if test "x$ap_platform_runtime_link_flag" != "x"; then
484       APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
485     fi
486   fi
487   APR_ADDTO(LIBS, [-lssl -lcrypto])
488   ap_cv_ssltk="$ap_ssltk_base"
489 fi
490 ])
491
492 dnl
493 dnl APACHE_EXPORT_ARGUMENTS
494 dnl Export (via APACHE_SUBST) the various path-related variables that
495 dnl apache will use while generating scripts like autoconf and apxs and
496 dnl the default config file.
497
498 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
499   APR_EXPAND_VAR(exp_$1, [$]$1)
500   APACHE_SUBST(exp_$1)
501   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
502   APACHE_SUBST(rel_$1)
503 ])
504
505 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
506   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
507   APACHE_SUBST_EXPANDED_ARG(bindir)
508   APACHE_SUBST_EXPANDED_ARG(sbindir)
509   APACHE_SUBST_EXPANDED_ARG(libdir)
510   APACHE_SUBST_EXPANDED_ARG(libexecdir)
511   APACHE_SUBST_EXPANDED_ARG(mandir)
512   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
513   APACHE_SUBST_EXPANDED_ARG(datadir)
514   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
515   APACHE_SUBST_EXPANDED_ARG(errordir)
516   APACHE_SUBST_EXPANDED_ARG(iconsdir)
517   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
518   APACHE_SUBST_EXPANDED_ARG(manualdir)
519   APACHE_SUBST_EXPANDED_ARG(cgidir)
520   APACHE_SUBST_EXPANDED_ARG(includedir)
521   APACHE_SUBST_EXPANDED_ARG(localstatedir)
522   APACHE_SUBST_EXPANDED_ARG(runtimedir)
523   APACHE_SUBST_EXPANDED_ARG(logfiledir)
524   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
525 ])
526