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