summaryrefslogtreecommitdiff
path: root/devel/cpuflags
diff options
context:
space:
mode:
authorabs <abs@pkgsrc.org>2008-12-10 23:27:17 +0000
committerabs <abs@pkgsrc.org>2008-12-10 23:27:17 +0000
commitb2e170707c79ba9e0f16b45d68dae0371f4418f8 (patch)
tree4144b04b8a37e492459e05360998aed6d2562b9d /devel/cpuflags
parent528b99347b92cf500d04d3b565bb53e646891bc4 (diff)
downloadpkgsrc-b2e170707c79ba9e0f16b45d68dae0371f4418f8.tar.gz
Updated devel/cpuflags to 1.24
Add map_x86_brand_string to subr_x86 and use in NetBSD, Linux and Solaris to determine ARCH for Intel CPUs after PIII. (Still need to rework AMD CPU detection to use family and extended family) Added 'AMD K6-2 (586-class)' - thanks Brian Ginsbach Added 'Pentium(R) Dual-Core CPU E5200' - thanks Andreas Burghardt
Diffstat (limited to 'devel/cpuflags')
-rw-r--r--devel/cpuflags/Makefile4
-rw-r--r--devel/cpuflags/files/subr_FreeBSD4
-rwxr-xr-xdevel/cpuflags/files/subr_Linux48
-rwxr-xr-xdevel/cpuflags/files/subr_NetBSD48
-rwxr-xr-xdevel/cpuflags/files/subr_SunOS14
-rw-r--r--devel/cpuflags/files/subr_x8623
6 files changed, 85 insertions, 56 deletions
diff --git a/devel/cpuflags/Makefile b/devel/cpuflags/Makefile
index b2f18b3ffca..d85ad60c0c1 100644
--- a/devel/cpuflags/Makefile
+++ b/devel/cpuflags/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.129 2008/12/08 19:46:58 abs Exp $
+# $NetBSD: Makefile,v 1.130 2008/12/10 23:27:17 abs Exp $
-DISTNAME= cpuflags-1.23
+DISTNAME= cpuflags-1.24
CATEGORIES= devel sysutils
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/devel/cpuflags/files/subr_FreeBSD b/devel/cpuflags/files/subr_FreeBSD
index 9da384d48ee..40e7b2f8b34 100644
--- a/devel/cpuflags/files/subr_FreeBSD
+++ b/devel/cpuflags/files/subr_FreeBSD
@@ -1,4 +1,4 @@
-# $NetBSD: subr_FreeBSD,v 1.2 2007/08/27 10:08:29 abs Exp $
+# $NetBSD: subr_FreeBSD,v 1.3 2008/12/10 23:27:17 abs Exp $
AWK=awk
SED=sed
@@ -38,7 +38,7 @@ determine_arch()
Pentium\ II*) ARCH='-march=pentium2' ;;
Intel\ Pentium\ III\ *) ARCH='-march=pentium3' ;;
Intel\ Pentium\ 4\ *) ARCH='-march=pentium4' ;;
- Intel\ Core2\ *) ARCH='-march=prescott' ;;
+ Intel\ Core2\ *) ARCH='-march=core2' ;;
AMD\ Athlon\ XP*) ARCH='-march=athlon-xp' ;;
AMD\ Sempron\ Processor\ *) ARCH='-march=athlon-xp' ;;
# last resort:
diff --git a/devel/cpuflags/files/subr_Linux b/devel/cpuflags/files/subr_Linux
index c2e5520a20f..d014f777d81 100755
--- a/devel/cpuflags/files/subr_Linux
+++ b/devel/cpuflags/files/subr_Linux
@@ -1,4 +1,4 @@
-# $NetBSD: subr_Linux,v 1.1 2007/08/20 11:21:21 abs Exp $
+# $NetBSD: subr_Linux,v 1.2 2008/12/10 23:27:17 abs Exp $
AWK=awk
SED=sed
@@ -32,37 +32,29 @@ determine_arch()
parisc) case $hw_model in
"Mirage 100+") ARCH='-march=1.1' ;;
esac ;;
- i386) ARCH='-march=i386' ;;
- i486) ARCH='-march=i486' ;;
- i586) ARCH='-march=pentium' ;;
- i686) case $hw_model in
+ i386) ARCH='-march=i386' ;;
+ i486) ARCH='-march=i486' ;;
+ i586) ARCH='-march=pentium' ;;
+ i686 | x86_64)
+ include subr_x86 # this provides map_x86_brand_string()
+ ARCH=$(map_x86_brand_string "$cpu_brand")
+ if [ -z "$ARCH" ] ; then
+ case $hw_model in
"AMD Athlon(TM) XP "*) ARCH='-march=athlon-xp' ;;
+ "AMD Athlon(tm) 64"*) ARCH='-march=athlon64' ;;
"AMD Athlon(tm) XP"*) ARCH='-march=athlon-xp' ;;
- "AMD Duron(TM)") ARCH='-march=athlon' ;;
- "AMD Duron(tm) ") ARCH='-march=athlon' ;;
- "Pentium II (Deschutes)") ARCH='-march=pentium2' ;;
- "Celeron (Coppermine)") ARCH='-march=pentium3' ;;
- "Intel(R) Pentium(R) 4 CPU "*) ARCH='-march=pentium4' ;;
- "Intel(R) Pentium(R) III Mobile CPU"*) ARCH='-march=pentium3m' ;;
- "Intel(R) Pentium(R) M processor"*) ARCH='-march=pentium3m' ;;
- "Mobile Intel(R) Pentium(R) 4 - M "*) ARCH='-march=pentium4m' ;;
- "Pentium III (Coppermine)") ARCH='-march=pentium3' ;;
- "Pentium III (Katmai)") ARCH='-march=pentium3' ;;
- "AMD Athlon(tm) 64"*) ARCH='-march=athlon-xp' ;;
+ "AMD Duron(TM)") ARCH='-march=athlon' ;;
+ "AMD Duron(tm) ") ARCH='-march=athlon' ;;
"AMD Opteron(tm) Processor "*) ARCH='-march=opteron' ;;
- "Intel(R) Celeron(R) CPU "* | "Intel(R) Xeon(TM) CPU "*)
- case "$feat_flags" in
- *" sse2 "*)
- ARCH='-march=pentium4' ;;
- esac;;
"AMD Sempron(tm) Processor "*) ARCH='-march=athlon-xp' ;;
- "Intel(R) Core(TM)2 CPU "*) ARCH='-march=prescott' ;;
- esac ;;
- x86_64) case $hw_model in
- "AMD Sempron(tm) Processor "*) ARCH='-march=athlon64' ;;
- "AMD Athlon(tm) 64"*) ARCH='-march=athlon64' ;;
- "Intel(R) Core(TM)2 CPU "*) ARCH='-march=nocona' ;;
- esac ;;
+
+ # Intel PIII & earlier - later Intel handled by map_x86_brand_string
+ "Celeron (Coppermine)") ARCH='-march=pentium3' ;;
+ "Pentium II (Deschutes)") ARCH='-march=pentium2' ;;
+ "Pentium III (Coppermine)") ARCH='-march=pentium3' ;;
+ "Pentium III (Katmai)") ARCH='-march=pentium3' ;;
+ esac
+ fi ;;
esac
echo $ARCH
}
diff --git a/devel/cpuflags/files/subr_NetBSD b/devel/cpuflags/files/subr_NetBSD
index 2af3a910483..06cd26a0b10 100755
--- a/devel/cpuflags/files/subr_NetBSD
+++ b/devel/cpuflags/files/subr_NetBSD
@@ -1,4 +1,4 @@
-# $NetBSD: subr_NetBSD,v 1.7 2008/12/08 19:46:59 abs Exp $
+# $NetBSD: subr_NetBSD,v 1.8 2008/12/10 23:27:17 abs Exp $
AWK=awk
SED=sed
@@ -12,13 +12,14 @@ hw.model : '$hw_model'
hw.machine : '$hw_machine'
hw.machine_arch : '$hw_machine_arch'
CPU : '$cpu'
-$cpu_details
END
+ extract_x86_cpu_vars
+ echo "$cpu_details"
}
extract_hw_details()
{
- hw_model=$(sysctl -n hw.model | sed 's/^ *//')
+ hw_model=$(sysctl -n hw.model | $SED 's/^ *//')
hw_machine=$(sysctl -n hw.machine)
hw_machine_arch=$(sysctl -n hw.machine_arch)
if [ "$hw_machine_arch" = i386 -o "$hw_machine_arch" = x86_64 ] ; then
@@ -27,7 +28,7 @@ extract_hw_details()
else
cpu_details="$(grep ^cpu0: /var/run/dmesg.boot)"
fi
- cpu=$(echo "$cpu_details"|awk '/cpu0:/{sub("cpu0: ","");print;exit}')
+ eval $(extract_x86_cpu_vars)
fi
# We're almost certainly crosscompiling
@@ -37,6 +38,23 @@ extract_hw_details()
fi
}
+extract_x86_cpu_vars()
+ {
+ # Set: cpu_feature_FOO=1 for each 'FOO' feature reported
+ # cpu_name="NAME" taken from the first cpu0: line
+ # cpu_brand="BRAND" the CPU branding string
+ echo "$cpu_details" | $AWK -F , '
+ { if (/cpu0:/ && !n) { sub("cpu0: ",""); n=1; print "cpu_name=\""$0"\"" } }
+ /cpu0: ".*"/ { sub("[^\"]*", ""); print "cpu_brand="$0 }
+ /cpu0: features/ {
+ sub(".*<","");
+ sub(">.*","");
+ gsub("[^,A-Z0-9]","_");
+ for (i = 1; i < NR; i++) { print "cpu_feature_"$i"=1" }
+ }
+ '
+ }
+
determine_arch()
{
ARCH=
@@ -91,28 +109,30 @@ determine_arch()
;;
i386 | x86_64)
- case "$cpu" in
+ include subr_x86 # this provides map_x86_brand_string()
+ ARCH=$(map_x86_brand_string "$cpu_brand")
+ if [ -z "$ARCH" ] ; then
+ case "$cpu_name" in
'AMD Athlon 64 X2 (686-class)'*) ARCH='-march=athlon64' ;;
'AMD Athlon 64 or Athlon 64 FX or Opteron '*) ARCH='-march=opteron' ;;
'AMD Athlon 64 or Sempron (686-class)'*) ARCH='-march=athlon64' ;;
'AMD Athlon Model 4 (Thunderbird) '*) ARCH='-march=athlon-tbird' ;;
'AMD Dual-Core Opteron or Athlon 64 X2 '*) ARCH='-march=opteron' ;;
'AMD Family 10h (686-class)'*) ARCH='-march=amdfam10' ;;
+ 'AMD K6-2 (586-class)'*) ARCH="-march=k6-2" ;;
+
+ # Intel PIII & earlier - later Intel handled by map_x86_brand_string
'Intel (686-class)'*) ARCH='-march=pentiumpro' ;;
- 'Intel Celeron (686-class)'*) ARCH='-march=pentiumpro' ;;
- 'Intel Core 2 (Merom) (686-class)'*) ARCH='-march=core2' ;;
- 'Intel Pentium 4 (686-class)'*) ARCH='-march=pentium4' ;;
'Intel Pentium II (686-class)'*) ARCH='-march=pentium2' ;;
'Intel Pentium III (686-class)'*) ARCH='-march=pentium3' ;;
'Intel Pentium III (Katmai) (686-class)'*) ARCH='-march=pentium3' ;;
'Intel Pentium III Xeon (686-class)'*) ARCH='-march=pentium3' ;;
- 'Intel Pentium M (Dothan) (686-class)'*) ARCH='-march=pentium-m' ;;
- 'Intel Pentium M (Yonah) (686-class)'*) ARCH='-march=pentium-m' ;;
# Fallback classes
*'(586-class)'*) ARCH='-march=pentium' ;;
*'(486-class)'*) ARCH='-march=i486' ;;
esac
+ fi
;;
m68k) case $hw_model in # Examples
@@ -196,14 +216,6 @@ determine_features()
case $hw_machine_arch in
i386 | x86_64)
- # Set cpu_feature_FOO=1 for each 'FOO' feature reported
- eval $(echo "$cpu_details" | awk -F , '
- /cpu0: features/ {
- sub(".*<","");
- sub(">.*","");
- gsub("[^,A-Z0-9]","_");
- for (i = 1; i < NR; i++) { print "cpu_feature_"$i"=1" } }
- ')
if [ -n "$cpu_feature_SSE3" ] ; then
FEATURES="-mfpmath=sse -msse3"
elif [ -n "$cpu_feature_SSE2" ] ; then
diff --git a/devel/cpuflags/files/subr_SunOS b/devel/cpuflags/files/subr_SunOS
index 07beabd10a3..c6162baf9f1 100755
--- a/devel/cpuflags/files/subr_SunOS
+++ b/devel/cpuflags/files/subr_SunOS
@@ -1,4 +1,4 @@
-# $NetBSD: subr_SunOS,v 1.1 2007/08/20 11:21:21 abs Exp $
+# $NetBSD: subr_SunOS,v 1.2 2008/12/10 23:27:17 abs Exp $
AWK=nawk
SED=sed
@@ -15,7 +15,7 @@ END
extract_hw_details()
{
hw_arch=`/usr/bin/uname -m`
- hw_psrinfo=`psrinfo -v | $AWK 'NR==3{print}'` # Just gets the first CPU
+ hw_psrinfo=`psrinfo -pv | $AWK 'NR==3{print}'` # Just gets the first CPU
}
determine_arch()
@@ -26,9 +26,13 @@ determine_arch()
sun4m ) ARCH='-mcpu=supersparc' ;;
sun4u ) ARCH='-mcpu=v9' ;;
i86pc )
- case "$hw_psrinfo" in
- *AMD\ Opteron\(tm\)*) ARCH="-mcpu=opteron" ;;
- esac
+ include subr_x86 # this provides map_x86_brand_string()
+ ARCH=$(map_x86_brand_string "$cpu_brand")
+ if [ -z "$ARCH" ] ; then
+ case "$hw_psrinfo" in
+ *)
+ esac
+ fi
;;
esac
echo $ARCH
diff --git a/devel/cpuflags/files/subr_x86 b/devel/cpuflags/files/subr_x86
index b2596915a6f..ca17d4dc26d 100644
--- a/devel/cpuflags/files/subr_x86
+++ b/devel/cpuflags/files/subr_x86
@@ -1,4 +1,25 @@
-# $NetBSD: subr_x86,v 1.2 2007/08/27 10:09:22 abs Exp $
+# $NetBSD: subr_x86,v 1.3 2008/12/10 23:27:17 abs Exp $
+
+# Apparently the only way to reliably determine the architecture of a recent
+# Intel CPU is to use the cpu brand string - as they reused family and
+# extended family bitflags... annoying
+map_x86_brand_string()
+ {
+ case "$1" in
+ "Genuine Intel(R) CPU T2400"*) echo '-march=core2' ;;
+ "Intel(R) Celeron(R) CPU E1400"*) echo '-march=core2' ;;
+ "Intel(R) Celeron(R) CPU 2.40GHz") echo '-march=pentium4' ;;
+ "Intel(R) Core(TM)2 CPU "*) echo '-march=core2' ;;
+ "Intel(R) Core(TM)2 Duo CPU "*) echo '-march=core2' ;;
+ "Intel(R) Core(TM)2 Quad CPU"*) echo '-march=core2' ;;
+ "Intel(R) Pentium(R) 4 CPU 3.00GHz") echo '-march=prescott' ;;
+ "Intel(R) Pentium(R) D CPU "*) echo '-march=prescott' ;;
+ "Intel(R) Xeon(R) CPU 3040"*) echo '-march=core2' ;;
+ "Intel(R) Xeon(R) CPU 3050"*) echo '-march=core2' ;;
+ "Pentium(R) Dual-Core CPU E5200"*) echo '-march=core2' ;;
+
+ esac
+ }
flags_fixup_x86arch()
{