Merge branch 'vendor/TCPDUMP'
[dragonfly.git] / share / mk / bsd.cpu.gcc41.mk
1 # $DragonFly: src/share/mk/bsd.cpu.gcc41.mk,v 1.4 2008/01/05 13:37:15 corecode Exp $
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 _CPUCFLAGS =
9 . if ${MACHINE_ARCH} == "i386"
10 MACHINE_CPU = i486
11 . elif ${MACHINE_ARCH} == "amd64"
12 MACHINE_CPU = amd64 sse2 sse
13 . endif
14 .else
15
16 # Handle aliases (not documented in make.conf to avoid user confusion
17 # between e.g. i586 and pentium)
18
19 . if ${MACHINE_ARCH} == "i386"
20 .  if ${CPUTYPE} == "nocona"
21 CPUTYPE = prescott
22 .  elif ${CPUTYPE} == "core" || ${CPUTYPE} == "core2"
23 CPUTYPE = prescott
24 .  elif ${CPUTYPE} == "p4"
25 CPUTYPE = pentium4
26 .  elif ${CPUTYPE} == "p4m"
27 CPUTYPE = pentium4m
28 .  elif ${CPUTYPE} == "p3"
29 CPUTYPE = pentium3
30 .  elif ${CPUTYPE} == "p3m"
31 CPUTYPE = pentium3m
32 .  elif ${CPUTYPE} == "p-m"
33 CPUTYPE = pentium-m
34 .  elif ${CPUTYPE} == "p2"
35 CPUTYPE = pentium2
36 .  elif ${CPUTYPE} == "i686"
37 CPUTYPE = pentiumpro
38 .  elif ${CPUTYPE} == "i586/mmx"
39 CPUTYPE = pentium-mmx
40 .  elif ${CPUTYPE} == "i586"
41 CPUTYPE = pentium
42 .  elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \
43      ${CPUTYPE} == "k8"
44 CPUTYPE = athlon-mp
45 .  elif ${CPUTYPE} == "k7"
46 CPUTYPE = athlon
47 .  endif
48 . elif ${MACHINE_ARCH} == "amd64"
49 .  if ${CPUTYPE} == "prescott" || ${CPUTYPE} == "core2"
50 CPUTYPE = nocona
51 .  endif
52 . endif
53
54 ###############################################################################
55 # Logic to set up correct gcc optimization flag.  This must be included
56 # after /etc/make.conf so it can react to the local value of CPUTYPE
57 # defined therein.  Consult:
58 #       http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
59 #       http://gcc.gnu.org/onlinedocs/gcc/IA-64-Options.html
60 #       http://gcc.gnu.org/onlinedocs/gcc/RS-6000-and-PowerPC-Options.html
61 #       http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html
62 #       http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
63
64 . if ${MACHINE_ARCH} == "i386"
65 .  if ${CPUTYPE} == "crusoe"
66 _CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
67 .  elif ${CPUTYPE} == "k5"
68 _CPUCFLAGS = -march=pentium
69 .  else
70 _CPUCFLAGS = -march=${CPUTYPE}
71 .  endif # GCC on 'i386'
72 . elif ${MACHINE_ARCH} == "amd64"
73 _CPUCFLAGS = -march=${CPUTYPE}
74 . endif
75
76 # Set up the list of CPU features based on the CPU type.  This is an
77 # unordered list to make it easy for client makefiles to test for the
78 # presence of a CPU feature.
79
80 . if ${MACHINE_ARCH} == "i386"
81 .  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64"
82 MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 i486 i386
83 .  elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \
84     ${CPUTYPE} == "athlon-4"
85 MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 i486 i386
86 .  elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird"
87 MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 i486 i386
88 .  elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2"
89 MACHINE_CPU = 3dnow mmx k6 k5 i586 i486 i386
90 .  elif ${CPUTYPE} == "k6"
91 MACHINE_CPU = mmx k6 k5 i586 i486 i386
92 .  elif ${CPUTYPE} == "k5"
93 MACHINE_CPU = k5 i586 i486 i386
94 .  elif ${CPUTYPE} == "c3"
95 MACHINE_CPU = 3dnow mmx i586 i486 i386
96 .  elif ${CPUTYPE} == "c3-2"
97 MACHINE_CPU = sse mmx i586 i486 i386
98 .  elif ${CPUTYPE} == "prescott"
99 MACHINE_CPU = sse3 sse2 sse i686 mmx i586 i486 i386
100 .  elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || ${CPUTYPE} == "pentium-m"
101 MACHINE_CPU = sse2 sse i686 mmx i586 i486 i386
102 .  elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m"
103 MACHINE_CPU = sse i686 mmx i586 i486 i386
104 .  elif ${CPUTYPE} == "pentium2"
105 MACHINE_CPU = i686 mmx i586 i486 i386
106 .  elif ${CPUTYPE} == "pentiumpro"
107 MACHINE_CPU = i686 i586 i486 i386
108 .  elif ${CPUTYPE} == "pentium-mmx"
109 MACHINE_CPU = mmx i586 i486 i386
110 .  elif ${CPUTYPE} == "pentium"
111 MACHINE_CPU = i586 i486 i386
112 .  elif ${CPUTYPE} == "i486"
113 MACHINE_CPU = i486 i386
114 .  elif ${CPUTYPE} == "i386"
115 MACHINE_CPU = i386
116 .  endif
117 . elif ${MACHINE_ARCH} == "amd64"
118 .  if ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || ${CPUTYPE} == "k8"
119 MACHINE_CPU = k8 3dnow
120 .  elif ${CPUTYPE} == "nocona"
121 MACHINE_CPU = sse3
122 .  endif
123 MACHINE_CPU += amd64 sse2 sse mmx
124 . endif
125 .endif
126
127 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk
128
129 .if !defined(NO_CPU_CFLAGS)
130 CFLAGS += ${_CPUCFLAGS}
131 .endif