bsd.cpu.mk revision 100772
1# $FreeBSD: head/share/mk/bsd.cpu.mk 100772 2002-07-27 22:04:05Z 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 !defined(NO_CPU_CFLAGS) || !defined(NO_CPU_COPTFLAGS)
45. if ${MACHINE_ARCH} == "i386"
46.  if ${CPUTYPE} == "k7"
47.   if defined(BOOTSTRAPPING)
48_CPUCFLAGS = -march=k6		# gcc 2.95.x didn't support athlon
49.   else
50_CPUCFLAGS = -march=athlon
51.   endif
52.  elif ${CPUTYPE} == "k6-2"
53_CPUCFLAGS = -march=k6
54.  elif ${CPUTYPE} == "k6"
55_CPUCFLAGS = -march=k6
56.  elif ${CPUTYPE} == "k5"
57_CPUCFLAGS = -march=pentium
58.  elif ${CPUTYPE} == "p4"
59_CPUCFLAGS = -march=pentiumpro
60.  elif ${CPUTYPE} == "p3"
61_CPUCFLAGS = -march=pentiumpro
62.  elif ${CPUTYPE} == "p2"
63_CPUCFLAGS = -march=pentiumpro
64.  elif ${CPUTYPE} == "i686"
65_CPUCFLAGS = -march=pentiumpro
66.  elif ${CPUTYPE} == "i586/mmx"
67_CPUCFLAGS = -march=pentium-mmx
68.  elif ${CPUTYPE} == "i586"
69_CPUCFLAGS = -march=pentium
70.  elif ${CPUTYPE} == "i486"
71_CPUCFLAGS = -march=i486
72.  endif
73. elif ${MACHINE_ARCH} == "alpha"
74.  if ${CPUTYPE} == "ev6"
75_CPUCFLAGS = -mcpu=ev6
76.  elif ${CPUTYPE} == "pca56"
77_CPUCFLAGS = -mcpu=pca56
78.  elif ${CPUTYPE} == "ev56"
79_CPUCFLAGS = -mcpu=ev56
80.  elif ${CPUTYPE} == "ev5"
81_CPUCFLAGS = -mcpu=ev5
82.  elif ${CPUTYPE} == "ev45"
83_CPUCFLAGS = -mcpu=ev4		# No -mcpu=ev45 for gcc
84.  elif ${CPUTYPE} == "ev4"
85_CPUCFLAGS = -mcpu=ev4
86.  endif
87. endif
88.endif
89.endif
90
91# NB: COPTFLAGS is handled in /usr/src/sys/conf/Makefile.<arch>
92
93.if !defined(NO_CPU_CFLAGS)
94CFLAGS += ${_CPUCFLAGS}
95.endif
96
97# Set up the list of CPU features based on the CPU type.  This is an
98# unordered list to make it easy for client makefiles to test for the
99# presence of a CPU feature.
100
101.if ${MACHINE_ARCH} == "i386"
102. if ${CPUTYPE} == "k7"
103MACHINE_CPU = k7 3dnow mmx k6 k5 i586 i486 i386
104. elif ${CPUTYPE} == "k6-2"
105MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
106. elif ${CPUTYPE} == "k6"
107MACHINE_CPU = mmx k6 k5 i586 i486 i386
108. elif ${CPUTYPE} == "k5"
109MACHINE_CPU = k5 i586 i486 i386
110. elif ${CPUTYPE} == "p4"
111MACHINE_CPU = sse i686 mmx i586 i486 i386
112. elif ${CPUTYPE} == "p3"
113MACHINE_CPU = sse i686 mmx i586 i486 i386
114. elif ${CPUTYPE} == "p2"
115MACHINE_CPU = i686 mmx i586 i486 i386
116. elif ${CPUTYPE} == "i686"
117MACHINE_CPU = i686 i586 i486 i386
118. elif ${CPUTYPE} == "i586/mmx"
119MACHINE_CPU = mmx i586 i486 i386
120. elif ${CPUTYPE} == "i586"
121MACHINE_CPU = i586 i486 i386
122. elif ${CPUTYPE} == "i486"
123MACHINE_CPU = i486 i386
124. elif ${CPUTYPE} == "i386"
125MACHINE_CPU = i386
126. endif
127.elif ${MACHINE_ARCH} == "alpha"
128. if ${CPUTYPE} == "ev6"
129MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4
130. elif ${CPUTYPE} == "pca56"
131MACHINE_CPU = pca56 ev56 ev5 ev45 ev4
132. elif ${CPUTYPE} == "ev56"
133MACHINE_CPU = ev56 ev5 ev45 ev4
134. elif ${CPUTYPE} == "ev5"
135MACHINE_CPU = ev5 ev45 ev4
136. elif ${CPUTYPE} == "ev45"
137MACHINE_CPU = ev45 ev4
138. elif ${CPUTYPE} == "ev4"
139MACHINE_CPU = ev4
140. endif
141.elif ${MACHINE_ARCH} == "ia64"
142. if ${CPUTYPE} == "itanium"
143MACHINE_CPU = itanium
144. endif
145.endif
146