1USAGE_LICENSE="[-author?ATT]" 2######################################################################## 3# # 4# This software is part of the ast package # 5# Copyright (c) 1994-2011 AT&T Intellectual Property # 6# and is licensed under the # 7# Eclipse Public License, Version 1.0 # 8# by AT&T Intellectual Property # 9# # 10# A copy of the License is available at # 11# http://www.eclipse.org/org/documents/epl-v10.html # 12# (with md5 checksum b35adb5213ca9657e911e9befb180842) # 13# # 14# Information and Software Systems Research # 15# AT&T Research # 16# Florham Park NJ # 17# # 18# Glenn Fowler <gsf@research.att.com> # 19# # 20######################################################################## 21### this script contains archaic constructs that work with all sh variants ### 22# mamprobe - generate MAM cc probe info 23# Glenn Fowler <gsf@research.att.com> 24 25case $-:$BASH_VERSION in 26*x*:[0123456789]*) : bash set -x is broken :; set +ex ;; 27esac 28 29command=mamprobe 30 31# check the options 32 33opt= 34 35case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in 360123) USAGE=$' 37[-? 38@(#)$Id: mamprobe (AT&T Labs Research) 2011-02-11 $ 39] 40[+NAME?mamprobe - generate MAM cc probe info] 41[+DESCRIPTION?\bmamprobe\b generates MAM (make abstract machine) \bcc\b(1) 42 probe information for use by \bmamake\b(1). \acc-path\a is the 43 absolute path of the probed compiler and \ainfo-file\a is where 44 the information is placed. \ainfo-file\a is usually 45 \b$INSTALLROOT/lib/probe/C/mam/\b\ahash\a, where \ahash\a is a hash 46 of \acc-path\a. Any \ainfo-file\a directories are created if needed. 47 If \ainfo-file\a is \b-\b then the probe information is written to 48 the standard output.] 49[+?\bmamprobe\b and \bmamake\b are used in the bootstrap phase of 50 \bpackage\b(1) installation before \bnmake\b(1) is built. The 51 probed variable names are the \bnmake\b(1) names with a \bmam_\b 52 prefix, \bCC\b converted to \bcc\b, and \b.\b converted to \b_\b. 53 Additional variables are:]{ 54 [+_hosttype_?the \bpackage\b(1) host type] 55 [+mam_cc_L?\b-L\b\adir\a supported] 56 [+STDCAT?command to execute for \bcat\b(1); prefixed by 57 \bexecrate\b(1) on \b.exe\b challenged systems] 58 [+STDCHMOD?command to execute for \bchmod\b(1); prefixed by 59 \bexecrate\b(1) on \b.exe\b challenged systems] 60 [+STDCMP?command to execute for \bcmp\b(1); prefixed by 61 \bexecrate\b(1) on \b.exe\b challenged systems] 62 [+STDCP?command to execute for \bcp\b(1); prefixed by 63 \bexecrate\b(1) on \b.exe\b challenged systems] 64 [+STDED?command to execute for \bed\b(1) or \bex\b(1)] 65 [+STDEDFLAGS?flags for \bSTDED\b] 66 [+STDLN?command to execute for \bln\b(1); prefixed by 67 \bexecrate\b(1) on \b.exe\b challenged systems] 68 [+STDMV?command to execute for \bmv\b(1); prefixed by 69 \bexecrate\b(1) on \b.exe\b challenged systems] 70 [+STDRM?command to execute for \brm\b(1); prefixed by 71 \bexecrate\b(1) on \b.exe\b challenged systems] 72} 73[d:debug?Enable probe script debug trace.] 74 75info-file cc-path 76 77[+SEE ALSO?\bexecrate\b(1), \bpackage\b(1), \bmamake\b(1), \bnmake\b(1), 78 \bprobe\b(1)] 79' 80 while getopts -a "$command" "$USAGE" OPT 81 do case $OPT in 82 d) opt=-d ;; 83 esac 84 done 85 shift `expr $OPTIND - 1` 86 ;; 87*) while : 88 do case $# in 89 0) break ;; 90 esac 91 case $1 in 92 --) shift 93 break 94 ;; 95 -) break 96 ;; 97 -d) opt=-d 98 ;; 99 -*) echo $command: $1: unknown option >&2 100 ;; 101 *) break 102 ;; 103 esac 104 set '' 105 break 106 done 107 ;; 108esac 109 110# check the args 111 112case $1 in 113-) ;; 114/*) ;; 115*) set '' ;; 116esac 117case $2 in 118/*) ;; 119*) set '' ;; 120esac 121case $# in 1220|1) echo "Usage: $command info-file cc-path" >&2; exit 2 ;; 123esac 124info=$1 125shift 126cc=$* 127 128# find the make probe script 129 130ifs=${IFS-' 131 '} 132IFS=: 133set $PATH 134IFS=$ifs 135script=lib/probe/C/make/probe 136while : 137do case $# in 138 0) echo "$0: ../$script: probe script not found on PATH" >&2 139 exit 1 140 ;; 141 esac 142 case $1 in 143 '') continue ;; 144 esac 145 makeprobe=`echo $1 | sed 's,[^/]*$,'$script,` 146 if test -x $makeprobe 147 then break 148 fi 149 shift 150done 151 152# create the info dir if necessary 153 154case $info in 155/*) i=X$info 156 ifs=${IFS-' 157 '} 158 IFS=/ 159 set $i 160 IFS=$ifs 161 while : 162 do i=$1 163 shift 164 case $i in 165 X) break ;; 166 esac 167 done 168 case $info in 169 //*) path=/ ;; 170 *) path= ;; 171 esac 172 while : 173 do case $# in 174 0|1) break ;; 175 esac 176 comp=$1 177 shift 178 case $comp in 179 '') continue ;; 180 esac 181 path=$path/$comp 182 if test ! -d $path 183 then mkdir $path || exit 184 fi 185 done 186 ;; 187esac 188 189# generate info in a tmp file and rename when finished 190 191case $info in 192-) ;; 193*) tmp=/tmp/mam$$ 194 trap "exec >/dev/null; rm -f $tmp" 0 1 2 3 15 195 exec > $tmp 196 echo "probing C language processor $cc for mam information" >&2 197 ;; 198esac 199 200echo "note generated by $0 for $cc" 201 202( 203 set '' $opt $cc 204 shift 205 . $makeprobe "$@" 206 207 case " $CC_DIALECT " in 208 *" -L "*) echo "CC.L = 1" ;; 209 esac 210 211) | sed \ 212 -e '/^CC\./!d' \ 213 -e 's/^CC./setv mam_cc_/' \ 214 -e 's/^\([^=.]*\)\./\1_/' \ 215 -e 's/^\([^=.]*\)\./\1_/' \ 216 -e 's/ =//' \ 217 -e 's/\$("\([^"]*\)")/\1/g' \ 218 -e 's/\$(\([^)]*\))/${\1}/g' \ 219 -e 's/\${CC\./${mam_cc_}/g' 220 221echo 'setv _hosttype_ ${mam_cc_HOSTTYPE}' 222 223# STD* are standard commands/flags with possible execrate(1) 224 225if ( 226ed <<! 227q 228! 229) < /dev/null > /dev/null 2>&1 230then STDED=ed 231else STDED=ex 232fi 233STDEDFLAGS=- 234set STDCAT cat STDCHMOD chmod STDCMP cmp STDCP cp STDLN ln STDMV mv STDRM rm 235while : 236do case $# in 237 0|1) break ;; 238 esac 239 p=$2 240 for d in /bin /usr/bin /usr/sbin 241 do if test -x $d/$p 242 then p=$d/$p 243 break 244 fi 245 done 246 eval $1=\$p 247 shift 248 shift 249done 250if execrate 251then for n in STDCAT STDCHMOD STDCMP STDCP STDLN STDMV STDRM 252 do eval $n=\"execrate \$$n\" 253 done 254fi 255for n in STDCAT STDCHMOD STDCMP STDCP STDED STDEDFLAGS STDLN STDMV STDRM 256do eval echo setv \$n \$$n 257done 258 259# all done 260 261case $info in 262-) ;; 263*) exec >/dev/null 264 test -f $info && rm -f $info 265 cp $tmp $info 266 chmod -w $info 267 ;; 268esac 269