-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathguesscpu_linux
executable file
·55 lines (44 loc) · 1.54 KB
/
guesscpu_linux
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
#!/bin/sh
# try guessing CPU type and flags suitable for compiler version
# needs a lot of work for many kernel version and architectures
$CC -v 2> .gcc_version
#GCC_VER=` sed -n 's/^.*gcc version //p' .gcc_version`
#GCC_VER=` sed -n 's/^[a-z ]*\([0-9.]*\).*/\1/p' .gcc_version`
GCC_VER=`cat .gcc_version`
#echo "gcc version is $GCC_VER" 1>&2
case $GCC_VER in
*2.6*) echo "gcc version $GCC_VER - are you sure you don't want to update it?" 1>&2
OLDFLAGS="y" ;;
*2.7*) OLDFLAGS="y" ;;
*2.8*) ;;
*2.91.*) echo "GCC_XFLAGS += -DUSE_AREGP">.cpu-extraflags
;;
*2.9*);;
*) echo "gcc version $GCC_VER not known - cannot set CPU flags" 1>&2 ;;
esac
ARCH=`uname -m`
CPU=`cat /proc/cpuinfo| sed -n 's/cpu.*: //p'`
[ -z "$CPU" ] && CPU=`cat /proc/cpuinfo| sed -n 's/CPU[[:blank:]]*:[^[:alnum:]]*//p' | cut -f1`
[ -n "$CPU" ] && for i in ${CPU};do CPU=${i};break;done # for amd k6, etc.; .hpr'18.12.1999 #
#echo "ARCH=\"${ARCH}\"; CPU type from /proc/cpuinfo: \"$CPU\""
if [ "$OLDFLAGS" = "y" ] ; then
case $ARCH in
*486|4) DEF_CPU=-m486 ;;
*586|5) DEF_CPU=-m486 ;; # gcc<2.8 doesn't know anything else..
*686|6) DEF_CPU=-m486 ;;
m68k) DEF_CPU=-m${CPU};;
*) echo "machine type not known - cannot set CPU flags automatically" 1>&2
DEF_CPU=ERROR ;;
esac
else
case $ARCH in
*486|4) DEF_CPU="-march=i486" ;;
*586|5) DEF_CPU="-march=pentium" ;;
*686|6) DEF_CPU="-march=pentiumpro" ;;
m68k) DEF_CPU=-m${CPU};;
*) echo "machine type not known - cannot set CPU flags automatically" 1>&2
DEF_CPU=ERROR ;;
esac
fi
#rm .gcc_version
echo "$DEF_CPU"