bsd.cpu.mk revision 125254
1# $FreeBSD: head/share/mk/bsd.cpu.mk 125254 2004-01-31 02:17:11Z bde $ 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. if ${MACHINE_ARCH} == "i386" 9_CPUCFLAGS = 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" 17_CPUCFLAGS = 18MACHINE_CPU = itanium 19. elif ${MACHINE_ARCH} == "sparc64" 20_CPUCFLAGS = 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} == "pentiumpro" 29CPUTYPE = i686 30. elif ${CPUTYPE} == "pentium" 31CPUTYPE = i586 32. elif ${CPUTYPE} == "k7" 33CPUTYPE = athlon 34. endif 35. endif 36 37# Logic to set up correct gcc optimization flag. This must be included 38# after /etc/make.conf so it can react to the local value of CPUTYPE 39# defined therein. Consult: 40# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html 41# http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html 42# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html 43# http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html 44 45. if ${MACHINE_ARCH} == "i386" 46. if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 47 ${CPUTYPE} == "athlon-4" || ${CPUTYPE} == "athlon-tbird" || \ 48 ${CPUTYPE} == "athlon" 49_CPUCFLAGS = -march=${CPUTYPE} 50. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "k6" 51_CPUCFLAGS = -march=${CPUTYPE} 52. elif ${CPUTYPE} == "k5" 53_CPUCFLAGS = -march=pentium 54. elif ${CPUTYPE} == "p4" 55_CPUCFLAGS = -march=pentium4 56. elif ${CPUTYPE} == "p3" 57_CPUCFLAGS = -march=pentium3 58. elif ${CPUTYPE} == "p2" 59_CPUCFLAGS = -march=pentium2 60. elif ${CPUTYPE} == "i686" 61_CPUCFLAGS = -march=pentiumpro 62. elif ${CPUTYPE} == "i586/mmx" 63_CPUCFLAGS = -march=pentium-mmx 64. elif ${CPUTYPE} == "i586" 65_CPUCFLAGS = -march=pentium 66. elif ${CPUTYPE} == "i486" 67_CPUCFLAGS = -march=i486 68. endif 69. elif ${MACHINE_ARCH} == "alpha" 70. if ${CPUTYPE} == "ev67" 71_CPUCFLAGS = -mcpu=ev67 72. elif ${CPUTYPE} == "ev6" 73_CPUCFLAGS = -mcpu=ev6 74. elif ${CPUTYPE} == "pca56" 75_CPUCFLAGS = -mcpu=pca56 76. elif ${CPUTYPE} == "ev56" 77_CPUCFLAGS = -mcpu=ev56 78. elif ${CPUTYPE} == "ev5" 79_CPUCFLAGS = -mcpu=ev5 80. elif ${CPUTYPE} == "ev45" 81_CPUCFLAGS = -mcpu=ev45 82. elif ${CPUTYPE} == "ev4" 83_CPUCFLAGS = -mcpu=ev4 84. endif 85. endif 86 87# Set up the list of CPU features based on the CPU type. This is an 88# unordered list to make it easy for client makefiles to test for the 89# presence of a CPU feature. 90 91.if ${MACHINE_ARCH} == "i386" 92. if ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ 93 ${CPUTYPE} == "athlon-4" 94MACHINE_CPU = athlon-xp k7 3dnow sse mmx k6 k5 i586 i486 i386 95. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" 96MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386 97. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" 98MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386 99. elif ${CPUTYPE} == "k6" 100MACHINE_CPU = mmx k6 k5 i586 i486 i386 101. elif ${CPUTYPE} == "k5" 102MACHINE_CPU = k5 i586 i486 i386 103. elif ${CPUTYPE} == "p4" 104MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386 105. elif ${CPUTYPE} == "p3" 106MACHINE_CPU = sse i686 mmx i586 i486 i386 107. elif ${CPUTYPE} == "p2" 108MACHINE_CPU = i686 mmx i586 i486 i386 109. elif ${CPUTYPE} == "i686" 110MACHINE_CPU = i686 i586 i486 i386 111. elif ${CPUTYPE} == "i586/mmx" 112MACHINE_CPU = mmx i586 i486 i386 113. elif ${CPUTYPE} == "i586" 114MACHINE_CPU = i586 i486 i386 115. elif ${CPUTYPE} == "i486" 116MACHINE_CPU = i486 i386 117. elif ${CPUTYPE} == "i386" 118MACHINE_CPU = i386 119. endif 120. elif ${MACHINE_ARCH} == "alpha" 121. if ${CPUTYPE} == "ev6" 122MACHINE_CPU = ev6 ev56 pca56 ev5 ev45 ev4 123. elif ${CPUTYPE} == "pca56" 124MACHINE_CPU = pca56 ev56 ev5 ev45 ev4 125. elif ${CPUTYPE} == "ev56" 126MACHINE_CPU = ev56 ev5 ev45 ev4 127. elif ${CPUTYPE} == "ev5" 128MACHINE_CPU = ev5 ev45 ev4 129. elif ${CPUTYPE} == "ev45" 130MACHINE_CPU = ev45 ev4 131. elif ${CPUTYPE} == "ev4" 132MACHINE_CPU = ev4 133. endif 134. elif ${MACHINE_ARCH} == "amd64" 135MACHINE_CPU = amd64 sse2 sse 136. elif ${MACHINE_ARCH} == "ia64" 137. if ${CPUTYPE} == "itanium" 138MACHINE_CPU = itanium 139. endif 140. endif 141.endif 142 143.if ${MACHINE_ARCH} == "alpha" 144_CPUCFLAGS += -mieee 145.endif 146 147# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk 148 149.if !defined(NO_CPU_CFLAGS) 150CFLAGS += ${_CPUCFLAGS} 151.endif 152