bsd.cpu.mk revision 179989
172878Skris# $FreeBSD: head/share/mk/bsd.cpu.mk 179989 2008-06-25 06:07:03Z ale $ 272878Skris 3100772Sjhb# Set default CPU compile flags and baseline CPUTYPE for each arch. The 4100772Sjhb# compile flags must support the minimum CPU type for each architecture but 5100772Sjhb# may tune support for more advanced processors. 672878Skris 7101232Sru.if !defined(CPUTYPE) || empty(CPUTYPE) 8136606Sobrien_CPUCFLAGS = 9100773Sjhb. if ${MACHINE_ARCH} == "i386" 10113374SobrienMACHINE_CPU = i486 11126657Sbde. elif ${MACHINE_ARCH} == "amd64" 12115175SpeterMACHINE_CPU = amd64 sse2 sse 13100773Sjhb. elif ${MACHINE_ARCH} == "ia64" 14103560SjhbMACHINE_CPU = itanium 15176776Sraj. elif ${MACHINE_ARCH} == "powerpc" 16176776SrajMACHINE_CPU = aim 17100773Sjhb. elif ${MACHINE_ARCH} == "sparc64" 18129217Scognet. elif ${MACHINE_ARCH} == "arm" 19129217ScognetMACHINE_CPU = arm 20177385Simp. elif ${MACHINE_ARCH} == "mips" 21177385SimpMACHINE_CPU = mips 22100773Sjhb. endif 23100772Sjhb.else 2472878Skris 2572878Skris# Handle aliases (not documented in make.conf to avoid user confusion 2672878Skris# between e.g. i586 and pentium) 2772878Skris 28100773Sjhb. if ${MACHINE_ARCH} == "i386" 29166071Sdes. if ${CPUTYPE} == "nocona" 30166071SdesCPUTYPE = prescott 31166071Sdes. elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2" 32166071SdesCPUTYPE = prescott 33136607Sobrien. elif ${CPUTYPE} == "p4" 34136606SobrienCPUTYPE = pentium4 35136606Sobrien. elif ${CPUTYPE} == "p4m" 36136606SobrienCPUTYPE = pentium4m 37136606Sobrien. elif ${CPUTYPE} == "p3" 38136606SobrienCPUTYPE = pentium3 39136606Sobrien. elif ${CPUTYPE} == "p3m" 40136606SobrienCPUTYPE = pentium3m 41136606Sobrien. elif ${CPUTYPE} == "p-m" 42136606SobrienCPUTYPE = pentium-m 43136606Sobrien. elif ${CPUTYPE} == "p2" 44136606SobrienCPUTYPE = pentium2 45136606Sobrien. elif ${CPUTYPE} == "i686" 46136606SobrienCPUTYPE = pentiumpro 47136606Sobrien. elif ${CPUTYPE} == "i586/mmx" 48136606SobrienCPUTYPE = pentium-mmx 49136606Sobrien. elif ${CPUTYPE} == "i586" 50136606SobrienCPUTYPE = pentium 51136607Sobrien. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ 52136607Sobrien ${CPUTYPE} == "k8" 53133525SobrienCPUTYPE = athlon-mp 54103045Smux. elif ${CPUTYPE} == "k7" 55103045SmuxCPUTYPE = athlon 56100773Sjhb. endif 57136607Sobrien. elif ${MACHINE_ARCH} == "amd64" 58166072Sdes. if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2" 59136607SobrienCPUTYPE = nocona 60136607Sobrien. endif 6172878Skris. endif 6272878Skris 63136606Sobrien############################################################################### 6496421Sobrien# Logic to set up correct gcc optimization flag. This must be included 6572878Skris# after /etc/make.conf so it can react to the local value of CPUTYPE 6696421Sobrien# defined therein. Consult: 67160536Simp# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html 68179989Sale# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html 69179989Sale# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html 70177385Simp# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html 7196421Sobrien# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 72179989Sale# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html 7372878Skris 7472878Skris. if ${MACHINE_ARCH} == "i386" 75127888Sdfr. if ${CPUTYPE} == "crusoe" 76133000Sobrien_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 77136606Sobrien. elif ${CPUTYPE} == "k5" 78136606Sobrien_CPUCFLAGS = -march=pentium 79136606Sobrien. else 80136606Sobrien_CPUCFLAGS = -march=${CPUTYPE} 81136606Sobrien. endif # GCC on 'i386' 82136606Sobrien. if ${CPUTYPE} == "crusoe" 83127888Sdfr_ICC_CPUCFLAGS = -tpp6 -xiM 84127888Sdfr. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 85126938Strhodes ${CPUTYPE} == "athlon-4" 86126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 87126890Strhodes. elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon" 88126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 89112768Sobrien. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 90126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xi 9172878Skris. elif ${CPUTYPE} == "k5" 92126890Strhodes_ICC_CPUCFLAGS = -tpp5 93136606Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" 94126890Strhodes_ICC_CPUCFLAGS = -tpp7 -xiMKW 95136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \ 96136606Sobrien ${CPUTYPE} == "pentium-m" 97126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiMK 98136606Sobrien. elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro" 99126890Strhodes_ICC_CPUCFLAGS = -tpp6 -xiM 100136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 101126890Strhodes_ICC_CPUCFLAGS = -tpp5 -xM 102136606Sobrien. elif ${CPUTYPE} == "pentium" 103126890Strhodes_ICC_CPUCFLAGS = -tpp5 104136606Sobrien. else 105126890Strhodes_ICC_CPUCFLAGS = 106136606Sobrien. endif # ICC on 'i386' 107136607Sobrien. elif ${MACHINE_ARCH} == "amd64" 108136607Sobrien_CPUCFLAGS = -march=${CPUTYPE} 109135678Scognet. elif ${MACHINE_ARCH} == "arm" 110136606Sobrien. if ${CPUTYPE} == "xscale" 111172706Scognet#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself 112172706Scognet#_CPUCFLAGS = -mcpu=xscale 113172706Scognet_CPUCFLAGS = -march=armv5te -D__XSCALE__ 114136606Sobrien. else 115136606Sobrien_CPUCFLAGS = -mcpu=${CPUTYPE} 116135678Scognet. endif 117176776Sraj. elif ${MACHINE_ARCH} == "powerpc" 118176776Sraj. if ${CPUTYPE} == "e500" 119176776SrajMACHINE_CPU = booke 120176776Sraj_CPUCFLAGS = -Wa,-me500 -msoft-float 121176776Sraj. endif 122177385Simp. elif ${MACHINE_ARCH} == "mips" 123177385Simp. if ${CPUTYPE} == "mips32" 124177385Simp_CPUCFLAGS = -march=mips32 125177385Simp. elif ${CPUTYPE} == "mips32r2" 126177385Simp_CPUCFLAGS = -march=mips32r2 127177385Simp. elif ${CPUTYPE} == "mips64" 128177385Simp_CPUCFLAGS = -march=mips64 129177385Simp. elif ${CPUTYPE} == "mips64r2" 130177385Simp_CPUCFLAGS = -march=mips64r2 131177385Simp. elif ${CPUTYPE} == "mips4kc" 132177385Simp_CPUCFLAGS = -march=4kc 133177385Simp. elif ${CPUTYPE} == "mips24kc" 134177385Simp_CPUCFLAGS = -march=24kc 135177385Simp. endif 13672878Skris. endif 13772878Skris 13872878Skris# Set up the list of CPU features based on the CPU type. This is an 13972878Skris# unordered list to make it easy for client makefiles to test for the 14072878Skris# presence of a CPU feature. 14172878Skris 142126657Sbde. if ${MACHINE_ARCH} == "i386" 143136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" 144136607SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386 145136607Sobrien. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 146125254Sbde ${CPUTYPE} == "athlon-4" 147136606SobrienMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386 148126657Sbde. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 149112768SobrienMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 150126657Sbde. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 151103045SmuxMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 152103562Sjhb. elif ${CPUTYPE} == "k6" 15374069SsobomaxMACHINE_CPU = mmx k6 k5 i586 i486 i386 154103562Sjhb. elif ${CPUTYPE} == "k5" 15572878SkrisMACHINE_CPU = k5 i586 i486 i386 156160497Sdes. elif ${CPUTYPE} == "c3" 157161259SdesMACHINE_CPU = 3dnow mmx i586 i486 i386 158160497Sdes. elif ${CPUTYPE} == "c3-2" 159160497SdesMACHINE_CPU = sse mmx i586 i486 i386 160176665Sjhb. elif ${CPUTYPE} == "c7" 161176665SjhbMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 162166071Sdes. elif ${CPUTYPE} == "prescott" 163166069SdesMACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386 164136607Sobrien. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m" 165103045SmuxMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 166136606Sobrien. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" 16773145SkrisMACHINE_CPU = sse i686 mmx i586 i486 i386 168136606Sobrien. elif ${CPUTYPE} == "pentium2" 16974553SkrisMACHINE_CPU = i686 mmx i586 i486 i386 170136606Sobrien. elif ${CPUTYPE} == "pentiumpro" 17172878SkrisMACHINE_CPU = i686 i586 i486 i386 172136606Sobrien. elif ${CPUTYPE} == "pentium-mmx" 17373145SkrisMACHINE_CPU = mmx i586 i486 i386 174136606Sobrien. elif ${CPUTYPE} == "pentium" 17572878SkrisMACHINE_CPU = i586 i486 i386 176103562Sjhb. elif ${CPUTYPE} == "i486" 17772878SkrisMACHINE_CPU = i486 i386 178103562Sjhb. elif ${CPUTYPE} == "i386" 17972878SkrisMACHINE_CPU = i386 180103562Sjhb. endif 181115175Speter. elif ${MACHINE_ARCH} == "amd64" 182136607Sobrien. if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8" 183138685SobrienMACHINE_CPU = k8 3dnow 184166071Sdes. elif ${CPUTYPE} == "nocona" 185138685SobrienMACHINE_CPU = sse3 186136607Sobrien. endif 187138685SobrienMACHINE_CPU += amd64 sse2 sse mmx 188103562Sjhb. elif ${MACHINE_ARCH} == "ia64" 189103562Sjhb. if ${CPUTYPE} == "itanium" 19072878SkrisMACHINE_CPU = itanium 191103562Sjhb. endif 19272878Skris. endif 19372878Skris.endif 194103561Sjhb 195163513Scognet.if ${MACHINE_ARCH} == "arm" && defined(TARGET_BIG_ENDIAN) 196160534ScognetCFLAGS += -mbig-endian 197160544ScognetLDFLAGS += -mbig-endian 198160535ScognetLD += -EB 199160534Scognet.endif 200160534Scognet 201177385Simp.if ${MACHINE_ARCH} == "mips" 202177385Simp. if defined(TARGET_BIG_ENDIAN) 203177385SimpCFLAGS += -EB 204177385SimpLDFLAGS += -Wl,-EB 205177385SimpLD += -EB 206177385Simp. else 207177385SimpCFLAGS += -EL 208177385SimpLDFLAGS += -Wl,-EL 209177385SimpLD += -EL 210177385Simp. endif 211177385SimpCFLAGS += -msoft-float -G0 -mno-dsp -mabicalls 212177385Simp.endif 213177385Simp 214124347Sru# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 215103561Sjhb 216103561Sjhb.if !defined(NO_CPU_CFLAGS) 217126890Strhodes. if ${CC} == "icc" 218126890StrhodesCFLAGS += ${_ICC_CPUCFLAGS} 219126890Strhodes. else 220103561SjhbCFLAGS += ${_CPUCFLAGS} 221126890Strhodes. endif 222103561Sjhb.endif 223