~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to build/apr_common.m4

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

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