bsd.cpu.mk revision 101015
1# $FreeBSD: head/share/mk/bsd.cpu.mk 101015 2002-07-31 03:56:03Z jhb $ 2 3# Allow TARGET_CPUTYPE to override CPUTYPE to handle the cross-build case. 4 5.if defined(TARGET_CPUTYPE) 6CPUTYPE = ${TARGET_CPUTYPE} 7.endif 8 9# Set default CPU compile flags and baseline CPUTYPE for each arch. The 10# compile flags must support the minimum CPU type for each architecture but 11# may tune support for more advanced processors. 12 13.if !defined(CPUTYPE) || ${CPUTYPE} == "" 14. if ${MACHINE_ARCH} == "i386" 15_CPUCFLAGS = -mcpu=pentiumpro 16CPUTYPE = i386 17. elif ${MACHINE_ARCH} == "alpha" 18_CPUCFLAGS = -mcpu=ev4 -mtune=ev5 19CPUTYPE = ev4 20. elif ${MACHINE_ARCH} == "ia64" 21_CPUCFLAGS = 22CPUTYPE = itanium 23. elif ${MACHINE_ARCH} == "sparc64" 24_CPUCFLAGS = 25CPUTYPE = ultrasparc 26. endif 27.else 28 29# Handle aliases (not documented in make.conf to avoid user confusion 30# between e.g. i586 and pentium) 31 32. if ${MACHINE_ARCH} == "i386" 33. if ${CPUTYPE} == "pentiumpro" 34CPUTYPE = i686 35. elif ${CPUTYPE} == "pentium" 36CPUTYPE = i586 37. elif ${CPUTYPE} == "athlon" 38CPUTYPE = k7 39. endif 40. endif 41 42# Logic to set up correct gcc optimization flag. This must be included 43# after /etc/make.conf so it can react to the local value of CPUTYPE 44# defined therein. Consult: 45# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 46# http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html 47# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 48# http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html 49 50. if ${MACHINE_ARCH} == "i386" 51. if ${CPUTYPE} == "k7" 52_CPUCFLAGS = -march=athlon 53. elif ${CPUTYPE} == "k6-2" 54_CPUCFLAGS = -march=k6 55. elif ${CPUTYPE} == "k6" 56_CPUCFLAGS = -march=k6 57. elif ${CPUTYPE} == "k5" 58_CPUCFLAGS = -march=pentium 59. elif ${CPUTYPE} == "p4" 60_CPUCFLAGS = -march=pentiumpro 61. elif ${CPUTYPE} == "p3" 62_CPUCFLAGS = -march=pentiumpro 63. elif ${CPUTYPE} == "p2" 64_CPUCFLAGS = -march=pentiumpro 65. elif ${CPUTYPE} == "i686" 66_CPUCFLAGS = -march=pentiumpro 67. elif ${CPUTYPE} == "i586/mmx" 68_CPUCFLAGS = -march=pentium-mmx 69. elif ${CPUTYPE} == "i586" 70_CPUCFLAGS = -march=pentium 71. elif ${CPUTYPE} == "i486" 72_CPUCFLAGS = -march=i486 73. endif 74. elif ${MACHINE_ARCH} == "alpha" 75. if ${CPUTYPE} == "ev6" 76_CPUCFLAGS = -mcpu=ev6 77. elif ${CPUTYPE} == "pca56" 78_CPUCFLAGS = -mcpu=pca56 79. elif ${CPUTYPE} == "ev56" 80_CPUCFLAGS = -mcpu=ev56 81. elif ${CPUTYPE} == "ev5" 82_CPUCFLAGS = -mcpu=ev5 83. elif ${CPUTYPE} == "ev45" 84_CPUCFLAGS = -mcpu=ev4 # No -mcpu=ev45 for gcc 85. elif ${CPUTYPE} == "ev4" 86_CPUCFLAGS = -mcpu=ev4 87. endif 88. endif 89.endif 90 91# NB: COPTFLAGS is handled in /usr/src/sys/conf/Makefile.<arch> 92 93.if !defined(NO_CPU_CFLAGS) 94CFLAGS += ${_CPUCFLAGS} 95.endif 96 97# Set up the list of CPU features based on the CPU type. This is an 98# unordered list to make it easy for client makefiles to test for the 99# presence of a CPU feature. 100 101.if ${MACHINE_ARCH} == "i386" 102. if ${CPUTYPE} == "k7" 103MACHINE_CPU = k7 3dnow mmx k6 k5 i586 i486 i386 104. elif ${CPUTYPE} == "k6-2" 105MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 106. elif ${CPUTYPE} == "k6" 107MACHINE_CPU = mmx k6 k5 i586 i486 i386 108. elif ${CPUTYPE} == "k5" 109MACHINE_CPU = k5 i586 i486 i386 110. elif ${CPUTYPE} == "p4" 111MACHINE_CPU = sse i686 mmx i586 i486 i386 112. elif ${CPUTYPE} == "p3" 113MACHINE_CPU = sse i686 mmx i586 i486 i386 114. elif ${CPUTYPE} == "p2" 115MACHINE_CPU = i686 mmx i586 i486 i386 116. elif ${CPUTYPE} == "i686" 117MACHINE_CPU = i686 i586 i486 i386 118. elif ${CPUTYPE} == "i586/mmx" 119MACHINE_CPU = mmx i586 i486 i386 120. elif ${CPUTYPE} == "i586" 121MACHINE_CPU = i586 i486 i386 122. elif ${CPUTYPE} == "i486" 123MACHINE_CPU = i486 i386 124. elif ${CPUTYPE} == "i386" 125MACHINE_CPU = i386 126. endif 127.elif ${MACHINE_ARCH} == "alpha" 128. if ${CPUTYPE} == "ev6" 129MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4 130. elif ${CPUTYPE} == "pca56" 131MACHINE_CPU = pca56 ev56 ev5 ev45 ev4 132. elif ${CPUTYPE} == "ev56" 133MACHINE_CPU = ev56 ev5 ev45 ev4 134. elif ${CPUTYPE} == "ev5" 135MACHINE_CPU = ev5 ev45 ev4 136. elif ${CPUTYPE} == "ev45" 137MACHINE_CPU = ev45 ev4 138. elif ${CPUTYPE} == "ev4" 139MACHINE_CPU = ev4 140. endif 141.elif ${MACHINE_ARCH} == "ia64" 142. if ${CPUTYPE} == "itanium" 143MACHINE_CPU = itanium 144. endif 145.endif 146