📄 apr_common.m4
字号:
dnl -----------------------------------------------------------------dnl apr_common.m4: APR's general-purpose autoconf macrosdnldnl APR_CONFIG_NICE(filename)dnldnl Saves a snapshot of the configure command-line for later reusednlAC_DEFUN(APR_CONFIG_NICE,[ rm -f $1 cat >$1<<EOF#! /bin/sh## Created by configureEOF if test -n "$CC"; then echo "CC=\"$CC\"; export CC" >> $1 fi if test -n "$CFLAGS"; then echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1 fi if test -n "$CPPFLAGS"; then echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1 fi if test -n "$LDFLAGS"; then echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1 fi if test -n "$LIBS"; then echo "LIBS=\"$LIBS\"; export LIBS" >> $1 fi if test -n "$INCLUDES"; then echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1 fi if test -n "$NOTEST_CFLAGS"; then echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1 fi if test -n "$NOTEST_CPPFLAGS"; then echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1 fi if test -n "$NOTEST_LDFLAGS"; then echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1 fi if test -n "$NOTEST_LIBS"; then echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1 fi for arg in [$]0 "[$]@"; do APR_EXPAND_VAR(arg, $arg) echo "\"[$]arg\" \\" >> $1 done echo '"[$]@"' >> $1 chmod +x $1])dnldnl APR_MKDIR_P_CHECK(fallback-mkdir-p)dnl checks whether mkdir -p worksAC_DEFUN(APR_MKDIR_P_CHECK,[ AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[ test -d conftestdir && rm -rf conftestdir mkdir -p conftestdir/somedir >/dev/null 2>&1 if test -d conftestdir/somedir; then ac_cv_mkdir_p=yes else ac_cv_mkdir_p=no fi rm -rf conftestdir ]) if test "$ac_cv_mkdir_p" = "yes"; then mkdir_p="mkdir -p" else mkdir_p="$1" fi])dnldnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args, args-to-drop])dnldnl dir: directory to find configure indnl sub-package-cmdline-args: arguments to add to the invocation (optional)dnl args-to-drop: arguments to drop from the invocation (optional)dnldnl Note: This macro relies on ac_configure_args being set properly.dnldnl The args-to-drop argument is shoved into a case statement, sodnl multiple arguments can be separated with a |.dnldnl Note: Older versions of autoconf do not single-quote args, while 2.54+dnl places quotes around every argument. So, if you want to drop thednl argument called --enable-layout, you must pass the third argument as:dnl [--enable-layout=*|\'--enable-layout=*]dnldnl Trying to optimize this is left as an exercise to the reader who wantsdnl to put up with more autoconf craziness. I give up.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` apr_config_subdirs="$1" test -d $1 || $mkdir_p $1 ac_abs_srcdir=`(cd $srcdir/$1 && pwd)` 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 pathname absolute for the subdirs # required to correctly handle subdirs that might actually # be symlinks case "$cache_file" in /*) # already absolute ac_sub_cache_file=$cache_file ;; *) # Was relative path. ac_sub_cache_file="$ac_popdir/$cache_file" ;; esac ifelse($3, [], [apr_configure_args=$ac_configure_args],[ apr_configure_args= apr_sep= for apr_configure_arg in $ac_configure_args do case "$apr_configure_arg" in $3) continue ;; esac apr_configure_args="$apr_configure_args$apr_sep'$apr_configure_arg'" apr_sep=" " done ]) dnl The eval makes quoting arguments work - specifically $2 where the dnl quoting mechanisms used is "" rather than []. dnl dnl We need to execute another shell because some autoconf/shell combinations dnl will choke after doing repeated APR_SUBDIR_CONFIG()s. (Namely Solaris dnl and autoconf-2.54+) if eval $SHELL $ac_abs_srcdir/configure $apr_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_SAVE_THE_ENVIRONMENT(variable_name)dnldnl Stores the variable (usually a Makefile macro) for later restorationdnlAC_DEFUN(APR_SAVE_THE_ENVIRONMENT,[ apr_ste_save_$1="$$1"])dnldnldnl APR_RESTORE_THE_ENVIRONMENT(variable_name, prefix_)dnldnl Uses the previously saved variable content to figure out what configurednl has added to the variable, moving the new bits to prefix_variable_namednl and restoring the original variable contents. This makes it possiblednl for a user to override configure when it does something stupid.dnlAC_DEFUN(APR_RESTORE_THE_ENVIRONMENT,[if test "x$apr_ste_save_$1" = "x"; then $2$1="$$1" $1=else if test "x$apr_ste_save_$1" = "x$$1"; then $2$1= else $2$1=`echo $$1 | sed -e "s%${apr_ste_save_$1}%%"` $1="$apr_ste_save_$1" fifiecho " restoring $1 to \"$$1\""echo " setting $2$1 to \"$$2$1\""AC_SUBST($2$1)])dnldnldnl 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" fi])dnldnldnl APR_SETVAR(variable, value)dnldnl Set variable no matter whatdnlAC_DEFUN(APR_SETVAR,[ echo " forcing $1 to \"$2\"" $1="$2"])dnldnldnl APR_ADDTO(variable, value)dnldnl Add value to variablednlAC_DEFUN(APR_ADDTO,[ if test "x$$1" = "x"; then echo " setting $1 to \"$2\"" $1="$2" else apr_addto_bugger="$2" for i in $apr_addto_bugger; do apr_addto_duplicate="0" for j in $$1; do if test "x$i" = "x$j"; then apr_addto_duplicate="1" break fi done if test $apr_addto_duplicate = "0"; then echo " adding \"$i\" to $1" $1="$$1 $i" fi done fi])dnldnldnl APR_REMOVEFROM(variable, value)dnldnl Remove a value from a variablednlAC_DEFUN(APR_REMOVEFROM,[ if test "x$$1" = "x$2"; then echo " nulling $1" $1="" else apr_new_bugger="" apr_removed=0 for i in $$1; do if test "x$i" != "x$2"; then apr_new_bugger="$apr_new_bugger $i" else apr_removed=1 fi done if test $apr_removed = "1"; then echo " removed \"$2\" from $1" $1=$apr_new_bugger fi fi]) dnldnldnl 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 $1YES_IS_DEFINED#endif ], ac_cv_define_$1=yes) done ]) if test "$ac_cv_define_$1" = "yes"; then AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined]) 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 $1YES_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, 1, [Define if $1 is defined in $2]) fi])dnldnl APR_CHECK_APR_DEFINE( symbol )dnlAC_DEFUN(APR_CHECK_APR_DEFINE,[apr_old_cppflags=$CPPFLAGSCPPFLAGS="$CPPFLAGS $INCLUDES"AC_EGREP_CPP(YES_IS_DEFINED, [#include <apr.h>#if $1YES_IS_DEFINED#endif], ac_cv_define_$1=yes, ac_cv_define_$1=no)CPPFLAGS=$apr_old_cppflags])dnl APR_CHECK_FILE(filename); set ac_cv_file_filename todnl "yes" if 'filename' is readable, else "no".AC_DEFUN([APR_CHECK_FILE], [dnl Pick a safe variable namedefine([apr_cvname], ac_cv_file_[]translit([$1], [./+-], [__p_]))AC_CACHE_CHECK([for $1], [apr_cvname],[if test -r $1; then apr_cvname=yes else apr_cvname=no 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" ;; struct ) ac_var="ac_cv_struct_$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, [The size of ]$2)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 "$ac_cv_prog_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_STRERROR_R_RCdnldnl Decide which style of retcode is used by this system's dnl strerror_r(). It either returns int (0 for success, -1dnl for failure), or it returns a pointer to the error dnl string.dnl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -