📄 iffe
字号:
USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-author?Phong Vo <kpv@research.att.com>][-copyright?Copyright (c) 1994-2005 AT&T Corp.][-license?http://www.opensource.org/licenses/cpl1.0.txt][--catalog?INIT]"# Glenn Fowler & Phong Vo# AT&T Research## test if feature exists# this script is written to make it through all sh variants## NOTE: .exe a.out suffix and [\\/] in path patterns for dos/ntcase $-:$BASH_VERSION in*x*:[0123456789]*) : bash set -x is broken :; set +ex ;;esaccommand=iffeversion=2005-02-11 # update in USAGE too #pkg() # package{ case $1 in '<') shift ;; *) return ;; esac case $1 in X|X11*) i="openwin" case $1 in X) set X11 ;; esac case $1 in X11) case $# in 1) set $1 6 5 4 ;; esac ;; esac ;; *) i= ;; esac pth="{ usr . - . contrib local $i - . share - . lib - $1" i=$1 while : do shift case $# in 0) break ;; esac case $1 in '>') shift; break ;; esac pth="$pth ${i}R$1 ${i}.$1" done pth="$pth . } $*"}is() # op name{ case $verbose in 1) case $complete in 1) failure ;; esac oo=$1 shift case $1 in ?*) yy=is ii=$1 complete=1 case $oo in cmd) mm="a command" ;; dat) mm="a library data symbol" ;; dfn) mm="a macro with extractable value" ;; exp) mm="true" ;; hdr) mm="a header" ;; id) mm="an identifier" ;; lcl) mm="a native header" ;; key) mm="a reserved keyword" ;; lib) mm="a library function" ;; LIB) case $2 in "") mm="a library" ;; *) ii=$*; mm="a library group" ;; esac ;; mac) mm="a macro" ;; mem) mm="a member of $2" ;; mth) mm="a math library symbol" ;; nos) mm="a non-opaque struct" ;; npt) mm="a symbol that needs a prototype" ;; num) mm="a numeric constant or enum" ;; nxt) mm="an include path for the native header" ;; pth) mm="a file" ;; run) yy="capture output of" mm= ;; siz) mm="a type with known size" ;; sym) mm="a typed variable" ;; sys) mm="a system header" ;; typ) mm="a type or typedef" ;; val) yy="determine" mm="value" ;; *) yy= mm= ;; esac case $ii in [abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;; esac $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr complete=1 ;; esac ;; esac}success(){ case $1 in -) shift ;; *) case $result in UNKNOWN) result=SUCCESS ;; esac case $1 in +) return ;; esac ;; esac case $complete:$verbose in 1:1) case $suspended in 1) suspended=0 $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr ;; esac complete=0 case $# in 0) mm="yes" ;; *) mm="'$*'" ;; esac case $debug in 0) echo " $mm" >&$stderr ;; *) echo "$command: ... $mm" >&$stderr ;; esac ;; esac}failure(){ case $1 in -) shift ;; *) result=FAILURE case $1 in +) return ;; esac ;; esac case $complete:$verbose in 1:1) case $suspended in 1) suspended=0 $show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr ;; esac complete=0 case $# in 0) mm="no" ;; *) mm=$* ;; esac case $debug in 0) echo " $mm" >&$stderr ;; *) echo "$command: ... $mm" >&$stderr ;; esac ;; esac}# report## - ignore global status# -0 normal sense# -1 inverted sense if ! def# status test status 0:success *:failure# success success comment# failure failure comment# default default setting comment## globals## $not invert test sense# $M test variable# $m test macro# $v default macroreport() # [-] [-0] [-1] status value success failure default{ case $1 in -) _report_ignore=$1 shift ;; *) _report_ignore= ;; esac _report_not=$not case $1 in -0) shift ;; -1) shift case $def in ''|-) case $_report_not in 1) _report_not= ;; *) _report_not=1 ;; esac ;; esac ;; esac _report_status=$1 case $_report_ignore:$_report_status in -:*) ;; *:0) success $_report_ignore ;; *) failure $_report_ignore ;; esac _report_value=$2 case $_report_not in 1) case $_report_status in 0) _report_status=1 ;; *) _report_status=0 ;; esac _report_success=$4 _report_failure=$3 ;; *) _report_success=$3 _report_failure=$4 ;; esac _report_default=$5 case $_report_status in 0) case $M in *-*) ;; *) usr="$usr$nl#define $m $_report_value" case $_report_success in ''|-) ;; *) case $define in 1) echo "#define $m $_report_value /* $_report_success */" ;; esac ;; esac eval $m=\'$_report_value\' ;; esac ;; *) case $M in *-*) ;; *) case $_report_failure in ''|-) ;; *) case $define$all$config$undef in 1?1?|1??1)echo "#undef $m /* $_report_failure */" ;; 11??) echo "#define $m 0 /* $_report_failure */" ;; esac ;; esac case $_report_default in ''|-) ;; *) case $define$set in 1?*) echo "#define $v $set /* $_report_default */" ;; esac ;; esac eval $m=0 ;; esac ;; esac}noisy(){ case $complete:$verbose in 1:1) suspended=1 echo >&$stderr ;; esac}here_broken=0copy() # output-file data{ case $shell in ksh) case $1 in -) print -r - "$2" ;; *) print -r - "$2" > "$1" ;; esac ;; *) case $1 in -) if cat <<!$2! then : old here doc botch not present else case $here_broken in 0) here_broken=1 echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr ;; esac sh -c "cat <<!$2!" fi ;; *) if cat > "$1" <<!$2! then : old here doc botch not present else case $here_broken in 0) here_broken=1 echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr ;; esac sh -c "cat > '$1' <<!$2!" fi ;; esac ;; esac}checkread(){ case $posix_read in -no) ;; *) posix_read=`(read -r _checkread_line; echo $_checkread_line) 2>/dev/null <<!a z!` ;; esac case $posix_read in "a z") posix_read=1 ;; *) copy ${tmp}r.c " extern int read(); extern int write(); int main() { char c; char r; int k; char s[32]; k = 0; while (read(0, &c, 1) == 1) { if (k >= 0) { if (c == ' ' || c == '\\t') { if (k < sizeof(s)) s[k++] = c; continue; } if (k > 1 && c != '#' && c != '\\n' && c != '\\r') write(1, s + 1, k - 1); k = -1; } if (c == '\\r') { r = c; if (read(0, &c, 1) == 1 && c != '\\n') write(1, &r, 1); } write(1, &c, 1); if (c == '\\n') return 0; } return 1; }" if $cc -o ${tmp}r.exe ${tmp}r.c >&$nullout then posix_read=${tmp}r.exe else echo "$command: cannot compile read -r workaround" >&$stderr exit 1 fi ;; esac case `(set -f && set x * && echo $# && set +f) 2>/dev/null` in 2) posix_noglob="set -f" posix_glob="set +f" ;; *) case `(set -F && set x * && echo $# && set +F) 2>/dev/null` in 2) posix_noglob="set -F" posix_glob="set +F" ;; *) posix_noglob=":" posix_glob=":" ;; esac ;; esac}execute(){ if test "" != "$cross" then crossexec $cross "$@" _execute_=$? elif test -d /NextDeveloper then "$@" <&$nullin >&$nullout _execute_=$? "$@" <&$nullin | cat else "$@" _execute_=$? fi return $_execute_}exclude(){ case $excludes in '') return 0 ;; esac for _exclude_var do eval _exclude_old=\$$_exclude_var case $_exclude_old in *" -I"*);; *) continue ;; esac _exclude_new= _exclude_sep= for _exclude_arg in $_exclude_old do for _exclude_dir in $excludes do case $_exclude_arg in -I$_exclude_dir|-I*/$_exclude_dir) ;; *) _exclude_new="$_exclude_new$_exclude_sep$_exclude_arg" _exclude_sep=" " ;; esac done done eval $_exclude_var=\$_exclude_new case $debug in 0) ;; *) echo $command: exclude $_exclude_var: "$_exclude_old => $_exclude_new" >&$stderr ;; esac done}all=0binding="-dy -dn -Bdynamic -Bstatic -Wl,-ashared -Wl,-aarchive -call_shared -non_shared '' -static"complete=0config=0defhdr=define=1explicit=0iff=usr=cross=debug=0deflib=dir=FEATUREexcludes=executable="test -x"exists="test -e"gothdr=gotlib=idno=idyes=ifs=${IFS-' '}in=includes=intrinsic=libpaths="LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARY64_PATH LIBPATH SHLIB_PATH" LD_LIBRARY_PATH_default=:/lib:/usr/lib LD_LIBRARYN32_PATH_default=:/lib32:/usr/lib32 LD_LIBRARY64_PATH_default=:/lib64:/usr/lib64 LIBPATH_default=:/lib:/usr/lib SHLIB_PATH_default=:/shlib:/usr/shlib:/lib:/usr/libnl=""occ=ccone=out=posix_read=-checkprotoflags=puthdr=putlib=pragma=case $RANDOM in$RANDOM)shell=bsh ($executable .) 2>/dev/null || executable='test -r' ($exists .) 2>/dev/null || exists='test -r' ;;*) case $BASH_VERSION in ?*) shell=bash ;; *) shell=ksh ;; esac ;;esacreallystatic=reallystatictest=regress=static=.statictest=style=Ccase $COTEMP in"") case $HOSTNAME in ""|?|??|???|????|????) tmp=${HOSTNAME} ;; *) case $shell in bsh) eval `echo $HOSTNAME | sed 's/\\(....\\).*/tmp=\\1/'` ;; *) eval 'tmp=${HOSTNAME%${HOSTNAME#????}}' ;; esac ;; esac tmp=${tmp}$$ ;;*) tmp=$COTEMP ;;esaccase $tmp in??????????*) case $shell in bsh) eval `echo $tmp | sed 's/\\(.........\\).*/tmp=\\1/'` ;; *) eval 'tmp=${tmp%${tmp#?????????}}' ;; esac ;;?????????) ;;????????) tmp=F$tmp ;;esactmp=./$tmpundef=0verbose=0# options -- `-' for output to stdout otherwise usagecase $1 in-) out=-; shift ;;esacset=case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in0123) USAGE=$'[-?@(#)$Id: iffe (AT&T Research) 2005-02-11 $]'$USAGE_LICENSE$'[+NAME?iffe - C compilation environment feature probe][+DESCRIPTION?\biffe\b is a command interpreter that probes the C compilation environment for features. A feature is any file, option or symbol that controls or is controlled by the C compiler. \biffe\b tests features by generating and compiling C programs and observing the behavior of the C compiler and generated programs.][+?\biffe\b statements are line oriented. Statements may appear in the operand list with the \b:\b operand or \bnewline\b as the line delimiter. The standard input is read if there are no command line statements or if \afile\a\b.iffe\b is omitted.][+?Though similar in concept to \bautoconf\b(1) and \bconfig\b(1), there are fundamental differences. The latter tend to generate global headers accessed by all components in a package, whereas \biffe\b is aimed at localized, self contained feature testing.][+?Output is generated in \bFEATURE/\b\atest\a by default, where \atest\a is the base name of \afile\a\b.iffe\b or the \biffe\b \brun\b file operand. Output is first generated in a temporary file; the output file is updated if it does not exist or if the temporary file is different. If the first operand is \b-\b then the output is written to the standard output and no update checks are done.][+?Files with suffixes \b.iffe\b and \b.iff\b are assumed to contain \biffe\b statements.][a:all?Define failed test macros \b0\b. By default only successful test macros are defined \b1\b.][c:cc?Sets the C compiler name and flags to be used in the feature tests.]:[C-compiler-name [C-compiler-flags ...]]][C:config?Generate \bconfig\b(1) style \aHAVE_\a* macro names. This implies \b--undef\b. Since \bconfig\b(1) has inconsistent naming conventions, the \bexp\b op may be needed to translate from the (consistent) \biffe\b names. Unless otherwise noted a \bconfig\b macro name is the \biffe\b macro name prefixed with \bHAVE\b and converted to upper case. \b--config\b is set by default if the command arguments contain a \brun\b op on an input file with the base name \bconfig\b.][d:debug?Sets the debug level. Level 0 inhibits most error messages, level 1 shows compiler messages, and level 2 traces internal \biffe\b \bsh\b(1) actions and does not remove core dumps on exit.]#[level][D:define?Successful test macro definitions are emitted. This is the default.][E:explicit?Disable implicit test output.][i:input?Sets the input file name to \afile\a, which must contain \biffe\b statements.]:[file][I:include?Adds \b-I\b\adir\a to the C compiler flags.]:[dir][L:library?Adds \b-L\b\adir\a to the C compiler flags.]:[dir][o:output?Sets the output file name to \afile\a.]:[file][e:package?Sets the \bproto\b(1) package name to \aname\a.]:[name][p:prototyped?Emits \b#pragma prototyped\b at the top of the output file. See \bproto\b(1).][P:pragma?Emits \b#pragma\b \atext\a at the top of the output file.]:[text][r:regress?Massage output for regression testing.][s:shell?Sets the internal shell name to \aname\a. Used for debugging Bourne shell compatibility (otherwise \biffe\b uses \aksh\a constructs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -