bsd.cpu.mk revision 161526
183104Sphantom# $FreeBSD: head/share/mk/bsd.cpu.mk 161526 2006-08-22 08:03:01Z ru $
287659Sphantom
383104Sphantom# Set default CPU compile flags and baseline CPUTYPE for each arch.  The
483104Sphantom# compile flags must support the minimum CPU type for each architecture but
583104Sphantom# may tune support for more advanced processors.
683104Sphantom
783104Sphantom.if !defined(CPUTYPE) || empty(CPUTYPE)
883104Sphantom_CPUCFLAGS =
983104Sphantom. if ${MACHINE_ARCH} == "i386"
1083104SphantomMACHINE_CPU = i486
1183104Sphantom. elif ${MACHINE_ARCH} == "amd64"
1283104SphantomMACHINE_CPU = amd64 sse2 sse
1383104Sphantom. elif ${MACHINE_ARCH} == "ia64"
1483104SphantomMACHINE_CPU = itanium
1583104Sphantom. elif ${MACHINE_ARCH} == "sparc64"
1683104Sphantom. elif ${MACHINE_ARCH} == "arm"
1783104SphantomMACHINE_CPU = arm
1883104Sphantom. endif
1983104Sphantom.else
2083104Sphantom
2183104Sphantom# Handle aliases (not documented in make.conf to avoid user confusion
2283104Sphantom# between e.g. i586 and pentium)
2383104Sphantom
2483104Sphantom. if ${MACHINE_ARCH} == "i386"
2583104Sphantom.  if ${CPUTYPE} == "nocona"
2683104SphantomCPUTYPE = prescott
2783104Sphantom.  elif ${CPUTYPE} == "p4"
2892986SobrienCPUTYPE = pentium4
2992986Sobrien.  elif ${CPUTYPE} == "p4m"
3083104SphantomCPUTYPE = pentium4m
3183104Sphantom.  elif ${CPUTYPE} == "p3"
3283104SphantomCPUTYPE = pentium3
3383104Sphantom.  elif ${CPUTYPE} == "p3m"
3483104SphantomCPUTYPE = pentium3m
3583104Sphantom.  elif ${CPUTYPE} == "p-m"
3683104SphantomCPUTYPE = pentium-m
3783104Sphantom.  elif ${CPUTYPE} == "p2"
3883104SphantomCPUTYPE = pentium2
3983104Sphantom.  elif ${CPUTYPE} == "i686"
4083104SphantomCPUTYPE = pentiumpro
4183104Sphantom.  elif ${CPUTYPE} == "i586/mmx"
4283104SphantomCPUTYPE = pentium-mmx
4383104Sphantom.  elif ${CPUTYPE} == "i586"
4483104SphantomCPUTYPE = pentium
4583104Sphantom.  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
4683104Sphantom     ${CPUTYPE} == "k8"
4783104SphantomCPUTYPE = athlon-mp
4883104Sphantom.  elif ${CPUTYPE} == "k7"
4983104SphantomCPUTYPE = athlon
5083104Sphantom.  endif
5183104Sphantom. elif ${MACHINE_ARCH} == "amd64"
5283559Smike.  if ${CPUTYPE} == "prescott"
5383104SphantomCPUTYPE = nocona
5483104Sphantom.  endif
5583104Sphantom. endif
5683559Smike
5783104Sphantom###############################################################################
5883559Smike# Logic to set up correct gcc optimization flag.  This must be included
5983104Sphantom# after /etc/make.conf so it can react to the local value of CPUTYPE
6083104Sphantom# defined therein.  Consult:
6183104Sphantom#	http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
6283559Smike#	http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html
6383104Sphantom#	http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
6483559Smike#	http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
6583104Sphantom#	http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
6683104Sphantom
6783104Sphantom. if ${MACHINE_ARCH} == "i386"
6883104Sphantom.  if ${CPUTYPE} == "crusoe"
6983104Sphantom_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
7083104Sphantom.  elif ${CPUTYPE} == "k5"
7183559Smike_CPUCFLAGS = -march=pentium
7283104Sphantom.  else
7383559Smike_CPUCFLAGS = -march=${CPUTYPE}
7483559Smike.  endif # GCC on 'i386'
7583559Smike.  if ${CPUTYPE} == "crusoe"
7683559Smike_ICC_CPUCFLAGS = -tpp6 -xiM
7783559Smike.  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
7883559Smike    ${CPUTYPE} == "athlon-4"
7983559Smike_ICC_CPUCFLAGS = -tpp6 -xiMK
8083559Smike.  elif ${CPUTYPE} == "athlon-tbird" || ${CPUTYPE} == "athlon"
8183559Smike_ICC_CPUCFLAGS = -tpp6 -xiM
8283559Smike.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6"
8383559Smike_ICC_CPUCFLAGS = -tpp6 -xi
8483559Smike.  elif ${CPUTYPE} == "k5"
8583559Smike_ICC_CPUCFLAGS = -tpp5
8683104Sphantom.  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m"
8783104Sphantom_ICC_CPUCFLAGS = -tpp7 -xiMKW
8883104Sphantom.  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" || \
8983104Sphantom     ${CPUTYPE} == "pentium-m"
9083104Sphantom_ICC_CPUCFLAGS = -tpp6 -xiMK
91103668Smike.  elif ${CPUTYPE} == "pentium2" || ${CPUTYPE} == "pentiumpro"
92103668Smike_ICC_CPUCFLAGS = -tpp6 -xiM
9383104Sphantom.  elif ${CPUTYPE} == "pentium-mmx"
9483104Sphantom_ICC_CPUCFLAGS = -tpp5 -xM
9583104Sphantom.  elif ${CPUTYPE} == "pentium"
9683104Sphantom_ICC_CPUCFLAGS = -tpp5
9783104Sphantom.  else
9883104Sphantom_ICC_CPUCFLAGS =
9983104Sphantom.  endif # ICC on 'i386'
10083104Sphantom. elif ${MACHINE_ARCH} == "amd64"
10183104Sphantom_CPUCFLAGS = -march=${CPUTYPE}
10283104Sphantom. elif ${MACHINE_ARCH} == "arm"
10383104Sphantom.  if ${CPUTYPE} == "xscale"
10483104Sphantom#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself
10583104Sphantom#_CPUCFLAGS = -mcpu=xscale
10683104Sphantom_CPUCFLAGS = -march=armv5te -D__XSCALE__
10783104Sphantom.  else
10883104Sphantom_CPUCFLAGS = -mcpu=${CPUTYPE}
10983104Sphantom.  endif
11083104Sphantom. endif
11183104Sphantom
11283104Sphantom# Set up the list of CPU features based on the CPU type.  This is an
11383104Sphantom# unordered list to make it easy for client makefiles to test for the
11483104Sphantom# presence of a CPU feature.
11583104Sphantom
11683104Sphantom. if ${MACHINE_ARCH} == "i386"
11783104Sphantom.  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
11883104SphantomMACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
11983104Sphantom.  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
12083104Sphantom    ${CPUTYPE} == "athlon-4"
12183104SphantomMACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
12283104Sphantom.  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
12383104SphantomMACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
12483104Sphantom.  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
12583104SphantomMACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
12683104Sphantom.  elif ${CPUTYPE} == "k6"
12783104SphantomMACHINE_CPU = mmx k6 k5 i586 i486 i386
12883104Sphantom.  elif ${CPUTYPE} == "k5"
12983559SmikeMACHINE_CPU = k5 i586 i486 i386
13083104Sphantom.  elif ${CPUTYPE} == "c3"
13183104SphantomMACHINE_CPU = 3dnow mmx i586 i486 i386
13283104Sphantom.  elif ${CPUTYPE} == "c3-2"
13383104SphantomMACHINE_CPU = sse mmx i586 i486 i386
13483104Sphantom.  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
13583104SphantomMACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
13683104Sphantom.  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
13783104SphantomMACHINE_CPU = sse i686 mmx i586 i486 i386
13883104Sphantom.  elif ${CPUTYPE} == "pentium2"
13983104SphantomMACHINE_CPU = i686 mmx i586 i486 i386
14083104Sphantom.  elif ${CPUTYPE} == "pentiumpro"
14183104SphantomMACHINE_CPU = i686 i586 i486 i386
14283104Sphantom.  elif ${CPUTYPE} == "pentium-mmx"
14383104SphantomMACHINE_CPU = mmx i586 i486 i386
14483104Sphantom.  elif ${CPUTYPE} == "pentium"
14583104SphantomMACHINE_CPU = i586 i486 i386
14683104Sphantom.  elif ${CPUTYPE} == "i486"
14783104SphantomMACHINE_CPU = i486 i386
14883104Sphantom.  elif ${CPUTYPE} == "i386"
14983104SphantomMACHINE_CPU = i386
15083104Sphantom.  endif
15183104Sphantom. elif ${MACHINE_ARCH} == "amd64"
15283104Sphantom.  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
15383104SphantomMACHINE_CPU = k8 3dnow
15483104Sphantom.  elif ${CPUTYPE} == "nocona"
15583104SphantomMACHINE_CPU = sse3
15683104Sphantom.  endif
15783104SphantomMACHINE_CPU += amd64 sse2 sse mmx
15883104Sphantom. elif ${MACHINE_ARCH} == "ia64"
15983104Sphantom.  if ${CPUTYPE} == "itanium"
16083104SphantomMACHINE_CPU = itanium
16183104Sphantom.  endif
16283104Sphantom. endif
16383104Sphantom.endif
16483104Sphantom
16583104Sphantom.if ${MACHINE_ARCH} == "arm" && defined(ARM_BIG_ENDIAN)
16683104SphantomCFLAGS += -mbig-endian
16783104SphantomLDFLAGS += -mbig-endian
16883104SphantomLD += -EB
16983104Sphantom.endif
17083104Sphantom
17183104Sphantom# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
17283104Sphantom
17383104Sphantom.if !defined(NO_CPU_CFLAGS)
17483104Sphantom. if ${CC} == "icc"
17583104SphantomCFLAGS += ${_ICC_CPUCFLAGS}
17683104Sphantom. else
17783104SphantomCFLAGS += ${_CPUCFLAGS}
17883104Sphantom. endif
17983104Sphantom.endif
18083104Sphantom