bsd.cpu.mk revision 101232
1252867Sdelphij# $FreeBSD: head/share/mk/bsd.cpu.mk 101232 2002-08-02 18:04:22Z ru $
2252867Sdelphij
3252867Sdelphij# Set default CPU compile flags and baseline CPUTYPE for each arch.  The
4252867Sdelphij# compile flags must support the minimum CPU type for each architecture but
5252867Sdelphij# may tune support for more advanced processors.
6252867Sdelphij
7252867Sdelphij.if !defined(CPUTYPE) || empty(CPUTYPE)
8252867Sdelphij. if ${MACHINE_ARCH} == "i386"
9252867Sdelphij_CPUCFLAGS = -mcpu=pentiumpro
10252867SdelphijCPUTYPE = i386
11252867Sdelphij. elif ${MACHINE_ARCH} == "alpha"
12252867Sdelphij_CPUCFLAGS = -mcpu=ev4 -mtune=ev5
13252867SdelphijCPUTYPE = ev4
14252867Sdelphij. elif ${MACHINE_ARCH} == "ia64"
15252867Sdelphij_CPUCFLAGS =
16252867SdelphijCPUTYPE = itanium
17252867Sdelphij. elif ${MACHINE_ARCH} == "sparc64"
18252867Sdelphij_CPUCFLAGS =
19252867SdelphijCPUTYPE = ultrasparc
20252867Sdelphij. endif
21252867Sdelphij.else
22252867Sdelphij
23252867Sdelphij# Handle aliases (not documented in make.conf to avoid user confusion
24252867Sdelphij# between e.g. i586 and pentium)
25252867Sdelphij
26252867Sdelphij. if ${MACHINE_ARCH} == "i386"
27252867Sdelphij.  if ${CPUTYPE} == "pentiumpro"
28252867SdelphijCPUTYPE = i686
29252867Sdelphij.  elif ${CPUTYPE} == "pentium"
30252867SdelphijCPUTYPE = i586
31252867Sdelphij.  elif ${CPUTYPE} == "athlon"
32252867SdelphijCPUTYPE = k7
33252867Sdelphij.  endif
34252867Sdelphij. endif
35252867Sdelphij
36252867Sdelphij# Logic to set up correct gcc optimization flag.  This must be included
37252867Sdelphij# after /etc/make.conf so it can react to the local value of CPUTYPE
38252867Sdelphij# defined therein.  Consult:
39252867Sdelphij#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
40252867Sdelphij#	http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html
41252867Sdelphij#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
42252867Sdelphij#	http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
43252867Sdelphij
44252867Sdelphij. if ${MACHINE_ARCH} == "i386"
45252867Sdelphij.  if ${CPUTYPE} == "k7"
46252867Sdelphij_CPUCFLAGS = -march=athlon
47252867Sdelphij.  elif ${CPUTYPE} == "k6-2"
48252867Sdelphij_CPUCFLAGS = -march=k6
49252867Sdelphij.  elif ${CPUTYPE} == "k6"
50252867Sdelphij_CPUCFLAGS = -march=k6
51252867Sdelphij.  elif ${CPUTYPE} == "k5"
52252867Sdelphij_CPUCFLAGS = -march=pentium
53252867Sdelphij.  elif ${CPUTYPE} == "p4"
54252867Sdelphij_CPUCFLAGS = -march=pentiumpro
55252867Sdelphij.  elif ${CPUTYPE} == "p3"
56252867Sdelphij_CPUCFLAGS = -march=pentiumpro
57252867Sdelphij.  elif ${CPUTYPE} == "p2"
58252867Sdelphij_CPUCFLAGS = -march=pentiumpro
59252867Sdelphij.  elif ${CPUTYPE} == "i686"
60252867Sdelphij_CPUCFLAGS = -march=pentiumpro
61252867Sdelphij.  elif ${CPUTYPE} == "i586/mmx"
62252867Sdelphij_CPUCFLAGS = -march=pentium-mmx
63252867Sdelphij.  elif ${CPUTYPE} == "i586"
64252867Sdelphij_CPUCFLAGS = -march=pentium
65252867Sdelphij.  elif ${CPUTYPE} == "i486"
66252867Sdelphij_CPUCFLAGS = -march=i486
67252867Sdelphij.  endif
68252867Sdelphij. elif ${MACHINE_ARCH} == "alpha"
69252867Sdelphij.  if ${CPUTYPE} == "ev6"
70252867Sdelphij_CPUCFLAGS = -mcpu=ev6
71252867Sdelphij.  elif ${CPUTYPE} == "pca56"
72252867Sdelphij_CPUCFLAGS = -mcpu=pca56
73252867Sdelphij.  elif ${CPUTYPE} == "ev56"
74252867Sdelphij_CPUCFLAGS = -mcpu=ev56
75252867Sdelphij.  elif ${CPUTYPE} == "ev5"
76252867Sdelphij_CPUCFLAGS = -mcpu=ev5
77252867Sdelphij.  elif ${CPUTYPE} == "ev45"
78252867Sdelphij_CPUCFLAGS = -mcpu=ev4		# No -mcpu=ev45 for gcc
79252867Sdelphij.  elif ${CPUTYPE} == "ev4"
80252867Sdelphij_CPUCFLAGS = -mcpu=ev4
81252867Sdelphij.  endif
82252867Sdelphij. endif
83252867Sdelphij.endif
84252867Sdelphij
85252867Sdelphij# NB: COPTFLAGS is handled in /usr/src/sys/conf/Makefile.<arch>
86252867Sdelphij
87252867Sdelphij.if !defined(NO_CPU_CFLAGS)
88252867SdelphijCFLAGS += ${_CPUCFLAGS}
89252867Sdelphij.endif
90252867Sdelphij
91252867Sdelphij# Set up the list of CPU features based on the CPU type.  This is an
92252867Sdelphij# unordered list to make it easy for client makefiles to test for the
93252867Sdelphij# presence of a CPU feature.
94252867Sdelphij
95252867Sdelphij.if ${MACHINE_ARCH} == "i386"
96252867Sdelphij. if ${CPUTYPE} == "k7"
97252867SdelphijMACHINE_CPU = k7 3dnow mmx k6 k5 i586 i486 i386
98252867Sdelphij. elif ${CPUTYPE} == "k6-2"
99252867SdelphijMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
100252867Sdelphij. elif ${CPUTYPE} == "k6"
101252867SdelphijMACHINE_CPU = mmx k6 k5 i586 i486 i386
102252867Sdelphij. elif ${CPUTYPE} == "k5"
103252867SdelphijMACHINE_CPU = k5 i586 i486 i386
104252867Sdelphij. elif ${CPUTYPE} == "p4"
105252867SdelphijMACHINE_CPU = sse i686 mmx i586 i486 i386
106252867Sdelphij. elif ${CPUTYPE} == "p3"
107252867SdelphijMACHINE_CPU = sse i686 mmx i586 i486 i386
108252867Sdelphij. elif ${CPUTYPE} == "p2"
109252867SdelphijMACHINE_CPU = i686 mmx i586 i486 i386
110252867Sdelphij. elif ${CPUTYPE} == "i686"
111252867SdelphijMACHINE_CPU = i686 i586 i486 i386
112252867Sdelphij. elif ${CPUTYPE} == "i586/mmx"
113252867SdelphijMACHINE_CPU = mmx i586 i486 i386
114252867Sdelphij. elif ${CPUTYPE} == "i586"
115252867SdelphijMACHINE_CPU = i586 i486 i386
116252867Sdelphij. elif ${CPUTYPE} == "i486"
117252867SdelphijMACHINE_CPU = i486 i386
118252867Sdelphij. elif ${CPUTYPE} == "i386"
119252867SdelphijMACHINE_CPU = i386
120252867Sdelphij. endif
121252867Sdelphij.elif ${MACHINE_ARCH} == "alpha"
122252867Sdelphij. if ${CPUTYPE} == "ev6"
123252867SdelphijMACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
124252867Sdelphij. elif ${CPUTYPE} == "pca56"
125252867SdelphijMACHINE_CPU = pca56 ev56 ev5 ev45 ev4
126252867Sdelphij. elif ${CPUTYPE} == "ev56"
127252867SdelphijMACHINE_CPU = ev56 ev5 ev45 ev4
128252867Sdelphij. elif ${CPUTYPE} == "ev5"
129252867SdelphijMACHINE_CPU = ev5 ev45 ev4
130252867Sdelphij. elif ${CPUTYPE} == "ev45"
131298955SpfgMACHINE_CPU = ev45 ev4
132252867Sdelphij. elif ${CPUTYPE} == "ev4"
133252867SdelphijMACHINE_CPU = ev4
134252867Sdelphij. endif
135252867Sdelphij.elif ${MACHINE_ARCH} == "ia64"
136252867Sdelphij. if ${CPUTYPE} == "itanium"
137252867SdelphijMACHINE_CPU = itanium
138252867Sdelphij. endif
139252867Sdelphij.endif
140252867Sdelphij