⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m4sh.m4

📁 autoconf是一个产生可以自动配置源代码包
💻 M4
📖 第 1 页 / 共 3 页
字号:
# Set VAR to DIR-NAME/FILE-NAME.# Optimize the common case where $2 or $3 is '.'.m4_define([AS_SET_CATFILE],[case $2 in.) $1=$3;;*)  case $3 in  .) $1=$2;;  [[\\/]]* | ?:[[\\/]]* ) $1=$3;;  *) $1=$2/$3;;  esac;;esac[]dnl])# AS_SET_CATFILE# _AS_TEST_PREPARE# ----------------# Find out ahead of time whether ``test -x'' can be used to distinguish# executables from other regular files.# FIXME: This should use "test -x /"; that's much faster.m4_defun([_AS_TEST_PREPARE],[# Find out whether ``test -x'' works.  Don't use a zero-byte file, as# systems may use methods other than mode bits to determine executability.cat >conf$$.file <<_ASEOF#! /bin/shexit 0_ASEOFchmod +x conf$$.fileif test -x conf$$.file >/dev/null 2>&1; then  as_executable_p="test -x"else  as_executable_p=:firm -f conf$$.file])# _AS_TEST_PREPARE## ------------------ #### 5. Common idioms.  #### ------------------ ### This section is lexicographically sorted.# AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])# ----------------------------------------# Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which# must not be `/').m4_define([AS_BOX],[AS_LITERAL_IF([$1],	       [_AS_BOX_LITERAL($@)],	       [_AS_BOX_INDIR($@)])])# _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])# -------------------------------------------------m4_define([_AS_BOX_LITERAL],[cat <<\_ASBOXm4_text_box($@)_ASBOX])# _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])# -----------------------------------------------m4_define([_AS_BOX_INDIR],[sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX@%:@@%:@ $1 @%:@@%:@_ASBOX])# AS_HELP_STRING(LHS, RHS, [COLUMN])# ----------------------------------## Format a help string so that it looks pretty when# the user executes "script --help".  This macro takes three# arguments, a "left hand side" (LHS), a "right hand side" (RHS), and# the COLUMN which is a string of white spaces which leads to the# the RHS column (default: 26 white spaces).## The resulting string is suitable for use in other macros that require# a help string (e.g. AC_ARG_WITH).## Here is the sample string from the Autoconf manual (Node: External# Software) which shows the proper spacing for help strings.##    --with-readline         support fancy command line editing#  ^ ^                       ^#  | |                       |#  | column 2                column 26#  |#  column 0## A help string is made up of a "left hand side" (LHS) and a "right# hand side" (RHS).  In the example above, the LHS is# "--with-readline", while the RHS is "support fancy command line# editing".## If the LHS contains more than (COLUMN - 3) characters, then the LHS is# terminated with a newline so that the RHS starts on a line of its own# beginning with COLUMN.  In the default case, this corresponds to an# LHS with more than 23 characters.## Therefore, in the example, if the LHS were instead# "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would# expand into:###    --with-readline-blah-blah-blah#  ^ ^                       support fancy command line editing#  | |                       ^#  | column 2                |#  column 0                  column 26### m4_text_wrap hacks^Wworks around the fact that m4_format does not# know quadrigraphs.#m4_define([AS_HELP_STRING],[m4_pushdef([AS_Prefix], m4_default([$3], [                          ]))dnlm4_pushdef([AS_Prefix_Format],	   [  %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [  %-23s ]m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnlm4_popdef([AS_Prefix_Format])dnlm4_popdef([AS_Prefix])dnl])# AS_HELP_STRING# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)# -----------------------------------------------------# If EXPRESSION has shell indirections ($var or `expr`), expand# IF-INDIR, else IF-NOT-INDIR.# This is an *approximation*: for instance EXPRESSION = `\$' is# definitely a literal, but will not be recognized as such.m4_define([AS_LITERAL_IF],[m4_bmatch([$1], [[`$]],	   [$3], [$2])])# AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])# -------------------------------------------------# Create as safely as possible a temporary directory in DIRECTORY# which name is inspired by PREFIX (should be 2-4 chars max).m4_define([AS_TMPDIR],[# Create a (secure) tmp directory for tmp files.m4_if([$2], [], [: ${TMPDIR=/tmp}]){  tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&  test -n "$tmp" && test -d "$tmp"}  ||{  tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM  (umask 077 && mkdir "$tmp")} ||{   echo "$me: cannot create a temporary directory in m4_default([$2], [$TMPDIR])" >&2   AS_EXIT}dnl])# AS_TMPDIR# AS_UNAME# --------# Try to describe this machine.  Meant for logs.m4_define([AS_UNAME],[{cat <<_ASUNAMEm4_text_box([Platform.])hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`uname -m = `(uname -m) 2>/dev/null || echo unknown`uname -r = `(uname -r) 2>/dev/null || echo unknown`uname -s = `(uname -s) 2>/dev/null || echo unknown`uname -v = `(uname -v) 2>/dev/null || echo unknown`/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`_ASUNAME_AS_PATH_WALK([$PATH], [echo "PATH: $as_dir"])}])# _AS_VERSION_COMPARE_PREPARE# ---------------------------# Output variables for comparing version numbers.m4_defun([_AS_VERSION_COMPARE_PREPARE],[[as_awk_strverscmp='  # Use only awk features that work with 7th edition Unix awk (1978).  # My, what an old awk you have, Mr. Solaris!  END {    while (length(v1) && length(v2)) {      # Set d1 to be the next thing to compare from v1, and likewise for d2.      # Normally this is a single character, but if v1 and v2 contain digits,      # compare them as integers and fractions as strverscmp does.      if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {	# Split v1 and v2 into their leading digit string components d1 and d2,	# and advance v1 and v2 past the leading digit strings.	for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue	for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue	d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)	d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)	if (d1 ~ /^0/) {	  if (d2 ~ /^0/) {	    # Compare two fractions.	    while (d1 ~ /^0/ && d2 ~ /^0/) {	      d1 = substr(d1, 2); len1--	      d2 = substr(d2, 2); len2--	    }	    if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {	      # The two components differ in length, and the common prefix	      # contains only leading zeros.  Consider the longer to be less.	      d1 = -len1	      d2 = -len2	    } else {	      # Otherwise, compare as strings.	      d1 = "x" d1	      d2 = "x" d2	    }	  } else {	    # A fraction is less than an integer.	    exit 1	  }	} else {	  if (d2 ~ /^0/) {	    # An integer is greater than a fraction.	    exit 2	  } else {	    # Compare two integers.	    d1 += 0	    d2 += 0	  }	}      } else {	# The normal case, without worrying about digits.	d1 = substr(v1, 1, 1); v1 = substr(v1, 2)	d2 = substr(v2, 1, 1); v2 = substr(v2, 2)      }      if (d1 < d2) exit 1      if (d1 > d2) exit 2    }    # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),    # which mishandles some comparisons of empty strings to integers.    if (length(v2)) exit 1    if (length(v1)) exit 2  }']])# _AS_VERSION_COMPARE_PREPARE# AS_VERSION_COMPARE(VERSION-1, VERSION-2,#                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])# -----------------------------------------------------------------------------# Compare two strings possibly containing shell variables as version strings.m4_defun([AS_VERSION_COMPARE],[AS_REQUIRE([_$0_PREPARE])dnlas_arg_v1=$1as_arg_v2=$2dnl This usage is portable even to ancient awk,dnl so don't worry about finding a "nice" awk version.awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/nullcase $? in1) $3;;0) $4;;2) $5;;esac[]dnl])# _AS_VERSION_COMPARE## ------------------------------------ #### Common m4/sh character translation.  #### ------------------------------------ ### The point of this section is to provide high level macros comparable# to m4's `translit' primitive, but m4/sh polymorphic.# Transliteration of literal strings should be handled by m4, while# shell variables' content will be translated at runtime (tr or sed).# _AS_CR_PREPARE# --------------# Output variables defining common character ranges.# See m4_cr_letters etc.m4_defun([_AS_CR_PREPARE],[# Avoid depending upon Character Ranges.as_cr_letters='abcdefghijklmnopqrstuvwxyz'as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'as_cr_Letters=$as_cr_letters$as_cr_LETTERSas_cr_digits='0123456789'as_cr_alnum=$as_cr_Letters$as_cr_digits])# _AS_TR_SH_PREPARE# -----------------m4_defun([_AS_TR_SH_PREPARE],[AS_REQUIRE([_AS_CR_PREPARE])dnl# Sed expression to map a string onto a valid variable name.as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"])# AS_TR_SH(EXPRESSION)# --------------------# Transform EXPRESSION into a valid shell variable name.# sh/m4 polymorphic.# Be sure to update the definition of `$as_tr_sh' if you change this.m4_defun([AS_TR_SH],[AS_REQUIRE([_$0_PREPARE])dnlAS_LITERAL_IF([$1],	      [m4_bpatsubst(m4_translit([[$1]], [*+], [pp]),			    [[^a-zA-Z0-9_]], [_])],	      [`echo "$1" | $as_tr_sh`])])# _AS_TR_CPP_PREPARE# ------------------m4_defun([_AS_TR_CPP_PREPARE],[AS_REQUIRE([_AS_CR_PREPARE])dnl# Sed expression to map a string onto a valid CPP name.as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"])# AS_TR_CPP(EXPRESSION)# ---------------------# Map EXPRESSION to an upper case string which is valid as rhs for a# `#define'.  sh/m4 polymorphic.  Be sure to update the definition# of `$as_tr_cpp' if you change this.m4_defun([AS_TR_CPP],[AS_REQUIRE([_$0_PREPARE])dnlAS_LITERAL_IF([$1],	      [m4_bpatsubst(m4_translit([[$1]],					[*abcdefghijklmnopqrstuvwxyz],					[PABCDEFGHIJKLMNOPQRSTUVWXYZ]),			   [[^A-Z0-9_]], [_])],	      [`echo "$1" | $as_tr_cpp`])])# _AS_TR_PREPARE# --------------m4_defun([_AS_TR_PREPARE],[AS_REQUIRE([_AS_TR_SH_PREPARE])dnlAS_REQUIRE([_AS_TR_CPP_PREPARE])dnl])## --------------------------------------------------- #### Common m4/sh handling of variables (indirections).  #### --------------------------------------------------- ### The purpose of this section is to provide a uniform API for# reading/setting sh variables with or without indirection.# Typically, one can write#   AS_VAR_SET(var, val)# or#   AS_VAR_SET(as_$var, val)# and expect the right thing to happen.# AS_VAR_SET(VARIABLE, VALUE)# ---------------------------# Set the VALUE of the shell VARIABLE.# If the variable contains indirections (e.g. `ac_cv_func_$ac_func')# perform whenever possible at m4 level, otherwise sh level.m4_define([AS_VAR_SET],[AS_LITERAL_IF([$1],	       [$1=$2],	       [eval "$1=AS_ESCAPE([$2])"])])# AS_VAR_GET(VARIABLE)# --------------------# Get the value of the shell VARIABLE.# Evaluates to $VARIABLE if there are no indirection in VARIABLE,# else into the appropriate `eval' sequence.# FIXME: This mishandles values that end in newlines, or have backslashes,# or are '-n'.  Fixing this will require changing the API.m4_define([AS_VAR_GET],[AS_LITERAL_IF([$1],	       [$$1],	       [`eval echo '${'m4_bpatsubst($1, [[\\`]], [\\\&])'}'`])])# AS_VAR_TEST_SET(VARIABLE)# -------------------------# Expands into the `test' expression which is true if VARIABLE# is set.  Polymorphic.  Should be dnl'ed.m4_define([AS_VAR_TEST_SET],[AS_LITERAL_IF([$1],	       [test "${$1+set}" = set],	       [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])# AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)# ------------------------------------------# Implement a shell `if-then-else' depending whether VARIABLE is set# or not.  Polymorphic.m4_define([AS_VAR_SET_IF],[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])# AS_VAR_PUSHDEF and AS_VAR_POPDEF# --------------------------------## Sometimes we may have to handle literals (e.g. `stdlib.h'), while at# other moments, the same code may have to get the value from a# variable (e.g., `ac_header').  To have a uniform handling of both# cases, when a new value is about to be processed, declare a local# variable, e.g.:##   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])## and then in the body of the macro, use `header' as is.  It is of# first importance to use `AS_VAR_*' to access this variable.  Don't# quote its name: it must be used right away by m4.## If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is# in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,# then `header's value in m4 is in fact `$ac_header', the shell# variable that holds all of the magic to get the expansion right.## At the end of the block, free the variable with##   AS_VAR_POPDEF([header])# AS_VAR_PUSHDEF(VARNAME, VALUE)# ------------------------------# Define the m4 macro VARNAME to an accessor to the shell variable# named VALUE.  VALUE does not need to be a valid shell variable name:# the transliteration is handled here.  To be dnl'ed.m4_define([AS_VAR_PUSHDEF],[AS_LITERAL_IF([$2],	       [m4_pushdef([$1], [AS_TR_SH($2)])],	       [as_$1=AS_TR_SH($2)m4_pushdef([$1], [$as_[$1]])])])# AS_VAR_POPDEF(VARNAME)# ----------------------# Free the shell variable accessor VARNAME.  To be dnl'ed.m4_define([AS_VAR_POPDEF],[m4_popdef([$1])])## ----------------- #### Setting M4sh up.  #### ----------------- ### _AS_SHELL_FN_SPY# ----------------# This temporary macro checks "in the wild" for shells that do# not support shell functions.m4_define([_AS_SHELL_FN_SPY],[_AS_DETECT_SUGGESTED([_AS_SHELL_FN_WORK])_AS_RUN([_AS_SHELL_FN_WORK]) || {  echo No shell found that supports shell functions.  echo Please tell autoconf@gnu.org about your system,  echo including any error possibly output before this  echo message}])# AS_INIT# -------# Initialize m4sh.m4_define([AS_INIT],[m4_init# Forbidden tokens and exceptions.m4_pattern_forbid([^_?AS_])# Bangshe and minimal initialization.m4_divert_text([BINSH], [@%:@! /bin/sh])m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])AS_REQUIRE([_AS_SHELL_FN_SPY])# Let's go!m4_divert_pop([KILL])[]dnlm4_divert_push([BODY])[]dnl])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -