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