pkgsrc/devel/cpuflags/files/subr_Linux
abs b2e170707c 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
2008-12-10 23:27:17 +00:00

75 lines
2 KiB
Text
Executable file

# $NetBSD: subr_Linux,v 1.2 2008/12/10 23:27:17 abs Exp $
AWK=awk
SED=sed
display_hw_details()
{
cat <<END
OS : '$(uname)'
proc model : '$hw_model'
machine_arch : '$hw_machine_arch'
proc flag : '$feat_flags'
END
}
extract_hw_details()
{
hw_machine_arch=$(uname -m)
if [ ! -f /proc/cpuinfo ] ; then
echo "Unable to open /proc/cpuinfo"
hw_model=Unknown
else
hw_model=$($AWK -F: '/^model name/{sub(" ","",$2);print $2;exit}' /proc/cpuinfo)
feat_flags=$($AWK -F: '/^flags/{sub(" ","",$2);print $2;exit}' /proc/cpuinfo)
fi
}
determine_arch()
{
ARCH=
case $hw_machine_arch in
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 | 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' ;;
"AMD Opteron(tm) Processor "*) ARCH='-march=opteron' ;;
"AMD Sempron(tm) Processor "*) ARCH='-march=athlon-xp' ;;
# 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
}
determine_features()
{
FEATURES=
case $hw_machine_arch in
i586|i686|x86_64)
case " $feat_flags " in
*" ssse3 "*) FEATURES='-mfpmath=sse -msse3' ;;
*" sse2 "*) FEATURES='-mfpmath=sse -msse2' ;;
*" sse "*) FEATURES='-mfpmath=sse -msse' ;;
*" mmx "*) FEATURES='-mmmx' ;;
esac ;;
esac
echo $FEATURES
}