bsd.cpu.mk revision 136697
1# $FreeBSD: head/share/mk/bsd.cpu.mk 136697 2004-10-19 17:25:33Z 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_CPUCFLAGS = 9. if ${MACHINE_ARCH} == "i386" 10MACHINE_CPU = i486 11. elif ${MACHINE_ARCH} == "alpha" 12_CPUCFLAGS = -mcpu=ev4 -mtune=ev5 13MACHINE_CPU = ev4 14. elif ${MACHINE_ARCH} == "amd64" 15MACHINE_CPU = amd64 sse2 sse 16. elif ${MACHINE_ARCH} == "ia64" 17MACHINE_CPU = itanium 18. elif ${MACHINE_ARCH} == "sparc64" 19. elif ${MACHINE_ARCH} == "arm" 20MACHINE_CPU = arm 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} == "nocona" 29CPUTYPE = prescott 30. elif ${CPUTYPE} == "p4" 31CPUTYPE = pentium4 32. elif ${CPUTYPE} == "p4m" 33CPUTYPE = pentium4m 34. elif ${CPUTYPE} == "p3" 35CPUTYPE = pentium3 36. elif ${CPUTYPE} == "p3m" 37CPUTYPE = pentium3m 38. elif ${CPUTYPE} == "p-m" 39CPUTYPE = pentium-m 40. elif ${CPUTYPE} == "p2" 41CPUTYPE = pentium2 42. elif ${CPUTYPE} == "i686" 43CPUTYPE = pentiumpro 44. elif ${CPUTYPE} == "i586/mmx" 45CPUTYPE = pentium-mmx 46. elif ${CPUTYPE} == "i586" 47CPUTYPE = pentium 48. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 49 ${CPUTYPE} == "k8" 50CPUTYPE = athlon-mp 51. elif ${CPUTYPE} == "k7" 52CPUTYPE = athlon 53. endif 54. elif ${MACHINE_ARCH} == "amd64" 55. if ${CPUTYPE} == "prescott" 56CPUTYPE = nocona 57. endif 58. endif 59 60############################################################################### 61# Logic to set up correct gcc optimization flag. This must be included 62# after /etc/make.conf so it can react to the local value of CPUTYPE 63# defined therein. Consult: 64# http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html 65# http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html 66# http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html 67# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 68# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 69 70. if ${MACHINE_ARCH} == "i386" 71. if ${CPUTYPE} == "crusoe" 72_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 73. elif ${CPUTYPE} == "k5" 74_CPUCFLAGS = -march=pentium 75. else 76_CPUCFLAGS = -march=${CPUTYPE} 77. endif # GCC on 'i386' 78. if ${CPUTYPE} == "crusoe" 79_ICC_CPUCFLAGS = -tpp6 -xiM 80. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 81 ${CPUTYPE} == "athlon-4" 82_ICC_CPUCFLAGS = -tpp6 -xiMK 83. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 84_ICC_CPUCFLAGS = -tpp6 -xiM 85. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 86_ICC_CPUCFLAGS = -tpp6 -xi 87. elif ${CPUTYPE} == "k5" 88_ICC_CPUCFLAGS = -tpp5 89. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 90_ICC_CPUCFLAGS = -tpp7 -xiMKW 91. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 92 ${CPUTYPE} == "pentium-m" 93_ICC_CPUCFLAGS = -tpp6 -xiMK 94. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 95_ICC_CPUCFLAGS = -tpp6 -xiM 96. elif ${CPUTYPE} == "pentium-mmx" 97_ICC_CPUCFLAGS = -tpp5 -xM 98. elif ${CPUTYPE} == "pentium" 99_ICC_CPUCFLAGS = -tpp5 100. else 101_ICC_CPUCFLAGS = 102. endif # ICC on 'i386' 103. if ${CPUTYPE} == "i386" 104CFLAGS += -DI386_CPU 105. endif 106. elif ${MACHINE_ARCH} == "alpha" 107_CPUCFLAGS = -mcpu=${CPUTYPE} 108. elif ${MACHINE_ARCH} == "amd64" 109_CPUCFLAGS = -march=${CPUTYPE} 110. elif ${MACHINE_ARCH} == "arm" 111. if ${CPUTYPE} == "xscale" 112#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 113#_CPUCFLAGS = -mcpu=xscale 114_CPUCFLAGS = -D__XSCALE__ 115. else 116_CPUCFLAGS = -mcpu=${CPUTYPE} 117. endif 118. endif 119 120# Set up the list of CPU features based on the CPU type. This is an 121# unordered list to make it easy for client makefiles to test for the 122# presence of a CPU feature. 123 124. if ${MACHINE_ARCH} == "i386" 125. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 126MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 127. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 128 ${CPUTYPE} == "athlon-4" 129MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 130. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 131MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 132. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 133MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 134. elif ${CPUTYPE} == "k6" 135MACHINE_CPU = mmx k6 k5 i586 i486 i386 136. elif ${CPUTYPE} == "k5" 137MACHINE_CPU = k5 i586 i486 i386 138. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 139MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 140. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 141MACHINE_CPU = sse i686 mmx i586 i486 i386 142. elif ${CPUTYPE} == "pentium2" 143MACHINE_CPU = i686 mmx i586 i486 i386 144. elif ${CPUTYPE} == "pentiumpro" 145MACHINE_CPU = i686 i586 i486 i386 146. elif ${CPUTYPE} == "pentium-mmx" 147MACHINE_CPU = mmx i586 i486 i386 148. elif ${CPUTYPE} == "pentium" 149MACHINE_CPU = i586 i486 i386 150. elif ${CPUTYPE} == "i486" 151MACHINE_CPU = i486 i386 152. elif ${CPUTYPE} == "i386" 153MACHINE_CPU = i386 154. endif 155. elif ${MACHINE_ARCH} == "alpha" 156. if ${CPUTYPE} == "ev6" 157MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4 158. elif ${CPUTYPE} == "pca56" 159MACHINE_CPU = pca56 ev56 ev5 ev45 ev4 160. elif ${CPUTYPE} == "ev56" 161MACHINE_CPU = ev56 ev5 ev45 ev4 162. elif ${CPUTYPE} == "ev5" 163MACHINE_CPU = ev5 ev45 ev4 164. elif ${CPUTYPE} == "ev45" 165MACHINE_CPU = ev45 ev4 166. elif ${CPUTYPE} == "ev4" 167MACHINE_CPU = ev4 168. endif 169. elif ${MACHINE_ARCH} == "amd64" 170. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 171MACHINE_CPU = amd64 k8 athlon-mp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 172. elif ${CPUTYPE} == "nocona" 173MACHINE_CPU = sse3 sse2 sse mmx 174. endif 175. elif ${MACHINE_ARCH} == "ia64" 176. if ${CPUTYPE} == "itanium" 177MACHINE_CPU = itanium 178. endif 179. endif 180.endif 181 182.if ${MACHINE_ARCH} == "alpha" 183_CPUCFLAGS += -mieee 184.endif 185 186# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 187 188.if !defined(NO_CPU_CFLAGS) 189. if ${CC} == "icc" 190CFLAGS += ${_ICC_CPUCFLAGS} 191. else 192CFLAGS += ${_CPUCFLAGS} 193. endif 194.endif 195