1 ########################################################################
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 #
9 # A copy of the License is available at #
10 # http://www.eclipse.org/org/documents/epl-v10.html #
11 # (with md5 checksum b35adb5213ca9657e911e9befb180842) #
13 # Information and Software Systems Research #
17 # Glenn Fowler <glenn.s.fowler@gmail.com> #
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>
24 case $-:$BASH_VERSION in
25 *x*:[0123456789]*) : bash set -x is broken :; set +ex ;;
34 case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
37 @(#)$Id: mamprobe (AT&T Labs Research) 2011-02-11 $
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
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]
72 [d:debug?Enable probe script debug trace.]
76 [+SEE ALSO?\bexecrate\b(1), \bpackage\b(1), \bmamake\b(1), \bnmake\b(1),
79 while getopts -a "$command" "$USAGE" OPT
84 shift `expr $OPTIND - 1`
98 -*) echo $command: $1: unknown option >&2
121 0|1) echo "Usage: $command info-file cc-path" >&2; exit 2 ;;
127 # find the make probe script
134 script=lib/probe/C/make/probe
137 0) echo "$0: ../$script: probe script not found on PATH" >&2
144 makeprobe=`echo $1 | sed 's,[^/]*$,'$script,`
145 if test -x $makeprobe
151 # create the info dir if necessary
182 then mkdir $path || exit
188 # generate info in a tmp file and rename when finished
193 trap "exec >/dev/null; rm -f $tmp" 0 1 2 3 15
195 echo "probing C language processor $cc for mam information" >&2
199 echo "note generated by $0 for $cc"
206 case " $CC_DIALECT " in
207 *" -L "*) echo "CC.L = 1" ;;
212 -e 's/^CC./setv mam_cc_/' \
213 -e 's/^\([^=.]*\)\./\1_/' \
214 -e 's/^\([^=.]*\)\./\1_/' \
216 -e 's/\$("\([^"]*\)")/\1/g' \
217 -e 's/\$(\([^)]*\))/${\1}/g' \
218 -e 's/\${CC\./${mam_cc_}/g'
220 echo 'setv _hosttype_ ${mam_cc_HOSTTYPE}'
222 # STD* are standard commands/flags with possible execrate(1)
228 ) < /dev/null > /dev/null 2>&1
233 set STDCAT cat STDCHMOD chmod STDCMP cmp STDCP cp STDLN ln STDMV mv STDRM rm
239 for d in /bin /usr/bin /usr/sbin
250 then for n in STDCAT STDCHMOD STDCMP STDCP STDLN STDMV STDRM
251 do eval $n=\"execrate \$$n\"
254 for n in STDCAT STDCHMOD STDCMP STDCP STDED STDEDFLAGS STDLN STDMV STDRM
255 do eval echo setv \$n \$$n
263 test -f $info && rm -f $info