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