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