blob: dfdf96d6b294fefe8c3a894d43d904e2c93dcc40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/bin/sh
#
# Check cpu of current machine and find the
# best compiler optimization flags for gcc
#
#
if test -r /proc/cpuinfo ; then
cpuinfo="cat /proc/cpuinfo"
cpu_family=`$cpuinfo | grep 'family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
if test -z "$cpu_family" ; then
cpu_family=`$cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
fi
cpu_vendor=`$cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1`
model_name=`$cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`
if test -z "$model_name" ; then
model_name=`$cpuinfo | grep 'cpu model' | cut -d ':' -f 2 | head -1`
fi
if test -z "$model_name" ; then
model_name=`uname -m`
fi
else
# Fallback when there is no /proc/cpuinfo
case "`uname -s`" in
FreeBSD)
cpu_family=`uname -m`;
model_name=`sysctl -b hw.model`
;;
*)
cpu_family=`uname -m`;
model_name="unknown";
;;
esac
fi
cpu_flag=""
cpu_flag_old=""
case "$cpu_family--$model_name" in
Alpha*EV6*)
cpu_flag="ev6";
;;
*Xeon*)
cpu_flag="nocona";
;;
*Pentium*4*Mobile*CPU*)
cpu_flag="pentium4m";
;;
*Pentium*4*CPU*)
cpu_flag="pentium4";
;;
*Pentium*III*Mobile*CPU*)
cpu_flag="pentium3m";
;;
*Pentium*III*CPU*)
cpu_flag="pentium3";
;;
*Athlon*64*)
cpu_flag="athlon64";
cpu_flag_old="athlon";
;;
*Athlon*)
cpu_flag="athlon";
;;
*Itanium*)
# Don't need to set any flags for itanium(at the moment)
cpu_flag="";
;;
*ppc)
cpu_flag="powerpc";
;;
*)
cpu_flag="";
;;
esac
if test -z "$cpu_flag"; then
echo "BUILD/check-cpu: Oops, could not findout what kind of cpu this machine is using."
check_cpu_flags=""
return
fi
echo "cpu_flag: $cpu_flag"
if test -z "$CC" ; then
cc="gcc";
else
cc=$CC
fi
cc_ver=`$cc --version | sed 1q`
cc_verno=`echo $cc_ver | sed -e 's/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
case "$cc_ver--$cc_verno" in
*GCC*--3.4*|*GCC*--3.5*|*GCC*--4.*)
check_cpu_cflags="-mtune=$cpu_flag -march=$cpu_flag"
;;
*GCC*)
# Fix for older compiler versions
if test -n "$cpu_flag_old"; then
cpu_flag="$cpu_flag_old"
fi
check_cpu_cflags="-mcpu=$cpu_flag -march=$cpu_flag"
;;
*)
check_cpu_cflags=""
;;
esac
echo $check_cpu_cflags
|