bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / build / apr_common.m4
1 dnl -----------------------------------------------------------------
2 dnl apr_common.m4: APR's general-purpose autoconf macros
3 dnl
4
5 dnl APR_CONFIG_NICE(filename)
6 dnl
7 dnl Saves a snapshot of the configure command-line for later reuse
8 dnl
9 AC_DEFUN(APR_CONFIG_NICE,[
10   rm -f $1
11   cat >$1<<EOF
12 #! /bin/sh
13 #
14 # Created by configure
15
16 EOF
17   if test -n "$CC"; then
18     echo "CC=\"$CC\"; export CC" >> $1
19   fi
20   if test -n "$CFLAGS"; then
21     echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1
22   fi
23   if test -n "$CPPFLAGS"; then
24     echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1
25   fi
26   if test -n "$LDFLAGS"; then
27     echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1
28   fi
29   if test -n "$LIBS"; then
30     echo "LIBS=\"$LIBS\"; export LIBS" >> $1
31   fi
32   if test -n "$INCLUDES"; then
33     echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1
34   fi
35   if test -n "$NOTEST_CFLAGS"; then
36     echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1
37   fi
38   if test -n "$NOTEST_CPPFLAGS"; then
39     echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1
40   fi
41   if test -n "$NOTEST_LDFLAGS"; then
42     echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1
43   fi
44   if test -n "$NOTEST_LIBS"; then
45     echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1
46   fi
47
48   # Retrieve command-line arguments.
49   eval "set x $[0] $ac_configure_args"
50   shift
51
52   for arg
53   do
54     APR_EXPAND_VAR(arg, $arg)
55     echo "\"[$]arg\" \\" >> $1
56   done
57   echo '"[$]@"' >> $1
58   chmod +x $1
59 ])dnl
60
61 dnl APR_MKDIR_P_CHECK(fallback-mkdir-p)
62 dnl checks whether mkdir -p works
63 AC_DEFUN(APR_MKDIR_P_CHECK,[
64   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
65     test -d conftestdir && rm -rf conftestdir
66     mkdir -p conftestdir/somedir >/dev/null 2>&1
67     if test -d conftestdir/somedir; then
68       ac_cv_mkdir_p=yes
69     else
70       ac_cv_mkdir_p=no
71     fi
72     rm -rf conftestdir
73   ])
74   if test "$ac_cv_mkdir_p" = "yes"; then
75       mkdir_p="mkdir -p"
76   else
77       mkdir_p="$1"
78   fi
79 ])
80
81 dnl
82 dnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args, args-to-drop])
83 dnl
84 dnl dir: directory to find configure in
85 dnl sub-package-cmdline-args: arguments to add to the invocation (optional)
86 dnl args-to-drop: arguments to drop from the invocation (optional)
87 dnl
88 dnl Note: This macro relies on ac_configure_args being set properly.
89 dnl
90 dnl The args-to-drop argument is shoved into a case statement, so
91 dnl multiple arguments can be separated with a |.
92 dnl
93 dnl Note: Older versions of autoconf do not single-quote args, while 2.54+
94 dnl places quotes around every argument.  So, if you want to drop the
95 dnl argument called --enable-layout, you must pass the third argument as:
96 dnl [--enable-layout=*|\'--enable-layout=*]
97 dnl
98 dnl Trying to optimize this is left as an exercise to the reader who wants
99 dnl to put up with more autoconf craziness.  I give up.
100 dnl
101 AC_DEFUN(APR_SUBDIR_CONFIG, [
102   # save our work to this point; this allows the sub-package to use it
103   AC_CACHE_SAVE
104
105   echo "configuring package in $1 now"
106   ac_popdir=`pwd`
107   apr_config_subdirs="$1"
108   test -d $1 || $mkdir_p $1
109   ac_abs_srcdir=`(cd $srcdir/$1 && pwd)`
110   cd $1
111
112 changequote(, )dnl
113       # A "../" for each directory in /$config_subdirs.
114       ac_dots=`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`
115 changequote([, ])dnl
116
117   # Make the cache file pathname absolute for the subdirs
118   # required to correctly handle subdirs that might actually
119   # be symlinks
120   case "$cache_file" in
121   /*) # already absolute
122     ac_sub_cache_file=$cache_file ;;
123   *)  # Was relative path.
124     ac_sub_cache_file="$ac_popdir/$cache_file" ;;
125   esac
126
127   ifelse($3, [], [apr_configure_args=$ac_configure_args],[
128   apr_configure_args=
129   apr_sep=
130   for apr_configure_arg in $ac_configure_args
131   do
132     case "$apr_configure_arg" in
133       $3)
134         continue ;;
135     esac
136     apr_configure_args="$apr_configure_args$apr_sep'$apr_configure_arg'"
137     apr_sep=" "
138   done
139   ])
140
141   dnl autoconf doesn't add --silent to ac_configure_args; explicitly pass it
142   test "x$silent" = "xyes" && apr_configure_args="$apr_configure_args --silent"
143
144   dnl AC_CONFIG_SUBDIRS silences option warnings, emulate this for 2.62
145   apr_configure_args="--disable-option-checking $apr_configure_args" 
146
147   dnl The eval makes quoting arguments work - specifically $2 where the
148   dnl quoting mechanisms used is "" rather than [].
149   dnl
150   dnl We need to execute another shell because some autoconf/shell combinations
151   dnl will choke after doing repeated APR_SUBDIR_CONFIG()s.  (Namely Solaris
152   dnl and autoconf-2.54+)
153   if eval $SHELL $ac_abs_srcdir/configure $apr_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2
154   then :
155     echo "$1 configured properly"
156   else
157     echo "configure failed for $1"
158     exit 1
159   fi
160
161   cd $ac_popdir
162
163   # grab any updates from the sub-package
164   AC_CACHE_LOAD
165 ])dnl
166
167 dnl
168 dnl APR_SAVE_THE_ENVIRONMENT(variable_name)
169 dnl
170 dnl Stores the variable (usually a Makefile macro) for later restoration
171 dnl
172 AC_DEFUN(APR_SAVE_THE_ENVIRONMENT,[
173   apr_ste_save_$1="$$1"
174 ])dnl
175
176 dnl
177 dnl APR_RESTORE_THE_ENVIRONMENT(variable_name, prefix_)
178 dnl
179 dnl Uses the previously saved variable content to figure out what configure
180 dnl has added to the variable, moving the new bits to prefix_variable_name
181 dnl and restoring the original variable contents.  This makes it possible
182 dnl for a user to override configure when it does something stupid.
183 dnl
184 AC_DEFUN(APR_RESTORE_THE_ENVIRONMENT,[
185 if test "x$apr_ste_save_$1" = "x"; then
186   $2$1="$$1"
187   $1=
188 else
189   if test "x$apr_ste_save_$1" = "x$$1"; then
190     $2$1=
191   else
192     $2$1=`echo $$1 | sed -e "s%${apr_ste_save_$1}%%"`
193     $1="$apr_ste_save_$1"
194   fi
195 fi
196 echo "  restoring $1 to \"$$1\""
197 echo "  setting $2$1 to \"$$2$1\""
198 AC_SUBST($2$1)
199 ])dnl
200
201 dnl
202 dnl APR_SETIFNULL(variable, value)
203 dnl
204 dnl  Set variable iff it's currently null
205 dnl
206 AC_DEFUN(APR_SETIFNULL,[
207   if test -z "$$1"; then
208     echo "  setting $1 to \"$2\""
209     $1="$2"
210   fi
211 ])dnl
212
213 dnl
214 dnl APR_SETVAR(variable, value)
215 dnl
216 dnl  Set variable no matter what
217 dnl
218 AC_DEFUN(APR_SETVAR,[
219   echo "  forcing $1 to \"$2\""
220   $1="$2"
221 ])dnl
222
223 dnl
224 dnl APR_ADDTO(variable, value)
225 dnl
226 dnl  Add value to variable
227 dnl
228 AC_DEFUN(APR_ADDTO,[
229   if test "x$$1" = "x"; then
230     echo "  setting $1 to \"$2\""
231     $1="$2"
232   else
233     apr_addto_bugger="$2"
234     for i in $apr_addto_bugger; do
235       apr_addto_duplicate="0"
236       for j in $$1; do
237         if test "x$i" = "x$j"; then
238           apr_addto_duplicate="1"
239           break
240         fi
241       done
242       if test $apr_addto_duplicate = "0"; then
243         echo "  adding \"$i\" to $1"
244         $1="$$1 $i"
245       fi
246     done
247   fi
248 ])dnl
249
250 dnl
251 dnl APR_REMOVEFROM(variable, value)
252 dnl
253 dnl Remove a value from a variable
254 dnl
255 AC_DEFUN(APR_REMOVEFROM,[
256   if test "x$$1" = "x$2"; then
257     echo "  nulling $1"
258     $1=""
259   else
260     apr_new_bugger=""
261     apr_removed=0
262     for i in $$1; do
263       if test "x$i" != "x$2"; then
264         apr_new_bugger="$apr_new_bugger $i"
265       else
266         apr_removed=1
267       fi
268     done
269     if test $apr_removed = "1"; then
270       echo "  removed \"$2\" from $1"
271       $1=$apr_new_bugger
272     fi
273   fi
274 ]) dnl
275
276 dnl
277 dnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] )
278 dnl
279 AC_DEFUN(APR_CHECK_DEFINE_FILES,[
280   AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
281     ac_cv_define_$1=no
282     for curhdr in $2
283     do
284       AC_EGREP_CPP(YES_IS_DEFINED, [
285 #include <$curhdr>
286 #ifdef $1
287 YES_IS_DEFINED
288 #endif
289       ], ac_cv_define_$1=yes)
290     done
291   ])
292   if test "$ac_cv_define_$1" = "yes"; then
293     AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined])
294   fi
295 ])
296
297
298 dnl
299 dnl APR_CHECK_DEFINE(symbol, header_file)
300 dnl
301 AC_DEFUN(APR_CHECK_DEFINE,[
302   AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
303     AC_EGREP_CPP(YES_IS_DEFINED, [
304 #include <$2>
305 #ifdef $1
306 YES_IS_DEFINED
307 #endif
308     ], ac_cv_define_$1=yes, ac_cv_define_$1=no)
309   ])
310   if test "$ac_cv_define_$1" = "yes"; then
311     AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2])
312   fi
313 ])
314
315 dnl
316 dnl APR_CHECK_APR_DEFINE( symbol )
317 dnl
318 AC_DEFUN(APR_CHECK_APR_DEFINE,[
319 apr_old_cppflags=$CPPFLAGS
320 CPPFLAGS="$CPPFLAGS $INCLUDES"
321 AC_EGREP_CPP(YES_IS_DEFINED, [
322 #include <apr.h>
323 #if $1
324 YES_IS_DEFINED
325 #endif
326 ], ac_cv_define_$1=yes, ac_cv_define_$1=no)
327 CPPFLAGS=$apr_old_cppflags
328 ])
329
330 dnl APR_CHECK_FILE(filename); set ac_cv_file_filename to
331 dnl "yes" if 'filename' is readable, else "no".
332 dnl @deprecated! - use AC_CHECK_FILE instead
333 AC_DEFUN([APR_CHECK_FILE], [
334 dnl Pick a safe variable name
335 define([apr_cvname], ac_cv_file_[]translit([$1], [./+-], [__p_]))
336 AC_CACHE_CHECK([for $1], [apr_cvname],
337 [if test -r $1; then
338    apr_cvname=yes
339  else
340    apr_cvname=no
341  fi])
342 ])
343
344 define(APR_IFALLYES,[dnl
345 ac_rc=yes
346 for ac_spec in $1; do
347     ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'`
348     ac_item=`echo "$ac_spec" | sed -e 's/^.*://'`
349     case $ac_type in
350         header )
351             ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
352             ac_var="ac_cv_header_$ac_item"
353             ;;
354         file )
355             ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
356             ac_var="ac_cv_file_$ac_item"
357             ;;
358         func )   ac_var="ac_cv_func_$ac_item"   ;;
359         struct ) ac_var="ac_cv_struct_$ac_item" ;;
360         define ) ac_var="ac_cv_define_$ac_item" ;;
361         custom ) ac_var="$ac_item" ;;
362     esac
363     eval "ac_val=\$$ac_var"
364     if test ".$ac_val" != .yes; then
365         ac_rc=no
366         break
367     fi
368 done
369 if test ".$ac_rc" = .yes; then
370     :
371     $2
372 else
373     :
374     $3
375 fi
376 ])
377
378
379 define(APR_BEGIN_DECISION,[dnl
380 ac_decision_item='$1'
381 ac_decision_msg='FAILED'
382 ac_decision=''
383 ])
384
385
386 define(APR_DECIDE,[dnl
387 ac_decision='$1'
388 ac_decision_msg='$2'
389 ac_decision_$1=yes
390 ac_decision_$1_msg='$2'
391 ])
392
393
394 define(APR_DECISION_OVERRIDE,[dnl
395     ac_decision=''
396     for ac_item in $1; do
397          eval "ac_decision_this=\$ac_decision_${ac_item}"
398          if test ".$ac_decision_this" = .yes; then
399              ac_decision=$ac_item
400              eval "ac_decision_msg=\$ac_decision_${ac_item}_msg"
401          fi
402     done
403 ])
404
405
406 define(APR_DECISION_FORCE,[dnl
407 ac_decision="$1"
408 eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\""
409 ])
410
411
412 define(APR_END_DECISION,[dnl
413 if test ".$ac_decision" = .; then
414     echo "[$]0:Error: decision on $ac_decision_item failed" 1>&2
415     exit 1
416 else
417     if test ".$ac_decision_msg" = .; then
418         ac_decision_msg="$ac_decision"
419     fi
420     AC_DEFINE_UNQUOTED(${ac_decision_item})
421     AC_MSG_RESULT([decision on $ac_decision_item... $ac_decision_msg])
422 fi
423 ])
424
425
426 dnl
427 dnl APR_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
428 dnl
429 dnl A variant of AC_CHECK_SIZEOF which allows the checking of
430 dnl sizes of non-builtin types
431 dnl
432 AC_DEFUN(APR_CHECK_SIZEOF_EXTENDED,
433 [changequote(<<,>>)dnl
434 dnl The name to #define
435 define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
436 dnl The cache variable
437 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *],[<p>]))dnl
438 changequote([, ])dnl
439 AC_MSG_CHECKING(size of $2)
440 AC_CACHE_VAL(AC_CV_NAME,
441 [AC_TRY_RUN([#include <stdio.h>
442 $1
443 main()
444 {
445   FILE *f=fopen("conftestval","w");
446   if (!f) exit(1);
447   fprintf(f, "%d\n", sizeof($2));
448   exit(0);
449 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
450 AC_CV_NAME=$3))])dnl
451 AC_MSG_RESULT($AC_CV_NAME)
452 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2)
453 undefine([AC_TYPE_NAME])dnl
454 undefine([AC_CV_NAME])dnl
455 ])
456
457
458 dnl
459 dnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY,
460 dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
461 dnl
462 dnl Tries a compile test with warnings activated so that the result
463 dnl is false if the code doesn't compile cleanly.
464 dnl
465 AC_DEFUN(APR_TRY_COMPILE_NO_WARNING,
466 [if test "x$CFLAGS_WARN" = "x"; then
467   apr_tcnw_flags=""
468 else
469   apr_tcnw_flags=$CFLAGS_WARN
470 fi
471 if test "$ac_cv_prog_gcc" = "yes"; then 
472   apr_tcnw_flags="$apr_tcnw_flags -Werror"
473 fi
474 changequote(', ')
475 cat > conftest.$ac_ext <<EOTEST
476 #include "confdefs.h"
477 '$1'
478 int main(int argc, const char * const *argv) {
479 '$2'
480 ; return 0; }
481 EOTEST
482 changequote([, ])
483 if ${CC-cc} -c $CFLAGS $CPPFLAGS $apr_tcnw_flags conftest.$ac_ext 2>&AC_FD_CC ; then
484   ifelse([$3], , :, [rm -rf conftest*
485   $3])
486 else
487   echo "configure: failed or warning program:" >&AC_FD_CC
488   cat conftest.$ac_ext >&AC_FD_CC
489   ifelse([$4], , , [rm -rf conftest*
490   $4])
491 fi
492 rm -f conftest*
493 ])dnl
494
495 dnl
496 dnl APR_CHECK_STRERROR_R_RC
497 dnl
498 dnl  Decide which style of retcode is used by this system's 
499 dnl  strerror_r().  It either returns int (0 for success, -1
500 dnl  for failure), or it returns a pointer to the error 
501 dnl  string.
502 dnl
503 dnl
504 AC_DEFUN(APR_CHECK_STRERROR_R_RC,[
505 AC_MSG_CHECKING(for type of return code from strerror_r)
506 AC_TRY_RUN([
507 #include <errno.h>
508 #include <string.h>
509 #include <stdio.h>
510 main()
511 {
512   char buf[1024];
513   if (strerror_r(ERANGE, buf, sizeof buf) < 1) {
514     exit(0);
515   }
516   else {
517     exit(1);
518   }
519 }], [
520     ac_cv_strerror_r_rc_int=yes ], [
521     ac_cv_strerror_r_rc_int=no ], [
522     ac_cv_strerror_r_rc_int=no ] )
523 if test "x$ac_cv_strerror_r_rc_int" = xyes; then
524   AC_DEFINE(STRERROR_R_RC_INT, 1, [Define if strerror returns int])
525   msg="int"
526 else
527   msg="pointer"
528 fi
529 AC_MSG_RESULT([$msg])
530 ] )
531 dnl
532 dnl APR_CHECK_CRYPT_R_STYLE
533 dnl
534 dnl  Decide which of a couple of flavors of crypt_r() is necessary for
535 dnl  this platform.
536 dnl
537 AC_DEFUN(APR_CHECK_CRYPT_R_STYLE,[
538 AC_CACHE_CHECK(style of crypt_r, ac_cv_crypt_r_style,[
539 dnl
540 ac_cv_crypt_r_style=none
541 dnl
542 AC_TRY_COMPILE([
543 #include <crypt.h>
544 ],[
545 CRYPTD buffer;
546 crypt_r("passwd", "hash", &buffer);
547 ], ac_cv_crypt_r_style=cryptd)
548 dnl
549 if test "$ac_cv_crypt_r_style" = "none"; then
550 AC_TRY_COMPILE([
551 #include <crypt.h>
552 ],[
553 struct crypt_data buffer;
554 crypt_r("passwd", "hash", &buffer);
555 ], ac_cv_crypt_r_style=struct_crypt_data)
556 fi
557 dnl
558 ])
559 if test "$ac_cv_crypt_r_style" = "cryptd"; then
560     AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
561 fi
562 # if we don't combine these conditions, CRYPT_R_STRUCT_CRYPT_DATA
563 # will end up defined twice
564 if test "$ac_cv_crypt_r_style" = "struct_crypt_data"; then
565     AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
566 fi
567 ])
568
569 dnl
570 dnl APR_CHECK_DIRENT_INODE
571 dnl
572 dnl  Decide if d_fileno or d_ino are available in the dirent
573 dnl  structure on this platform.  Single UNIX Spec says d_ino,
574 dnl  BSD uses d_fileno.  Undef to find the real beast.
575 dnl
576 AC_DEFUN(APR_CHECK_DIRENT_INODE, [
577 AC_CACHE_CHECK([for inode member of struct dirent], apr_cv_dirent_inode, [
578 apr_cv_dirent_inode=no
579 AC_TRY_COMPILE([
580 #include <sys/types.h>
581 #include <dirent.h>
582 ],[
583 #ifdef d_ino
584 #undef d_ino
585 #endif
586 struct dirent de; de.d_fileno;
587 ], apr_cv_dirent_inode=d_fileno)
588 if test "$apr_cv_dirent_inode" = "no"; then
589 AC_TRY_COMPILE([
590 #include <sys/types.h>
591 #include <dirent.h>
592 ],[
593 #ifdef d_fileno
594 #undef d_fileno
595 #endif
596 struct dirent de; de.d_ino;
597 ], apr_cv_dirent_inode=d_ino)
598 fi
599 ])
600 if test "$apr_cv_dirent_inode" != "no"; then
601   AC_DEFINE_UNQUOTED(DIRENT_INODE, $apr_cv_dirent_inode)
602 fi
603 ])
604
605 dnl
606 dnl APR_CHECK_DIRENT_TYPE
607 dnl
608 dnl  Decide if d_type is available in the dirent structure 
609 dnl  on this platform.  Not part of the Single UNIX Spec.
610 dnl  Note that this is worthless without DT_xxx macros, so
611 dnl  look for one while we are at it.
612 dnl
613 AC_DEFUN(APR_CHECK_DIRENT_TYPE,[
614 AC_CACHE_CHECK([for file type member of struct dirent], apr_cv_dirent_type,[
615 apr_cv_dirent_type=no
616 AC_TRY_COMPILE([
617 #include <sys/types.h>
618 #include <dirent.h>
619 ],[
620 struct dirent de; de.d_type = DT_REG;
621 ], apr_cv_dirent_type=d_type)
622 ])
623 if test "$apr_cv_dirent_type" != "no"; then
624   AC_DEFINE_UNQUOTED(DIRENT_TYPE, $apr_cv_dirent_type) 
625 fi
626 ])
627
628 dnl the following is a newline, a space, a tab, and a backslash (the
629 dnl backslash is used by the shell to skip newlines, but m4 sees it;
630 dnl treat it like whitespace).
631 dnl WARNING: don't reindent these lines, or the space/tab will be lost!
632 define([apr_whitespace],[
633         \])
634
635 dnl
636 dnl APR_COMMA_ARGS(ARG1 ...)
637 dnl  convert the whitespace-separated arguments into comman-separated
638 dnl  arguments.
639 dnl
640 dnl APR_FOREACH(CODE-BLOCK, ARG1, ARG2, ...)
641 dnl  subsitute CODE-BLOCK for each ARG[i]. "eachval" will be set to ARG[i]
642 dnl  within each iteration.
643 dnl
644 changequote({,})
645 define({APR_COMMA_ARGS},{patsubst([$}{1],[[}apr_whitespace{]+],[,])})
646 define({APR_FOREACH},
647   {ifelse($}{2,,,
648           [define([eachval],
649                   $}{2)$}{1[]APR_FOREACH([$}{1],
650                                          builtin([shift],
651                                                  builtin([shift], $}{@)))])})
652 changequote([,])
653
654 dnl APR_FLAG_HEADERS(HEADER-FILE ... [, FLAG-TO-SET ] [, "yes" ])
655 dnl  we set FLAG-TO-SET to 1 if we find HEADER-FILE, otherwise we set to 0
656 dnl  if FLAG-TO-SET is null, we automagically determine it's name
657 dnl  by changing all "/" to "_" in the HEADER-FILE and dropping
658 dnl  all "." and "-" chars. If the 3rd parameter is "yes" then instead of
659 dnl  setting to 1 or 0, we set FLAG-TO-SET to yes or no.
660 dnl  
661 AC_DEFUN(APR_FLAG_HEADERS,[
662 AC_CHECK_HEADERS($1)
663 for aprt_i in $1
664 do
665     ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'`
666     aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'`
667     if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
668        eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,yes,1)"
669     else
670        eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,no,0)"
671     fi
672 done
673 ])
674
675 dnl APR_FLAG_FUNCS(FUNC ... [, FLAG-TO-SET] [, "yes" ])
676 dnl  if FLAG-TO-SET is null, we automagically determine it's name
677 dnl  prepending "have_" to the function name in FUNC, otherwise
678 dnl  we use what's provided as FLAG-TO-SET. If the 3rd parameter
679 dnl  is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SET
680 dnl  to yes or no.
681 dnl
682 AC_DEFUN(APR_FLAG_FUNCS,[
683 AC_CHECK_FUNCS($1)
684 for aprt_j in $1
685 do
686     aprt_3="have_$aprt_j"
687     if eval "test \"`echo '$ac_cv_func_'$aprt_j`\" = yes"; then
688        eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,yes,1)"
689     else
690        eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,no,0)"
691     fi
692 done
693 ])
694
695 dnl Iteratively interpolate the contents of the second argument
696 dnl until interpolation offers no new result. Then assign the
697 dnl final result to $1.
698 dnl
699 dnl Example:
700 dnl
701 dnl foo=1
702 dnl bar='${foo}/2'
703 dnl baz='${bar}/3'
704 dnl APR_EXPAND_VAR(fraz, $baz)
705 dnl   $fraz is now "1/2/3"
706 dnl 
707 AC_DEFUN(APR_EXPAND_VAR,[
708 ap_last=
709 ap_cur="$2"
710 while test "x${ap_cur}" != "x${ap_last}";
711 do
712   ap_last="${ap_cur}"
713   ap_cur=`eval "echo ${ap_cur}"`
714 done
715 $1="${ap_cur}"
716 ])
717
718 dnl
719 dnl Removes the value of $3 from the string in $2, strips of any leading
720 dnl slashes, and returns the value in $1.
721 dnl
722 dnl Example:
723 dnl orig_path="${prefix}/bar"
724 dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix)
725 dnl    $final_path now contains "bar"
726 AC_DEFUN(APR_PATH_RELATIVE,[
727 ap_stripped=`echo $2 | sed -e "s#^$3##"`
728 # check if the stripping was successful
729 if test "x$2" != "x${ap_stripped}"; then
730     # it was, so strip of any leading slashes
731     $1="`echo ${ap_stripped} | sed -e 's#^/*##'`"
732 else
733     # it wasn't so return the original
734     $1="$2"
735 fi
736 ])
737
738 dnl APR_HELP_STRING(LHS, RHS)
739 dnl Autoconf 2.50 can not handle substr correctly.  It does have 
740 dnl AC_HELP_STRING, so let's try to call it if we can.
741 dnl Note: this define must be on one line so that it can be properly returned
742 dnl as the help string.  When using this macro with a multi-line RHS, ensure
743 dnl that you surround the macro invocation with []s
744 AC_DEFUN(APR_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[  ][$1] substr([                       ],len($1))[$2])])
745
746 dnl
747 dnl APR_LAYOUT(configlayout, layoutname [, extravars])
748 dnl
749 AC_DEFUN(APR_LAYOUT,[
750   if test ! -f $srcdir/config.layout; then
751     echo "** Error: Layout file $srcdir/config.layout not found"
752     echo "** Error: Cannot use undefined layout '$LAYOUT'"
753     exit 1
754   fi
755   pldconf=./config.pld
756   changequote({,})
757   sed -e "1s/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*//;1t" \
758       -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
759       -e '/[    ]*<\/Layout>[   ]*/,$d' \
760       -e "s/^[  ]*//g" \
761       -e "s/:[  ]*/=\'/g" \
762       -e "s/[   ]*$/'/g" \
763       $1 > $pldconf
764   layout_name=$2
765   if test ! -s $pldconf; then
766     echo "** Error: unable to find layout $layout_name"
767     exit 1
768   fi
769   . $pldconf
770   rm $pldconf
771   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
772              sysconfdir datadir includedir localstatedir runtimedir \
773              logfiledir libdir installbuilddir libsuffix $3; do
774     eval "val=\"\$$var\""
775     case $val in
776       *+)
777         val=`echo $val | sed -e 's;\+$;;'`
778         eval "$var=\"\$val\""
779         autosuffix=yes
780         ;;
781       *)
782         autosuffix=no
783         ;;
784     esac
785     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
786     val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
787     if test "$autosuffix" = "yes"; then
788       if echo $val | grep apache >/dev/null; then
789         addtarget=no
790       else
791         addtarget=yes
792       fi
793       if test "$addtarget" = "yes"; then
794         val="$val/apache2"
795       fi
796     fi
797     eval "$var='$val'"
798   done
799   changequote([,])
800 ])dnl
801
802 dnl
803 dnl APR_ENABLE_LAYOUT(default layout name [, extra vars])
804 dnl
805 AC_DEFUN(APR_ENABLE_LAYOUT,[
806 AC_ARG_ENABLE(layout,
807 [  --enable-layout=LAYOUT],[
808   LAYOUT=$enableval
809 ])
810
811 if test -z "$LAYOUT"; then
812   LAYOUT="$1"
813 fi
814 APR_LAYOUT($srcdir/config.layout, $LAYOUT, $2)
815
816 AC_MSG_CHECKING(for chosen layout)
817 AC_MSG_RESULT($layout_name)
818 ])
819
820
821 dnl
822 dnl APR_PARSE_ARGUMENTS
823 dnl a reimplementation of autoconf's argument parser,
824 dnl used here to allow us to co-exist layouts and argument based
825 dnl set ups.
826 AC_DEFUN(APR_PARSE_ARGUMENTS,[
827 ac_prev=
828 # Retrieve the command-line arguments.  The eval is needed because
829 # the arguments are quoted to preserve accuracy.
830 eval "set x $ac_configure_args"
831 shift
832 for ac_option
833 do
834   # If the previous option needs an argument, assign it.
835   if test -n "$ac_prev"; then
836     eval "$ac_prev=\$ac_option"
837     ac_prev=
838     continue
839   fi
840
841   ac_optarg=`expr "x$ac_option" : 'x[[^=]]*=\(.*\)'`
842
843   case $ac_option in
844
845   -bindir | --bindir | --bindi | --bind | --bin | --bi)
846     ac_prev=bindir ;;
847   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
848     bindir="$ac_optarg" ;;
849
850   -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
851     ac_prev=datadir ;;
852   -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
853   | --da=*)
854     datadir="$ac_optarg" ;;
855
856   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
857   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
858   | --exec | --exe | --ex)
859     ac_prev=exec_prefix ;;
860   -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
861   | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
862   | --exec=* | --exe=* | --ex=*)
863     exec_prefix="$ac_optarg" ;;
864
865   -includedir | --includedir | --includedi | --included | --include \
866   | --includ | --inclu | --incl | --inc)
867     ac_prev=includedir ;;
868   -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
869   | --includ=* | --inclu=* | --incl=* | --inc=*)
870     includedir="$ac_optarg" ;;
871
872   -infodir | --infodir | --infodi | --infod | --info | --inf)
873     ac_prev=infodir ;;
874   -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
875     infodir="$ac_optarg" ;;
876
877   -libdir | --libdir | --libdi | --libd)
878     ac_prev=libdir ;;
879   -libdir=* | --libdir=* | --libdi=* | --libd=*)
880     libdir="$ac_optarg" ;;
881
882   -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
883   | --libexe | --libex | --libe)
884     ac_prev=libexecdir ;;
885   -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
886   | --libexe=* | --libex=* | --libe=*)
887     libexecdir="$ac_optarg" ;;
888
889   -localstatedir | --localstatedir | --localstatedi | --localstated \
890   | --localstate | --localstat | --localsta | --localst \
891   | --locals | --local | --loca | --loc | --lo)
892     ac_prev=localstatedir ;;
893   -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
894   | --localstate=* | --localstat=* | --localsta=* | --localst=* \
895   | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
896     localstatedir="$ac_optarg" ;;
897
898   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
899     ac_prev=mandir ;;
900   -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
901     mandir="$ac_optarg" ;;
902
903   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
904     ac_prev=prefix ;;
905   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
906     prefix="$ac_optarg" ;;
907
908   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
909     ac_prev=sbindir ;;
910   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
911   | --sbi=* | --sb=*)
912     sbindir="$ac_optarg" ;;
913
914   -sharedstatedir | --sharedstatedir | --sharedstatedi \
915   | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
916   | --sharedst | --shareds | --shared | --share | --shar \
917   | --sha | --sh)
918     ac_prev=sharedstatedir ;;
919   -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
920   | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
921   | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
922   | --sha=* | --sh=*)
923     sharedstatedir="$ac_optarg" ;;
924
925   -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
926   | --syscon | --sysco | --sysc | --sys | --sy)
927     ac_prev=sysconfdir ;;
928   -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
929   | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
930     sysconfdir="$ac_optarg" ;;
931
932   esac
933 done
934
935 # Be sure to have absolute paths.
936 for ac_var in exec_prefix prefix
937 do
938   eval ac_val=$`echo $ac_var`
939   case $ac_val in
940     [[\\/$]]* | ?:[[\\/]]* | NONE | '' ) ;;
941     *)  AC_MSG_ERROR([expected an absolute path for --$ac_var: $ac_val]);;
942   esac
943 done
944
945 ])dnl
946
947 dnl
948 dnl APR_CHECK_DEPEND
949 dnl
950 dnl Determine what program we can use to generate .deps-style dependencies
951 dnl
952 AC_DEFUN(APR_CHECK_DEPEND,[
953 dnl Try to determine what depend program we can use
954 dnl All GCC-variants should have -MM.
955 dnl If not, then we can check on those, too.
956 if test "$GCC" = "yes"; then
957   MKDEP='$(CC) -MM'
958 else
959   rm -f conftest.c
960 dnl <sys/types.h> should be available everywhere!
961   cat > conftest.c <<EOF
962 #include <sys/types.h>
963   int main() { return 0; }
964 EOF
965   MKDEP="true"
966   for i in "$CC -MM" "$CC -M" "$CPP -MM" "$CPP -M" "cpp -M"; do
967     AC_MSG_CHECKING([if $i can create proper make dependencies])
968     if $i conftest.c 2>/dev/null | grep 'conftest.o: conftest.c' >/dev/null; then
969       MKDEP=$i
970       AC_MSG_RESULT(yes)
971       break;
972     fi
973     AC_MSG_RESULT(no)
974   done
975   rm -f conftest.c
976 fi
977
978 AC_SUBST(MKDEP)
979 ])
980
981 dnl
982 dnl APR_CHECK_TYPES_COMPATIBLE(TYPE-1, TYPE-2, [ACTION-IF-TRUE])
983 dnl
984 dnl Try to determine whether two types are the same. Only works
985 dnl for gcc and icc.
986 dnl
987 AC_DEFUN([APR_CHECK_TYPES_COMPATIBLE], [
988 define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_]))
989 AC_CACHE_CHECK([whether $1 and $2 are the same], apr_cvname, [
990 AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [
991     int foo[0 - !__builtin_types_compatible_p($1, $2)];
992 ], [apr_cvname=yes $3], [apr_cvname=no])])
993 ])