93
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
94
# compiler to aid in system detection is discouraged as it requires
95
# temporary files to be created and, as you can see below, it is a
96
# headache to deal with in a portable fashion.
96
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
98
# CC_FOR_BUILD -- compiler used by this script.
98
99
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
99
100
# use `HOST_CC' if defined, but it is deprecated.
101
# Portable tmp directory creation inspired by the Autoconf team.
104
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
105
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
107
{ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
108
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
109
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
110
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
112
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
113
102
case $CC_FOR_BUILD,$HOST_CC,$CC in
114
,,) echo "int x;" > $dummy.c ;
115
for c in cc gcc c89 c99 ; do
116
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
117
CC_FOR_BUILD="$c"; break ;
103
,,) echo "int dummy(){}" > $dummy.c
104
for c in cc gcc c89 ; do
105
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
106
if test $? = 0 ; then
107
CC_FOR_BUILD="$c"; break
110
rm -f $dummy.c $dummy.o $dummy.rel
120
111
if test x"$CC_FOR_BUILD" = x ; then
121
CC_FOR_BUILD=no_compiler_found ;
112
CC_FOR_BUILD=no_compiler_found
124
115
,,*) CC_FOR_BUILD=$CC ;;
125
116
,*,*) CC_FOR_BUILD=$HOST_CC ;;
128
119
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
129
# (ghazi@noc.rutgers.edu 1994-08-24)
120
# (ghazi@noc.rutgers.edu 8/24/94.)
130
121
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
131
122
PATH=$PATH:/.attbin ; export PATH
141
132
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
143
# NetBSD (nbsd) targets should (where applicable) match one or
134
# Netbsd (nbsd) targets should (where applicable) match one or
144
135
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
145
136
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
146
137
# switched to ELF, *-*-netbsd* would select the old
147
138
# object file format. This provides both forward
148
139
# compatibility and a consistent mechanism for selecting the
149
140
# object file format.
151
# Note: NetBSD doesn't particularly care about the vendor
152
# portion of the name. We always set it to "unknown".
153
sysctl="sysctl -n hw.machine_arch"
154
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
155
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
156
case "${UNAME_MACHINE_ARCH}" in
157
armeb) machine=armeb-unknown ;;
158
arm*) machine=arm-unknown ;;
159
sh3el) machine=shl-unknown ;;
160
sh3eb) machine=sh-unknown ;;
161
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
141
# Determine the machine/vendor (is the vendor relevant).
142
case "${UNAME_MACHINE}" in
143
amiga) machine=m68k-unknown ;;
144
arm32) machine=arm-unknown ;;
145
atari*) machine=m68k-atari ;;
146
sun3*) machine=m68k-sun ;;
147
mac68k) machine=m68k-apple ;;
148
macppc) machine=powerpc-apple ;;
149
hp3[0-9][05]) machine=m68k-hp ;;
150
ibmrt|romp-ibm) machine=romp-ibm ;;
151
*) machine=${UNAME_MACHINE}-unknown ;;
163
153
# The Operating System including object format, if it has switched
164
154
# to ELF recently, or will in the future.
165
case "${UNAME_MACHINE_ARCH}" in
166
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
167
eval $set_cc_for_build
155
case "${UNAME_MACHINE}" in
156
i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
168
157
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
169
158
| grep __ELF__ >/dev/null
183
# Debian GNU/NetBSD machines have a different userland, and
184
# thus, need a distinct triplet. However, they do not need
185
# kernel version information, so it can be replaced with a
186
# suitable tag, in the style of linux-gnu.
187
case "${UNAME_VERSION}" in
192
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
172
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
195
173
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
196
174
# contains redundant information, the shorter form:
197
175
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
198
176
echo "${machine}-${os}${release}"
201
echo x86_64-unknown-openbsd${UNAME_RELEASE}
204
echo m68k-unknown-openbsd${UNAME_RELEASE}
207
echo arm-unknown-openbsd${UNAME_RELEASE}
210
echo m68k-unknown-openbsd${UNAME_RELEASE}
213
echo m88k-unknown-openbsd${UNAME_RELEASE}
216
echo m68k-unknown-openbsd${UNAME_RELEASE}
219
echo powerpc-unknown-openbsd${UNAME_RELEASE}
222
echo m68k-unknown-openbsd${UNAME_RELEASE}
225
echo m88k-unknown-openbsd${UNAME_RELEASE}
228
echo powerpc-unknown-openbsd${UNAME_RELEASE}
231
echo mips64-unknown-openbsd${UNAME_RELEASE}
234
echo m68k-unknown-openbsd${UNAME_RELEASE}
237
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
240
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
243
echo powerppc-unknown-mirbsd${UNAME_RELEASE}
246
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
249
case $UNAME_RELEASE in
179
if test $UNAME_RELEASE = "V4.0"; then
251
180
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
254
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
257
# According to Compaq, /usr/sbin/psrinfo has been available on
258
# OSF/1 and Tru64 systems produced since 1995. I hope that
259
# covers most systems running today. This code pipes the CPU
260
# types through head -n 1, so we only detect the type of CPU 0.
261
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
262
case "$ALPHA_CPU_TYPE" in
264
UNAME_MACHINE="alpha" ;;
266
UNAME_MACHINE="alpha" ;;
267
"LCA4 (21066/21068)")
268
UNAME_MACHINE="alpha" ;;
270
UNAME_MACHINE="alphaev5" ;;
272
UNAME_MACHINE="alphaev56" ;;
274
UNAME_MACHINE="alphapca56" ;;
276
UNAME_MACHINE="alphapca57" ;;
278
UNAME_MACHINE="alphaev6" ;;
280
UNAME_MACHINE="alphaev67" ;;
282
UNAME_MACHINE="alphaev68" ;;
284
UNAME_MACHINE="alphaev68" ;;
286
UNAME_MACHINE="alphaev68" ;;
287
"EV6.9A (21264/EV69A)")
288
UNAME_MACHINE="alphaev69" ;;
290
UNAME_MACHINE="alphaev7" ;;
292
UNAME_MACHINE="alphaev79" ;;
294
# A Pn.n version is a patched version.
295
182
# A Vn.n version is a released version.
296
183
# A Tn.n version is a released field test version.
297
184
# A Xn.n version is an unreleased experimental baselevel.
298
185
# 1.2 uses "1.2" for uname -r.
299
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
189
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
196
.frame \$30,16,\$26,0
199
.long 0x47e03d80 # implver \$0
201
.long 0x47e20c21 # amask \$2,\$1
211
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
212
if test "$?" = 0 ; then
215
UNAME_MACHINE="alpha"
218
UNAME_MACHINE="alphaev5"
221
UNAME_MACHINE="alphaev56"
224
UNAME_MACHINE="alphapca56"
227
UNAME_MACHINE="alphaev6"
230
UNAME_MACHINE="alphaev67"
234
rm -f $dummy.s $dummy
235
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
301
237
Alpha\ *:Windows_NT*:*)
302
238
# How do we know it's Interix rather than the generic POSIX subsystem?
808
754
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
812
757
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
815
# other systems with GNU libc and userland
816
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
819
760
echo ${UNAME_MACHINE}-pc-minix
822
echo ${UNAME_MACHINE}-unknown-linux-gnu
825
echo cris-axis-linux-gnu
828
echo ${UNAME_MACHINE}-unknown-linux-gnu
831
echo ${UNAME_MACHINE}-unknown-linux-gnu
834
echo ${UNAME_MACHINE}-unknown-linux-gnu
837
eval $set_cc_for_build
838
sed 's/^ //' << EOF >$dummy.c
842
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
845
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
852
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
853
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
856
eval $set_cc_for_build
857
sed 's/^ //' << EOF >$dummy.c
861
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
864
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
871
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
872
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
875
echo powerpc-unknown-linux-gnu
878
echo powerpc64-unknown-linux-gnu
881
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
882
EV5) UNAME_MACHINE=alphaev5 ;;
883
EV56) UNAME_MACHINE=alphaev56 ;;
884
PCA56) UNAME_MACHINE=alphapca56 ;;
885
PCA57) UNAME_MACHINE=alphapca56 ;;
886
EV6) UNAME_MACHINE=alphaev6 ;;
887
EV67) UNAME_MACHINE=alphaev67 ;;
888
EV68*) UNAME_MACHINE=alphaev68 ;;
890
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
891
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
892
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
894
parisc:Linux:*:* | hppa:Linux:*:*)
896
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
897
PA7*) echo hppa1.1-unknown-linux-gnu ;;
898
PA8*) echo hppa2.0-unknown-linux-gnu ;;
899
*) echo hppa-unknown-linux-gnu ;;
902
parisc64:Linux:*:* | hppa64:Linux:*:*)
903
echo hppa64-unknown-linux-gnu
905
s390:Linux:*:* | s390x:Linux:*:*)
906
echo ${UNAME_MACHINE}-ibm-linux
909
echo ${UNAME_MACHINE}-unknown-linux-gnu
912
echo ${UNAME_MACHINE}-unknown-linux-gnu
914
sparc:Linux:*:* | sparc64:Linux:*:*)
915
echo ${UNAME_MACHINE}-unknown-linux-gnu
918
echo x86_64-unknown-linux-gnu
921
764
# The BFD linker knows what the default object file format is, so
922
765
# first see if it will tell us. cd to the root directory to prevent
923
766
# problems with other programs or directories called `ld' in the path.
924
# Set LC_ALL=C to ensure ld outputs messages in English.
925
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
926
| sed -ne '/supported targets:/!d
767
ld_supported_emulations=`cd /; ld --help 2>&1 \
768
| sed -ne '/supported emulations:/!d
928
s/.*supported targets: *//
770
s/.*supported emulations: *//
931
case "$ld_supported_targets" in
773
case "$ld_supported_emulations" in
775
echo "${UNAME_MACHINE}-unknown-linux"
779
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
933
783
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
936
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
939
786
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
942
# Either a pre-BFD a.out linker (linux-gnuoldld) or
943
# one that does not give us useful --help.
944
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
790
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
794
echo "${UNAME_MACHINE}-unknown-linux-gnu"
798
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
802
echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
806
echo "${UNAME_MACHINE}-unknown-linux-gnu"
810
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
813
elf32ppc | elf32ppclinux)
814
# Determine Lib Version
816
#include <features.h>
817
#if defined(__GLIBC__)
818
extern char __libc_version[];
819
extern char __libc_release[];
825
#if defined(__GLIBC__)
826
printf("%s %s\n", __libc_version, __libc_release);
834
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
835
if test "$?" = 0 ; then
836
./$dummy | grep 1\.99 > /dev/null
837
if test "$?" = 0 ; then
841
rm -f $dummy.c $dummy
842
echo powerpc-unknown-linux-gnu${LIBC}
846
echo "${UNAME_MACHINE}-unknown-linux-gnu"
947
# Determine whether the default compiler is a.out or elf
948
eval $set_cc_for_build
949
sed 's/^ //' << EOF >$dummy.c
950
#include <features.h>
962
#ifdef __INTEL_COMPILER
972
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
973
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
974
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
977
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
978
# earlier versions are messed up and put the nodename in both
979
# sysname and nodename.
851
if test "${UNAME_MACHINE}" = "alpha" ; then
855
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
862
.frame \$30,16,\$26,0
865
.long 0x47e03d80 # implver \$0
867
.long 0x47e20c21 # amask \$2,\$1
878
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
879
if test "$?" = 0 ; then
882
UNAME_MACHINE="alpha"
885
UNAME_MACHINE="alphaev5"
888
UNAME_MACHINE="alphaev56"
891
UNAME_MACHINE="alphapca56"
894
UNAME_MACHINE="alphaev6"
897
UNAME_MACHINE="alphaev67"
901
objdump --private-headers $dummy | \
902
grep ld.so.1 > /dev/null
903
if test "$?" = 0 ; then
907
rm -f $dummy.s $dummy
908
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
909
elif test "${UNAME_MACHINE}" = "mips" ; then
912
#include <stdio.h> /* for printf() prototype */
913
int main (int argc, char *argv[]) {
915
int main (argc, argv) int argc; char *argv[]; {
918
printf ("%s-unknown-linux-gnu\n", argv[1]);
922
/* Little Endian R5900 running Linux,
923
this *must* be Sony PlayStation 2 */
924
printf ("%sel-PlayStation2-linux-gnu\n", argv[1]);
926
printf ("%sel-unknown-linux-gnu\n", argv[1]);
932
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
933
rm -f $dummy.c $dummy
934
elif test "${UNAME_MACHINE}" = "s390"; then
935
echo s390-ibm-linux && exit 0
936
elif test "${UNAME_MACHINE}" = "x86_64"; then
937
echo x86_64-unknown-linux-gnu && exit 0
938
elif test "${UNAME_MACHINE}" = "parisc" -o "${UNAME_MACHINE}" = "hppa"; then
940
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
942
echo hppa1.1-unknown-linux-gnu
945
echo hppa2.0-unknown-linux-gnu
948
echo hppa-unknown-linux-gnu
953
# Either a pre-BFD a.out linker (linux-gnuoldld)
954
# or one that does not give us useful --help.
955
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
956
# If ld does not provide *any* "supported emulations:"
957
# that means it is gnuoldld.
958
test -z "$ld_supported_emulations" \
959
&& echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
961
case "${UNAME_MACHINE}" in
969
# Determine whether the default compiler is a.out or elf
971
#include <features.h>
973
#include <stdio.h> /* for printf() prototype */
974
int main (int argc, char *argv[]) {
976
int main (argc, argv) int argc; char *argv[]; {
981
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
983
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
986
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
989
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
994
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
995
rm -f $dummy.c $dummy
996
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
998
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
999
# are messed up and put the nodename in both sysname and nodename.
1000
i?86:DYNIX/ptx:4*:*)
980
1001
echo i386-sequent-sysv4
982
i*86:UNIX_SV:4.2MP:2.*)
1003
i?86:UNIX_SV:4.2MP:2.*)
983
1004
# Unixware is an offshoot of SVR4, but it has its own version
984
1005
# number series starting with 2...
985
1006
# I am not positive that other SVR4 systems won't match this,
1015
1016
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1019
case `/bin/uname -X | grep "^Machine"` in
1020
*486*) UNAME_MACHINE=i486 ;;
1021
*Pentium) UNAME_MACHINE=i586 ;;
1022
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1024
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1020
# Fixed at (any) Pentium or better
1022
if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
1023
echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
1025
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
1027
1029
if test -f /usr/options/cb.name; then
1028
1030
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1029
1031
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1030
1032
elif /bin/uname -X 2>/dev/null >/dev/null ; then
1031
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1032
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1033
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1033
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
1034
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
1035
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
1034
1036
&& UNAME_MACHINE=i586
1035
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1037
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
1036
1038
&& UNAME_MACHINE=i686
1037
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1039
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
1038
1040
&& UNAME_MACHINE=i686
1039
1041
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1041
1043
echo ${UNAME_MACHINE}-pc-sysv32
1047
echo ${UNAME_MACHINE}-pc-msdosdjgpp
1045
1050
# Left here for compatibility:
1046
1051
# uname -m prints for DJGPP always 'pc', but it prints nothing about