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