source: trunk/m4/apr_common.m4 @ 2724

Last change on this file since 2724 was 2724, checked in by Peter, 7 years ago

set svncopyright:ignore property

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