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