📄 apr_common.m4
字号:
dnl -----------------------------------------------------------------dnl apr_common.m4: APR's general-purpose autoconf macrosdnldnldnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args])dnlAC_DEFUN(APR_SUBDIR_CONFIG, [ # save our work to this point; this allows the sub-package to use it AC_CACHE_SAVE echo "configuring package in $1 now" ac_popdir=`pwd` ac_abs_srcdir=`(cd $srcdir/$1 && pwd)` apr_config_subdirs="$1" test -d $1 || $MKDIR $1 cd $1changequote(, )dnl # A "../" for each directory in /$config_subdirs. ac_dots=`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`changequote([, ])dnl # Make the cache file name correct relative to the subdirectory. case "$cache_file" in /*) ac_sub_cache_file=$cache_file ;; *) # Relative path. ac_sub_cache_file="$ac_dots$cache_file" ;; esac # The eval makes quoting arguments work. if eval $ac_abs_srcdir/configure $ac_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2 then : echo "$1 configured properly" else echo "configure failed for $1" exit 1 fi cd $ac_popdir # grab any updates from the sub-package AC_CACHE_LOAD])dnldnldnl APR_DOEXTRAdnldnl Handle the use of EXTRA_* variables.dnl Basically, EXTRA_* vars are added to thednl current settings of their "parents". Wednl can expand as needed for additionaldnl EXTRA_* variables by adding them to thednl "for i in..." line.dnldnl To handle recursive configures, the 1st timednl through we need to null out EXTRA_* and thendnl export the lot of them, since we want/needdnl them to exist in the sub-configures' environment.dnl The nasty eval's allow us to use the 'for'dnl construct and save some lines of code.dnlAC_DEFUN(APR_DOEXTRA, [ for i in CFLAGS LDFLAGS LIBS do eval APR_TMP=\$EXTRA_$i if test -n "$APR_TMP"; then eval $i=\"\$$i $APR_TMP\" eval export $i eval unset EXTRA_${i} eval export EXTRA_${i} fi done])dnldnl APR_SETIFNULL(variable, value)dnldnl Set variable iff it's currently nulldnlAC_DEFUN(APR_SETIFNULL,[ if test -z "$$1"; then echo " Setting $1 to \"$2\"" $1="$2"; export $1 fi])dnldnl APR_SETVAR(variable, value)dnldnl Set variable no matter whatdnlAC_DEFUN(APR_SETVAR,[ echo " Forcing $1 to \"$2\"" $1="$2"; export $1])dnldnl APR_ADDTO(variable, value)dnldnl Add value to variablednlAC_DEFUN(APR_ADDTO,[ echo " Adding \"$2\" to $1" $1="$$1 $2"; export $1])dnldnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] )dnlAC_DEFUN(APR_CHECK_DEFINE_FILES,[ AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ ac_cv_define_$1=no for curhdr in $2 do AC_EGREP_CPP(YES_IS_DEFINED, [ #include <$curhdr> #ifdef $1 YES_IS_DEFINED #endif ], ac_cv_define_$1=yes) done ]) if test "$ac_cv_define_$1" = "yes"; then AC_DEFINE(HAVE_$1) fi])dnldnl APR_CHECK_DEFINE( symbol, header_file )dnlAC_DEFUN(APR_CHECK_DEFINE,[ AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[ AC_EGREP_CPP(YES_IS_DEFINED, [ #include <$2> #ifdef $1 YES_IS_DEFINED #endif ], ac_cv_define_$1=yes, ac_cv_define_$1=no) ]) if test "$ac_cv_define_$1" = "yes"; then AC_DEFINE(HAVE_$1) fi])define(APR_IFALLYES,[dnlac_rc=yesfor ac_spec in $1; do ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'` ac_item=`echo "$ac_spec" | sed -e 's/^.*://'` case $ac_type in header ) ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` ac_var="ac_cv_header_$ac_item" ;; file ) ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'` ac_var="ac_cv_file_$ac_item" ;; func ) ac_var="ac_cv_func_$ac_item" ;; define ) ac_var="ac_cv_define_$ac_item" ;; custom ) ac_var="$ac_item" ;; esac eval "ac_val=\$$ac_var" if test ".$ac_val" != .yes; then ac_rc=no break fidoneif test ".$ac_rc" = .yes; then : $2else : $3fi])define(APR_BEGIN_DECISION,[dnlac_decision_item='$1'ac_decision_msg='FAILED'ac_decision=''])define(APR_DECIDE,[dnlac_decision='$1'ac_decision_msg='$2'ac_decision_$1=yesac_decision_$1_msg='$2'])define(APR_DECISION_OVERRIDE,[dnl ac_decision='' for ac_item in $1; do eval "ac_decision_this=\$ac_decision_${ac_item}" if test ".$ac_decision_this" = .yes; then ac_decision=$ac_item eval "ac_decision_msg=\$ac_decision_${ac_item}_msg" fi done])define(APR_DECISION_FORCE,[dnlac_decision="$1"eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\""])define(APR_END_DECISION,[dnlif test ".$ac_decision" = .; then echo "[$]0:Error: decision on $ac_decision_item failed" 1>&2 exit 1else if test ".$ac_decision_msg" = .; then ac_decision_msg="$ac_decision" fi AC_DEFINE_UNQUOTED(${ac_decision_item}) AC_MSG_RESULT([decision on $ac_decision_item... $ac_decision_msg])fi])dnldnl APR_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])dnldnl A variant of AC_CHECK_SIZEOF which allows the checking ofdnl sizes of non-builtin typesdnlAC_DEFUN(APR_CHECK_SIZEOF_EXTENDED,[changequote(<<,>>)dnldnl The name to #definedefine(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnldnl The cache variabledefine(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *],[<p>]))dnlchangequote([, ])dnlAC_MSG_CHECKING(size of $2)AC_CACHE_VAL(AC_CV_NAME,[AC_TRY_RUN([#include <stdio.h>$1main(){ FILE *f=fopen("conftestval","w"); if (!f) exit(1); fprintf(f, "%d\n", sizeof($2)); exit(0);}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,AC_CV_NAME=$3))])dnlAC_MSG_RESULT($AC_CV_NAME)AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)undefine([AC_TYPE_NAME])dnlundefine([AC_CV_NAME])dnl])dnldnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY,dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])dnldnl Tries a compile test with warnings activated so that the resultdnl is false if the code doesn't compile cleanly.dnlAC_DEFUN(APR_TRY_COMPILE_NO_WARNING,[if test "x$CFLAGS_WARN" = "x"; then apr_tcnw_flags=""else apr_tcnw_flags=$CFLAGS_WARNfiif test "$GCC" = "yes"; then apr_tcnw_flags="$apr_tcnw_flags -Werror"fichangequote(', ')cat > conftest.$ac_ext <<EOTEST#include "confdefs.h"'$1'int main(int argc, const char * const argv[]) {'$2'; return 0; }EOTESTchangequote([, ])if ${CC-cc} -c $CFLAGS $CPPFLAGS $apr_tcnw_flags conftest.$ac_ext 2>&AC_FD_CC ; then ifelse([$3], , :, [rm -rf conftest* $3])else echo "configure: failed or warning program:" >&AC_FD_CC cat conftest.$ac_ext >&AC_FD_CC ifelse([$4], , , [rm -rf conftest* $4])firm -f conftest*])dnldnldnl APR_CHECK_ICONV_INBUFdnldnl Decide whether or not the inbuf parameter to iconv() is const.dnldnl We try to compile something without const. If it fails to dnl compile, we assume that the system's iconv() has const. dnl Unfortunately, we won't realize when there was a compilednl warning, so we allow a variable -- apr_iconv_inbuf_const -- todnl be set in hints.m4 to specify whether or not iconv() has constdnl on this parameter.dnlAC_DEFUN(APR_CHECK_ICONV_INBUF,[AC_MSG_CHECKING(for type of inbuf parameter to iconv)if test "x$apr_iconv_inbuf_const" = "x"; then APR_TRY_COMPILE_NO_WARNING([ #include <stddef.h> #include <iconv.h> ],[ iconv(0,(char **)0,(size_t *)0,(char **)0,(size_t *)0); ], apr_iconv_inbuf_const="0", apr_iconv_inbuf_const="1")fiif test "$apr_iconv_inbuf_const" = "1"; then AC_DEFINE(APR_ICONV_INBUF_CONST, 1, [Define if the inbuf parm to iconv() is const char **]) msg="const char **"else msg="char **"fiAC_MSG_RESULT([$msg])])dnldnl the following is a newline, a space, a tab, and a backslash (thednl backslash is used by the shell to skip newlines, but m4 sees it;dnl treat it like whitespace).dnl WARNING: don't reindent these lines, or the space/tab will be lost!define([apr_whitespace],[ \])dnldnl APR_COMMA_ARGS(ARG1 ...)dnl convert the whitespace-separated arguments into comman-separateddnl arguments.dnldnl APR_FOREACH(CODE-BLOCK, ARG1, ARG2, ...)dnl subsitute CODE-BLOCK for each ARG[i]. "eachval" will be set to ARG[i]dnl within each iteration.dnlchangequote({,})define({APR_COMMA_ARGS},{patsubst([$}{1],[[}apr_whitespace{]+],[,])})define({APR_FOREACH}, {ifelse($}{2,,, [define([eachval], $}{2)$}{1[]APR_FOREACH([$}{1], builtin([shift], builtin([shift], $}{@)))])})changequote([,])dnl APR_FLAG_HEADERS(HEADER-FILE ... [, FLAG-TO-SET ] [, "yes" ])dnl we set FLAG-TO-SET to 1 if we find HEADER-FILE, otherwise we set to 0dnl if FLAG-TO-SET is null, we automagically determine it's namednl by changing all "/" to "_" in the HEADER-FILE and droppingdnl all "." chars. If the 3rd parameter is "yes" then instead ofdnl setting to 1 or 0, we set FLAG-TO-SET to yes or no.dnl AC_DEFUN(APR_FLAG_HEADERS,[AC_CHECK_HEADERS($1)for aprt_i in $1do ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'` aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g'` if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,yes,1)" else eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,no,0)" fidone])dnl APR_FLAG_FUNCS(FUNC ... [, FLAG-TO-SET] [, "yes" ])dnl if FLAG-TO-SET is null, we automagically determine it's namednl prepending "have_" to the function name in FUNC, otherwisednl we use what's provided as FLAG-TO-SET. If the 3rd parameterdnl is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SETdnl to yes or no.dnlAC_DEFUN(APR_FLAG_FUNCS,[AC_CHECK_FUNCS($1)for aprt_j in $1do aprt_3="have_$aprt_j" if eval "test \"`echo '$ac_cv_func_'$aprt_j`\" = yes"; then eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,yes,1)" else eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,no,0)" fidone])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -