bsd.cpu.mk revision 112769
1# $FreeBSD: head/share/mk/bsd.cpu.mk 112769 2003-03-29 03:14:24Z obrien $
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. if ${MACHINE_ARCH} == "i386"
9_CPUCFLAGS = -mcpu=pentiumpro
10MACHINE_CPU = i386
11. elif ${MACHINE_ARCH} == "alpha"
12_CPUCFLAGS = -mcpu=ev4 -mtune=ev5
13MACHINE_CPU = ev4
14.elif ${MACHINE_ARCH} == "x86-64" || ${MACHINE_ARCH} == "x86_64"
15MACHINE_CPU = x86-64 sse2 sse
16. elif ${MACHINE_ARCH} == "ia64"
17_CPUCFLAGS =
18MACHINE_CPU = itanium
19. elif ${MACHINE_ARCH} == "sparc64"
20_CPUCFLAGS =
21. endif
22.else
23
24# Handle aliases (not documented in make.conf to avoid user confusion
25# between e.g. i586 and pentium)
26
27. if ${MACHINE_ARCH} == "i386"
28.  if ${CPUTYPE} == "pentiumpro"
29CPUTYPE = i686
30.  elif ${CPUTYPE} == "pentium"
31CPUTYPE = i586
32.  elif ${CPUTYPE} == "k7"
33CPUTYPE = athlon
34.  endif
35. endif
36
37# Logic to set up correct gcc optimization flag.  This must be included
38# after /etc/make.conf so it can react to the local value of CPUTYPE
39# defined therein.  Consult:
40#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
41#	http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html
42#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
43#	http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
44
45. if ${MACHINE_ARCH} == "i386"
46.  if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || ${CPUTYPE} == "athlon-4" || ${CPUTYPE} == "athlon"
47_CPUCFLAGS = -march=${CPUTYPE}
48.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
49_CPUCFLAGS = -march=${CPUTYPE}
50.  elif ${CPUTYPE} == "k5"
51_CPUCFLAGS = -march=pentium
52.  elif ${CPUTYPE} == "p4"
53_CPUCFLAGS = -march=pentium4
54.  elif ${CPUTYPE} == "p3"
55_CPUCFLAGS = -march=pentium3
56.  elif ${CPUTYPE} == "p2"
57_CPUCFLAGS = -march=pentium2
58.  elif ${CPUTYPE} == "i686"
59_CPUCFLAGS = -march=pentiumpro
60.  elif ${CPUTYPE} == "i586/mmx"
61_CPUCFLAGS = -march=pentium-mmx
62.  elif ${CPUTYPE} == "i586"
63_CPUCFLAGS = -march=pentium
64.  elif ${CPUTYPE} == "i486"
65_CPUCFLAGS = -march=i486
66.  endif
67. elif ${MACHINE_ARCH} == "alpha"
68.  if ${CPUTYPE} == "ev67"
69_CPUCFLAGS = -mcpu=ev67
70.  elif ${CPUTYPE} == "ev6"
71_CPUCFLAGS = -mcpu=ev6
72.  elif ${CPUTYPE} == "pca56"
73_CPUCFLAGS = -mcpu=pca56
74.  elif ${CPUTYPE} == "ev56"
75_CPUCFLAGS = -mcpu=ev56
76.  elif ${CPUTYPE} == "ev5"
77_CPUCFLAGS = -mcpu=ev5
78.  elif ${CPUTYPE} == "ev45"
79_CPUCFLAGS = -mcpu=ev45
80.  elif ${CPUTYPE} == "ev4"
81_CPUCFLAGS = -mcpu=ev4
82.  endif
83. endif
84
85# Set up the list of CPU features based on the CPU type.  This is an
86# unordered list to make it easy for client makefiles to test for the
87# presence of a CPU feature.
88
89.if ${MACHINE_ARCH} == "i386"
90. if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || ${CPUTYPE} == "athlon-4"
91MACHINE_CPU = athlon-xp k7 3dnow sse mmx k6 k5 i586 i486 i386
92. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
93MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
94. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
95MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
96.  elif ${CPUTYPE} == "k6"
97MACHINE_CPU = mmx k6 k5 i586 i486 i386
98.  elif ${CPUTYPE} == "k5"
99MACHINE_CPU = k5 i586 i486 i386
100.  elif ${CPUTYPE} == "p4"
101MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
102.  elif ${CPUTYPE} == "p3"
103MACHINE_CPU = sse i686 mmx i586 i486 i386
104.  elif ${CPUTYPE} == "p2"
105MACHINE_CPU = i686 mmx i586 i486 i386
106.  elif ${CPUTYPE} == "i686"
107MACHINE_CPU = i686 i586 i486 i386
108.  elif ${CPUTYPE} == "i586/mmx"
109MACHINE_CPU = mmx i586 i486 i386
110.  elif ${CPUTYPE} == "i586"
111MACHINE_CPU = i586 i486 i386
112.  elif ${CPUTYPE} == "i486"
113MACHINE_CPU = i486 i386
114.  elif ${CPUTYPE} == "i386"
115MACHINE_CPU = i386
116.  endif
117. elif ${MACHINE_ARCH} == "alpha"
118.  if ${CPUTYPE} == "ev6"
119MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
120.  elif ${CPUTYPE} == "pca56"
121MACHINE_CPU = pca56 ev56 ev5 ev45 ev4
122.  elif ${CPUTYPE} == "ev56"
123MACHINE_CPU = ev56 ev5 ev45 ev4
124.  elif ${CPUTYPE} == "ev5"
125MACHINE_CPU = ev5 ev45 ev4
126.  elif ${CPUTYPE} == "ev45"
127MACHINE_CPU = ev45 ev4
128.  elif ${CPUTYPE} == "ev4"
129MACHINE_CPU = ev4
130.  endif
131. elif ${MACHINE_ARCH} == "x86-64" || ${MACHINE_ARCH} == "x86_64"
132MACHINE_CPU = x86-64 sse2 sse
133. elif ${MACHINE_ARCH} == "ia64"
134.  if ${CPUTYPE} == "itanium"
135MACHINE_CPU = itanium
136.  endif
137. endif
138.endif
139
140.if ${MACHINE_ARCH} == "alpha"
141_CPUCFLAGS += -mieee
142.endif
143
144# NB: COPTFLAGS is handled in /usr/src/sys/conf/Makefile.<arch>
145
146.if !defined(NO_CPU_CFLAGS)
147CFLAGS += ${_CPUCFLAGS}
148.endif
149