blob: 9521e6c32a8f0728b6ae3c4fdd12638a003f069e (
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
|
#!/bin/sh
# $NetBSD: cpuflags.Linux,v 1.11 2004/11/14 21:51:05 abs Exp $
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
if [ "$1" = -v ] ; then
shift
opt_v=1
fi
if [ -n "$1" ]; then
CC=$1
else
CC=gcc
fi
display_hw_details()
{
echo " OS : '$(uname)'"
echo " proc model : '$hw_model'"
echo " machine_arch : '$hw_machine_arch'"
echo " proc flags : '$hw_flags'"
}
hw_machine_arch=$(uname -m)
if [ ! -f /proc/cpuinfo ] ; then
echo "Unable to open /proc/cpuinfo"
hw_model=Unknown
else
hw_model=$(awk -F: '/^model name/{sub(" ","",$2);print $2;exit}' /proc/cpuinfo)
hw_flags=$(awk -F: '/^flags/{sub(" ","",$2);print $2;exit}' /proc/cpuinfo)
fi
case $hw_machine_arch in
# i386
i386) FLAGS='-march=i386' ;;
i486) FLAGS='-march=i486' ;;
i686) case $hw_model in
"AMD Duron(tm) ") FLAGS='-march=athlon' ;;
"AMD Duron(TM)") FLAGS='-march=athlon' ;;
"AMD Athlon(tm) XP "*) FLAGS='-march=athlon-xp' ;;
"Celeron (Coppermine)") FLAGS='-march=pentium3' ;;
"Pentium III (Coppermine)") FLAGS='-march=pentium3' ;;
"Intel(R) Pentium(R) M processor"*) FLAGS='-march=pentium3m' ;;
"Intel(R) Celeron(R) CPU "*)
case "$hw_flags" in
*" sse2 "*)
FLAGS='-march=pentium4' ;;
esac
esac
;;
#
esac
############
# Everything from this point common between all cpuflags variants.
if [ -n "$opt_v" ] ; then
if [ -z "$NONE" ] ; then
echo "CPUFLAGS=Unknown"
else
echo "CPUFLAGS=None"
fi
display_hw_details
exit
fi
if [ -z "$FLAGS" -a -z "$NONE" ] ; then
echo 'Unknown machine - please send details to abs@netbsd.org' >&2
display_hw_details >&2
fi
# Fixup options for older gccs.
# Entries can be recursive - eg:
# -march=k6-3 -> -march=k6 -> -march=pentium -> -march=i486
#
# The format of table is
# gcc_version_in_which_option_was_introduced new_option old_option
if [ -n "$FLAGS" ]; then
gcc_ver=`${CC} -dumpversion | sed 's/^egcs-//'`
FLAGS=`awk -F: -v "flags=$FLAGS" -v "gcc_ver=$gcc_ver" '
{ if (gcc_ver < $1){map[$2] = ""$3} }
END { while (flags in map) {flags = map[flags]} print flags }
' <<EOD
2.90:-march=i386:-mno-486
2.90:-march=i486:-m486
2.90:-march=pentium:-m486
2.90:-march=pentiumpro:-m486
2.90:-mcpu=21164a:
2.90:-mcpu=arm610:-m6
2.90:-mcpu=arm710:-m6
2.90:-mcpu=cypress:-mcypress
2.90:-mcpu=sparclite:-msparclite
2.90:-mcpu=strongarm110:-m6
2.90:-mcpu=supersparc:-msupersparc
2.90:-mcpu=v9:-mv8
2.95:-march=k6:-march=pentium
3.0:-march=athlon:-march=pentiumpro
3.1:-march=athlon-4:-march=athlon
3.1:-march=athlon-mp:-march=athlon
3.1:-march=athlon-tbird:-march=athlon
3.1:-march=athlon-xp:-march=athlon
3.1:-march=k6-2:-march=k6
3.1:-march=k6-3:-march=k6
3.1:-march=pentium-mmx:-march=pentium
3.1:-march=pentium2:-march=pentiumpro
3.1:-march=pentium3 -mno-sse:-march=pentiumpro
3.1:-march=pentium3:-march=pentiumpro
3.1:-march=pentium4:-march=pentiumpro
3.1:-march=r2000:-cpu=r2000
3.1:-march=r3000:-cpu=r3000
3.1:-march=r3900:-cpu=r3900
3.1:-march=r4000:-cpu=r4000
3.1:-march=r4100:-cpu=r4100
3.1:-march=r4300:-cpu=r4300
3.1:-march=r4400:-cpu=r4400
3.1:-march=r4600:-cpu=r4600
3.1:-march=r5000:-cpu=r5000
3.1:-march=r6000:-cpu=r6000
3.1:-march=r8000:-cpu=r8000
3.1:-mcpu=21264a:-mcpu=21264
3.1:-mcpu=7400:-mcpu=750
3.1:-mcpu=7450:-mcpu=750
3.1:-mtune=r2000:-cpu=r2000
3.1:-mtune=r3000:-cpu=r3000
3.1:-mtune=r3900:-cpu=r3900
3.1:-mtune=r4000:-cpu=r4000
3.1:-mtune=r4100:-cpu=r4100
3.1:-mtune=r4300:-cpu=r4300
3.1:-mtune=r4400:-cpu=r4400
3.1:-mtune=r4600:-cpu=r4600
3.1:-mtune=r5000:-cpu=r5000
3.1:-mtune=r6000:-cpu=r6000
3.1:-mtune=r8000:-cpu=r8000
3.3:-march=c3:-march=i586
3.3:-march=winchip-c6:-march=i586
3.3:-march=winchip2:-march=i586
3.4:-march=athlon-fx:-march=athlon-xp
3.4:-march=athlon64:-march=athlon-xp
3.4:-march=c3-2:-march=c3
3.4:-march=k8:-march=athlon-xp
3.4:-march=nocona:-march=pentium4
3.4:-march=opteron:-march=athlon-xp
3.4:-march=pentium-m:-march=pentium3
3.4:-march=pentium3m:-march=pentium3
3.4:-march=pentium4m:-march=pentium4
3.4:-march=prescott:-march=pentium4
EOD
`
fi
echo $FLAGS
exit 0
|