]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.cpu.mk
Complete the integration of tbemd branch into head.
[FreeBSD/FreeBSD.git] / share / mk / bsd.cpu.mk
1 # $FreeBSD$
2
3 # Set default CPU compile flags and baseline CPUTYPE for each arch.  The
4 # compile flags must support the minimum CPU type for each architecture but
5 # may tune support for more advanced processors.
6
7 .if !defined(CPUTYPE) || empty(CPUTYPE)
8 _CPUCFLAGS =
9 . if ${MACHINE_CPUARCH} == "i386"
10 MACHINE_CPU = i486
11 . elif ${MACHINE_CPUARCH} == "amd64"
12 MACHINE_CPU = amd64 sse2 sse mmx
13 . elif ${MACHINE_CPUARCH} == "ia64"
14 MACHINE_CPU = itanium
15 . elif ${MACHINE_CPUARCH} == "powerpc"
16 MACHINE_CPU = aim
17 . elif ${MACHINE_CPUARCH} == "sparc64"
18 . elif ${MACHINE_CPUARCH} == "arm"
19 MACHINE_CPU = arm
20 . elif ${MACHINE_CPUARCH} == "mips"
21 MACHINE_CPU = mips
22 . endif
23 .else
24
25 # Handle aliases (not documented in make.conf to avoid user confusion
26 # between e.g. i586 and pentium)
27
28 . if ${MACHINE_CPUARCH} == "i386"
29 .  if ${CPUTYPE} == "nocona"
30 CPUTYPE = prescott
31 .  elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2"
32 CPUTYPE = prescott
33 .  elif ${CPUTYPE} == "p4"
34 CPUTYPE = pentium4
35 .  elif ${CPUTYPE} == "p4m"
36 CPUTYPE = pentium4m
37 .  elif ${CPUTYPE} == "p3"
38 CPUTYPE = pentium3
39 .  elif ${CPUTYPE} == "p3m"
40 CPUTYPE = pentium3m
41 .  elif ${CPUTYPE} == "p-m"
42 CPUTYPE = pentium-m
43 .  elif ${CPUTYPE} == "p2"
44 CPUTYPE = pentium2
45 .  elif ${CPUTYPE} == "i686"
46 CPUTYPE = pentiumpro
47 .  elif ${CPUTYPE} == "i586/mmx"
48 CPUTYPE = pentium-mmx
49 .  elif ${CPUTYPE} == "i586"
50 CPUTYPE = pentium
51 .  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
52      ${CPUTYPE} == "k8"
53 CPUTYPE = athlon-mp
54 .  elif ${CPUTYPE} == "k7"
55 CPUTYPE = athlon
56 .  endif
57 . elif ${MACHINE_CPUARCH} == "amd64"
58 .  if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
59 CPUTYPE = nocona
60 .  endif
61 . endif
62
63 ###############################################################################
64 # Logic to set up correct gcc optimization flag.  This must be included
65 # after /etc/make.conf so it can react to the local value of CPUTYPE
66 # defined therein.  Consult:
67 #       http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
68 #       http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html
69 #       http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html
70 #       http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
71 #       http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
72 #       http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
73
74 . if ${MACHINE_CPUARCH} == "i386"
75 .  if ${CPUTYPE} == "crusoe"
76 _CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
77 .  elif ${CPUTYPE} == "k5"
78 _CPUCFLAGS = -march=pentium
79 .  else
80 _CPUCFLAGS = -march=${CPUTYPE}
81 .  endif # GCC on 'i386'
82 .  if ${CPUTYPE} == "crusoe"
83 _ICC_CPUCFLAGS = -tpp6 -xiM
84 .  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
85     ${CPUTYPE} == "athlon-4"
86 _ICC_CPUCFLAGS = -tpp6 -xiMK
87 .  elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
88 _ICC_CPUCFLAGS = -tpp6 -xiM
89 .  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
90 _ICC_CPUCFLAGS = -tpp6 -xi
91 .  elif ${CPUTYPE} == "k5"
92 _ICC_CPUCFLAGS = -tpp5
93 .  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
94 _ICC_CPUCFLAGS = -tpp7 -xiMKW
95 .  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
96      ${CPUTYPE} == "pentium-m"
97 _ICC_CPUCFLAGS = -tpp6 -xiMK
98 .  elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
99 _ICC_CPUCFLAGS = -tpp6 -xiM
100 .  elif ${CPUTYPE} == "pentium-mmx"
101 _ICC_CPUCFLAGS = -tpp5 -xM
102 .  elif ${CPUTYPE} == "pentium"
103 _ICC_CPUCFLAGS = -tpp5
104 .  else
105 _ICC_CPUCFLAGS =
106 .  endif # ICC on 'i386'
107 . elif ${MACHINE_CPUARCH} == "amd64"
108 _CPUCFLAGS = -march=${CPUTYPE}
109 . elif ${MACHINE_CPUARCH} == "arm"
110 .  if ${CPUTYPE} == "xscale"
111 #XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
112 #_CPUCFLAGS = -mcpu=xscale
113 _CPUCFLAGS = -march=armv5te -D__XSCALE__
114 .  else
115 _CPUCFLAGS = -mcpu=${CPUTYPE}
116 .  endif
117 . elif ${MACHINE_CPUARCH} == "powerpc"
118 .  if ${CPUTYPE} == "e500"
119 MACHINE_CPU = booke
120 _CPUCFLAGS = -Wa,-me500 -msoft-float
121 .  else
122 _CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64
123 .  endif
124 . elif ${MACHINE_ARCH} == "powerpc64"
125 _CPUCFLAGS = -mcpu=${CPUTYPE}
126 . elif ${MACHINE_CPUARCH} == "mips"
127 .  if ${CPUTYPE} == "mips32"
128 _CPUCFLAGS = -march=mips32
129 .  elif ${CPUTYPE} == "mips32r2"
130 _CPUCFLAGS = -march=mips32r2
131 .  elif ${CPUTYPE} == "mips64"
132 _CPUCFLAGS = -march=mips64
133 .  elif ${CPUTYPE} == "mips64r2"
134 _CPUCFLAGS = -march=mips64r2
135 .  elif ${CPUTYPE} == "mips4kc"
136 _CPUCFLAGS = -march=4kc
137 .  elif ${CPUTYPE} == "mips24kc"
138 _CPUCFLAGS = -march=24kc
139 .  endif
140 . endif
141
142 # Set up the list of CPU features based on the CPU type.  This is an
143 # unordered list to make it easy for client makefiles to test for the
144 # presence of a CPU feature.
145
146 . if ${MACHINE_CPUARCH} == "i386"
147 .  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
148 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
149 .  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
150     ${CPUTYPE} == "athlon-4"
151 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
152 .  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
153 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
154 .  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
155 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
156 .  elif ${CPUTYPE} == "k6"
157 MACHINE_CPU = mmx k6 k5 i586 i486 i386
158 .  elif ${CPUTYPE} == "k5"
159 MACHINE_CPU = k5 i586 i486 i386
160 .  elif ${CPUTYPE} == "c3"
161 MACHINE_CPU = 3dnow mmx i586 i486 i386
162 .  elif ${CPUTYPE} == "c3-2"
163 MACHINE_CPU = sse mmx i586 i486 i386
164 .  elif ${CPUTYPE} == "c7"
165 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
166 .  elif ${CPUTYPE} == "prescott"
167 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
168 .  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
169 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
170 .  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
171 MACHINE_CPU = sse i686 mmx i586 i486 i386
172 .  elif ${CPUTYPE} == "pentium2"
173 MACHINE_CPU = i686 mmx i586 i486 i386
174 .  elif ${CPUTYPE} == "pentiumpro"
175 MACHINE_CPU = i686 i586 i486 i386
176 .  elif ${CPUTYPE} == "pentium-mmx"
177 MACHINE_CPU = mmx i586 i486 i386
178 .  elif ${CPUTYPE} == "pentium"
179 MACHINE_CPU = i586 i486 i386
180 .  elif ${CPUTYPE} == "i486"
181 MACHINE_CPU = i486 i386
182 .  elif ${CPUTYPE} == "i386"
183 MACHINE_CPU = i386
184 .  endif
185 . elif ${MACHINE_CPUARCH} == "amd64"
186 .  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
187 MACHINE_CPU = k8 3dnow
188 .  elif ${CPUTYPE} == "nocona"
189 MACHINE_CPU = sse3
190 .  endif
191 MACHINE_CPU += amd64 sse2 sse mmx
192 . elif ${MACHINE_CPUARCH} == "ia64"
193 .  if ${CPUTYPE} == "itanium"
194 MACHINE_CPU = itanium
195 .  endif
196 . endif
197 .endif
198
199 .if ${MACHINE_CPUARCH} == "mips" 
200 CFLAGS += -G0
201 .endif
202
203 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
204
205 .if !defined(NO_CPU_CFLAGS)
206 . if ${CC} == "icc"
207 CFLAGS += ${_ICC_CPUCFLAGS}
208 . else
209 CFLAGS += ${_CPUCFLAGS}
210 . endif
211 .endif