blob: 1a69c47ee75b9f1c0a0af25446bdb98f455251b6 (
plain)
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
|
#!/bin/sh
# $NetBSD: cpuflags.NetBSD,v 1.32 2002/12/23 13:56:22 abs Exp $
if [ -x /sbin/sysctl ] ;then
SYSCTL=/sbin/sysctl
else
SYSCTL=/usr/sbin/sysctl # NetBSD 1.3
fi
hw_machine=`$SYSCTL -n hw.machine`
hw_machine_arch=`$SYSCTL -n hw.machine_arch`
hw_model=`$SYSCTL -n hw.model`
# We're almost certainly crosscompiling
if [ -n "$MACHINE" -a $hw_machine != "$MACHINE" ]; then
echo
exit
fi
case $hw_machine_arch in
alpha)
# cpu0 at mainbus0: ID 0 (primary), 21164A-0 (unknown ...
case "`egrep '^cpu0 ' /var/run/dmesg.boot`" in
*[\(\ ]2106[46][-\ \)]*) FLAGS="-mcpu=21064" ;;
*[\(\ ]21164[-\ \)]*) FLAGS="-mcpu=21164" ;;
*[\(\ ]21164A[-\ \)]*) FLAGS="-mcpu=21164a" ;;
*[\(\ ]21264B[-\ \)]*) FLAGS="-mcpu=21264" ;;
esac
;;
arm | arm32) case $hw_model in
ARM610*) FLAGS="-mcpu=arm610" ;; # risc pc
ARM710*) FLAGS="-mcpu=arm710" ;; # risc pc
SA-110*)
case $hw_machine in # arm32 split post 1.5
cats|shark|hpcarm|netwinder)
FLAGS="-mcpu=strongarm110" ;;
acorn32)
FLAGS="-march=armv3m -mtune=strongarm" ;;
*)
# memorybus in strongarm risc pc machines cannot support
# certain strongarm instructions, but in 1.5 and earlier
# all strongarm machines are 'arm32', so uname and sysctl
# no use
if egrep -q 'ofbus0|footbridge0' /var/run/dmesg.boot \
2>/dev/null ; then
FLAGS="-mcpu=strongarm110" # shark/cats
else
FLAGS="-march=armv3m -mtune=strongarm" # risc pc
fi
esac ;;
esac ;;
i386) case $hw_model in
*386-class*) FLAGS='-march=i386' ;;
*486-class*) FLAGS='-march=i486' ;;
*AMD\ K6*) FLAGS='-march=k6' ;;
*586-class*) FLAGS='-march=pentium' ;;
*686-class*) FLAGS='-march=pentiumpro' ;;
esac ;;
m68k) case $hw_model in # Examples
*\(68020*) FLAGS='-m68020' ;; # Untested
*\(68030*) FLAGS='-m68030' ;; # Mac LC III
*\(68040*) FLAGS='-m68040' ;; # Untested
*\(68060*) FLAGS='-m68060' ;; # Upgr amiga 3000
esac ;;
mipseb|mipsel)
# cpu0 at mainbus0: QED R4600 Orion CPU (0x2020) Rev. 2.0 with ...
case "`egrep '^cpu0 ' /var/run/dmesg.boot`" in
*\ MIPS\ R2000\ *) FLAGS="-mcpu=r2000" ;;
*\ MIPS\ R3000\ *) FLAGS="-mcpu=r3000" ;;
*\ MIPS\ R3000A\ *) FLAGS="-mcpu=r3000" ;;
*\ Toshiba\ TX3912\ *) FLAGS="-mcpu=r3900" ;;
*\ Toshiba\ TX392[27]\ *) FLAGS="-mcpu=r3900" ;;
*\ MIPS\ R4000\ *) FLAGS="-mcpu=r4000 -mips2" ;; # really mips3
*\ MIPS\ R4400\ *) FLAGS="-mcpu=r4400 -mips2" ;; # really mips3
*\ NEC\ VR4100\ *) FLAGS="-mcpu=r4100 -mips2" ;; # really mips3
*\ NEC\ VR4300\ *) FLAGS="-mcpu=r4300 -mips2" ;; # really mips3
*\ QED\ R4600\ *) FLAGS="-mcpu=r4600 -mips2" ;; # really mips3
*\ MIPS\ R5000\ *) FLAGS="-mcpu=r5000 -mips2" ;; # really mips4
*\ QED\ RM5200\ *) FLAGS="-mcpu=r5000 -mips2" ;; # really mips4
*\ MIPS\ R6000\ *) FLAGS="-mcpu=r6000 -mips2" ;;
*\ MIPS\ R8000\ *) FLAGS="-mcpu=r8000 -mips2" ;; # really mips4
esac
;;
powerpc) case $hw_model in # Examples
601\ *) FLAGS='-mcpu=601' ;; # Untested
602\ *) FLAGS='-mcpu=602' ;; # Untested
603\ *) FLAGS='-mcpu=603' ;; # Untested
603ev\ *) FLAGS='-mcpu=603e' ;; # PM 4400
604\ *) FLAGS='-mcpu=604' ;; # Mac 8500
604ev\ *) FLAGS='-mcpu=604e' ;; # upgr B&W G3
7450\ *) FLAGS='-mcpu=740' ;; # tibook 550
750\ *) FLAGS='-mcpu=750' ;; # Untested
740\ *) FLAGS='-mcpu=740' ;; # Untested
620\ *) FLAGS='-mcpu=620' ;; # Untested
esac ;;
sparc | sparc64) case " $hw_model" in # Examples
*[\ \(]MB86900/1A*) FLAGS='-mcpu=cypress' ;; # ss1+
*[\ \(]CY7C601*) FLAGS='-mcpu=cypress' ;; # ss2
*[\ \(]W8601/8701*) FLAGS='-mcpu=cypress' ;; # elc
*[\ \(]MB86904*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc
*[\ \(]MB86907*) FLAGS='-mcpu=supersparc' ;; # ss5 usparc
*[\ \(]TMS390S10*) FLAGS='-mcpu=supersparc' ;; # classic "
*[\ \(]TMS390Z50*) FLAGS='-mcpu=supersparc' ;; # ss10/ss20
*[\ \(]RT620/625*) FLAGS='-mcpu=supersparc' ;; # ss20 ross
*[\ \(]MB86930*) FLAGS='-mcpu=sparclite' ;; # from gcc
*[\ \(]MB86934*) FLAGS='-mcpu=sparclite' ;; # from gcc
# under 1.5.1 -mcpu=ultrasparc chokes egcs-2.91.66 compiling perl
*[\ \(]SUNW,UltraSPARC*) FLAGS='-mcpu=v9' ;; # Ultra
esac ;;
vax) # No VAX specific gcc optimisations available
NONE=1
;;
esac
if [ -z "$FLAGS" -a -z "$NONE" ] ; then
echo 'Unknown machine - please send details to abs@netbsd.org' >&2
echo " hw.model : '$hw_model'" >&2
echo " hw.machine : '$hw_machine'" >&2
echo " hw.machine_arch : '$hw_machine_arch'" >&2
echo " cpu details :" >&2
egrep '^cpu' /var/run/dmesg.boot >&2
fi
# Fixup flags for old gcc
if [ -n "$FLAGS" ]; then
gcc_ver=`gcc -v 2>&1 | awk '/gcc version/ {sub("egcs-","");print $3}'`
FLAGS=`awk -v "flags=$FLAGS" -v "gcc_ver=$gcc_ver" '
{if (gcc_ver < $1){map[$2] = ""$3}}
END{if (flags in map) {print map[flags]}else {print flags}}
' <<EOD
2.90 -mcpu=21164a
2.90 -march=i386 -mno-486
2.90 -march=i486 -m486
2.90 -march=pentium -m486
2.90 -march=pentiumpro -m486
2.90 -mcpu=supersparc -msupersparc
2.90 -mcpu=sparclite -msparclite
2.90 -mcpu=cypress -mcypress
2.90 -mcpu=v9 -mv8
2.90 -mcpu=arm610 -m6
2.90 -mcpu=strongarm110 -m6
2.90 -mcpu=arm710 -m6
2.95 -march=k6 -march=pentium
EOD
`
fi
echo $FLAGS
exit 0
|