bsd.cpu.mk revision 160535
11558Srgrimes# $FreeBSD: head/share/mk/bsd.cpu.mk 160535 2006-07-20 22:13:59Z cognet $ 21558Srgrimes 31558Srgrimes# Set default CPU compile flags and baseline CPUTYPE for each arch. The 41558Srgrimes# compile flags must support the minimum CPU type for each architecture but 51558Srgrimes# may tune support for more advanced processors. 61558Srgrimes 71558Srgrimes.if !defined(CPUTYPE) || empty(CPUTYPE) 81558Srgrimes_CPUCFLAGS = 91558Srgrimes. if ${MACHINE_ARCH} == "i386" 101558SrgrimesMACHINE_CPU = i486 111558Srgrimes. elif ${MACHINE_ARCH} == "alpha" 121558Srgrimes_CPUCFLAGS = -mcpu=ev4 -mtune=ev5 131558SrgrimesMACHINE_CPU = ev4 141558Srgrimes. elif ${MACHINE_ARCH} == "amd64" 151558SrgrimesMACHINE_CPU = amd64 sse2 sse 161558Srgrimes. elif ${MACHINE_ARCH} == "ia64" 171558SrgrimesMACHINE_CPU = itanium 181558Srgrimes. elif ${MACHINE_ARCH} == "sparc64" 191558Srgrimes. elif ${MACHINE_ARCH} == "arm" 201558SrgrimesMACHINE_CPU = arm 211558Srgrimes. endif 221558Srgrimes.else 231558Srgrimes 241558Srgrimes# Handle aliases (not documented in make.conf to avoid user confusion 251558Srgrimes# between e.g. i586 and pentium) 261558Srgrimes 271558Srgrimes. if ${MACHINE_ARCH} == "i386" 281558Srgrimes. if ${CPUTYPE} == "nocona" 291558SrgrimesCPUTYPE = prescott 301558Srgrimes. elif ${CPUTYPE} == "p4" 311558SrgrimesCPUTYPE = pentium4 321558Srgrimes. elif ${CPUTYPE} == "p4m" 331558SrgrimesCPUTYPE = pentium4m 341558Srgrimes. elif ${CPUTYPE} == "p3" 3537664ScharnierCPUTYPE = pentium3 3623682Speter. elif ${CPUTYPE} == "p3m" 3737664ScharnierCPUTYPE = pentium3m 3837664Scharnier. elif ${CPUTYPE} == "p-m" 3950476SpeterCPUTYPE = pentium-m 401558Srgrimes. elif ${CPUTYPE} == "p2" 411558SrgrimesCPUTYPE = pentium2 4237664Scharnier. elif ${CPUTYPE} == "i686" 4337664ScharnierCPUTYPE = pentiumpro 4437664Scharnier. elif ${CPUTYPE} == "i586/mmx" 4537664ScharnierCPUTYPE = pentium-mmx 461558Srgrimes. elif ${CPUTYPE} == "i586" 471558SrgrimesCPUTYPE = pentium 481558Srgrimes. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 4937664Scharnier ${CPUTYPE} == "k8" 501558SrgrimesCPUTYPE = athlon-mp 511558Srgrimes. elif ${CPUTYPE} == "k7" 5243804SdillonCPUTYPE = athlon 531558Srgrimes. endif 541558Srgrimes. elif ${MACHINE_ARCH} == "amd64" 551558Srgrimes. if ${CPUTYPE} == "prescott" 561558SrgrimesCPUTYPE = nocona 573550Sphk. endif 583550Sphk. endif 5913637Sjoerg 601558Srgrimes############################################################################### 611558Srgrimes# Logic to set up correct gcc optimization flag. This must be included 6224215Sache# after /etc/make.conf so it can react to the local value of CPUTYPE 6337664Scharnier# defined therein. Consult: 6437664Scharnier# http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html 6537664Scharnier# http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html 661558Srgrimes# http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html 671558Srgrimes# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 6837664Scharnier# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 6937664Scharnier 7037664Scharnier. if ${MACHINE_ARCH} == "i386" 7137664Scharnier. if ${CPUTYPE} == "crusoe" 7237664Scharnier_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 731558Srgrimes. elif ${CPUTYPE} == "k5" 741558Srgrimes_CPUCFLAGS = -march=pentium 751558Srgrimes. else 761558Srgrimes_CPUCFLAGS = -march=${CPUTYPE} 771558Srgrimes. endif # GCC on 'i386' 781558Srgrimes. if ${CPUTYPE} == "crusoe" 791558Srgrimes_ICC_CPUCFLAGS = -tpp6 -xiM 801558Srgrimes. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 811558Srgrimes ${CPUTYPE} == "athlon-4" 821558Srgrimes_ICC_CPUCFLAGS = -tpp6 -xiMK 831558Srgrimes. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 841558Srgrimes_ICC_CPUCFLAGS = -tpp6 -xiM 851558Srgrimes. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 861558Srgrimes_ICC_CPUCFLAGS = -tpp6 -xi 871558Srgrimes. elif ${CPUTYPE} == "k5" 881558Srgrimes_ICC_CPUCFLAGS = -tpp5 891558Srgrimes. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 901558Srgrimes_ICC_CPUCFLAGS = -tpp7 -xiMKW 911558Srgrimes. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 921558Srgrimes ${CPUTYPE} == "pentium-m" 931558Srgrimes_ICC_CPUCFLAGS = -tpp6 -xiMK 9443804Sdillon. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 9543804Sdillon_ICC_CPUCFLAGS = -tpp6 -xiM 961558Srgrimes. elif ${CPUTYPE} == "pentium-mmx" 971558Srgrimes_ICC_CPUCFLAGS = -tpp5 -xM 981558Srgrimes. elif ${CPUTYPE} == "pentium" 991558Srgrimes_ICC_CPUCFLAGS = -tpp5 1001558Srgrimes. else 1011558Srgrimes_ICC_CPUCFLAGS = 1021558Srgrimes. endif # ICC on 'i386' 1031558Srgrimes. elif ${MACHINE_ARCH} == "alpha" 10420061Ssos_CPUCFLAGS = -mcpu=${CPUTYPE} 1051558Srgrimes. elif ${MACHINE_ARCH} == "amd64" 1061558Srgrimes_CPUCFLAGS = -march=${CPUTYPE} 1071558Srgrimes. elif ${MACHINE_ARCH} == "arm" 1081558Srgrimes. if ${CPUTYPE} == "xscale" 1091558Srgrimes#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 1101558Srgrimes#_CPUCFLAGS = -mcpu=xscale 1111558Srgrimes_CPUCFLAGS = -march=armv5te -D__XSCALE__ 1121558Srgrimes. else 1131558Srgrimes_CPUCFLAGS = -mcpu=${CPUTYPE} 1141558Srgrimes. endif 1151558Srgrimes. endif 1161558Srgrimes 1171558Srgrimes# Set up the list of CPU features based on the CPU type. This is an 1181558Srgrimes# unordered list to make it easy for client makefiles to test for the 1191558Srgrimes# presence of a CPU feature. 1201558Srgrimes 1211558Srgrimes. if ${MACHINE_ARCH} == "i386" 1221558Srgrimes. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 1233550SphkMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 1241558Srgrimes. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 1251558Srgrimes ${CPUTYPE} == "athlon-4" 1261558SrgrimesMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 1271558Srgrimes. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 1281558SrgrimesMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 1291558Srgrimes. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 1301558SrgrimesMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 1311558Srgrimes. elif ${CPUTYPE} == "k6" 1321558SrgrimesMACHINE_CPU = mmx k6 k5 i586 i486 i386 1331558Srgrimes. elif ${CPUTYPE} == "k5" 1341558SrgrimesMACHINE_CPU = k5 i586 i486 i386 1351558Srgrimes. elif ${CPUTYPE} == "c3" 1361558SrgrimesMACHINE_CPU = 3dnow mmx i586 i486 i386 1371558Srgrimes. elif ${CPUTYPE} == "c3-2" 1381558SrgrimesMACHINE_CPU = sse mmx i586 i486 i386 1391558Srgrimes. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 14024215SacheMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 14124149Sguido. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 14224215SacheMACHINE_CPU = sse i686 mmx i586 i486 i386 14324149Sguido. elif ${CPUTYPE} == "pentium2" 1441558SrgrimesMACHINE_CPU = i686 mmx i586 i486 i386 14527372Sbde. elif ${CPUTYPE} == "pentiumpro" 14613769SjoergMACHINE_CPU = i686 i586 i486 i386 14737664Scharnier. elif ${CPUTYPE} == "pentium-mmx" 14837664ScharnierMACHINE_CPU = mmx i586 i486 i386 14937664Scharnier. elif ${CPUTYPE} == "pentium" 15037664ScharnierMACHINE_CPU = i586 i486 i386 15137664Scharnier. elif ${CPUTYPE} == "i486" 15237664ScharnierMACHINE_CPU = i486 i386 15337664Scharnier. elif ${CPUTYPE} == "i386" 15437664ScharnierMACHINE_CPU = i386 15537664Scharnier. endif 1561558Srgrimes. elif ${MACHINE_ARCH} == "alpha" 15737664Scharnier. if ${CPUTYPE} == "ev67" 15837664ScharnierMACHINE_CPU = ev67 ev6 ev56 pca56 ev5 ev45 ev4 15937664Scharnier. elif ${CPUTYPE} == "ev6" 16037664ScharnierMACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4 16137664Scharnier. elif ${CPUTYPE} == "pca56" 16237664ScharnierMACHINE_CPU = pca56 ev56 ev5 ev45 ev4 16337664Scharnier. elif ${CPUTYPE} == "ev56" 16437664ScharnierMACHINE_CPU = ev56 ev5 ev45 ev4 16537664Scharnier. elif ${CPUTYPE} == "ev5" 16637664ScharnierMACHINE_CPU = ev5 ev45 ev4 16743804Sdillon. elif ${CPUTYPE} == "ev45" 16843804SdillonMACHINE_CPU = ev45 ev4 16937664Scharnier. elif ${CPUTYPE} == "ev4" 1701558SrgrimesMACHINE_CPU = ev4 1711558Srgrimes. endif 1721558Srgrimes. elif ${MACHINE_ARCH} == "amd64" 1731558Srgrimes. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 1741558SrgrimesMACHINE_CPU = k8 3dnow 1751558Srgrimes. elif ${CPUTYPE} == "nocona" 1761558SrgrimesMACHINE_CPU = sse3 1771558Srgrimes. endif 17823682SpeterMACHINE_CPU += amd64 sse2 sse mmx 1791558Srgrimes. elif ${MACHINE_ARCH} == "ia64" 1801558Srgrimes. if ${CPUTYPE} == "itanium" 18143804SdillonMACHINE_CPU = itanium 1821558Srgrimes. endif 1831558Srgrimes. endif 1841558Srgrimes.endif 18513769Sjoerg 18613769Sjoerg.if ${MACHINE_ARCH} == "alpha" 1871558Srgrimes_CPUCFLAGS += -mieee 1881558Srgrimes.endif 1891558Srgrimes 1901558Srgrimes.if ${MACHINE_ARCH} == "arm" && defined(ARM_BIG_ENDIAN) 19124215SacheCFLAGS += -mbig-endian 19224215SacheLD += -EB 19324215Sache.endif 19426625Sache 19524215Sache# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 19624215Sache 1971558Srgrimes.if !defined(NO_CPU_CFLAGS) 19843804Sdillon. if ${CC} == "icc" 1991558SrgrimesCFLAGS += ${_ICC_CPUCFLAGS} 20037664Scharnier. else 20137664ScharnierCFLAGS += ${_CPUCFLAGS} 20237664Scharnier. endif 2031558Srgrimes.endif 2041558Srgrimes