4be902b14c
Add initial powerpc support for Darwin
81 lines
2.1 KiB
Text
81 lines
2.1 KiB
Text
# $NetBSD: subr_FreeBSD,v 1.4 2010/12/05 11:19:39 abs Exp $
|
|
|
|
AWK=awk
|
|
SED=sed
|
|
|
|
display_hw_details()
|
|
{
|
|
cat <<END
|
|
OS : '$(uname)'
|
|
hw.model : '$hw_model'
|
|
hw.machine : '$hw_machine'
|
|
hw.machine_arch : '$hw_machine_arch'
|
|
cpu details :
|
|
END
|
|
$SED -n '/^CPU:/{N;N;N;N;N;N;N;s/\n[^ ].*//g;/\n /p;}' \
|
|
/var/run/dmesg.boot 2>/dev/null
|
|
}
|
|
|
|
extract_hw_details()
|
|
{
|
|
hw_model=$(sysctl -n hw.model | $SED 's/(R)//g;s/([tT][mM])//g')
|
|
hw_machine=$(sysctl -n hw.machine)
|
|
hw_machine_arch=$(sysctl -n hw.machine_arch)
|
|
|
|
# We're almost certainly crosscompiling
|
|
if [ -n "$MACHINE" -a "$hw_machine" != "$MACHINE" ]; then
|
|
echo
|
|
exit
|
|
fi
|
|
}
|
|
|
|
determine_arch()
|
|
{
|
|
ARCH=
|
|
# When adding $hw_model tests use maximum context (such as trailing space)
|
|
case $hw_machine_arch in
|
|
i386) case $hw_model in
|
|
Pentium\ II*) ARCH='-march=pentium2' ;;
|
|
Intel\ Pentium\ III\ *) ARCH='-march=pentium3' ;;
|
|
Intel\ Pentium\ 4\ *) ARCH='-march=pentium4' ;;
|
|
Intel\ Core2\ *) ARCH='-march=core2' ;;
|
|
AMD\ Athlon\ XP*) ARCH='-march=athlon-xp' ;;
|
|
AMD\ Sempron\ Processor\ *) ARCH='-march=athlon-xp' ;;
|
|
# last resort:
|
|
*386-class*) ARCH='-march=i386' ;;
|
|
*486-class*) ARCH='-march=i486' ;;
|
|
*586-class*) ARCH='-march=pentium' ;;
|
|
*686-class*) ARCH='-march=pentiumpro' ;;
|
|
esac ;;
|
|
amd64) case $hw_model in
|
|
AMD\ Sempron\ Processor\ *) ARCH='-march=athlon64' ;;
|
|
esac ;;
|
|
esac
|
|
|
|
echo $ARCH
|
|
}
|
|
|
|
determine_features()
|
|
{
|
|
FEATURES=
|
|
dmesg_features=$(echo $($SED -n \
|
|
's/.* Features[0-9]\{0,1\}=0x[0-9a-f]\{1,\}<\(.*\)>$/\1/p' \
|
|
/var/run/dmesg.boot 2>/dev/null | $SED 's/,/ /g'))
|
|
|
|
case $hw_machine_arch in
|
|
i386 | amd64) case " $dmesg_features " in
|
|
*" SSE3 "*) FEATURES="-mfpmath=sse -msse3" ;;
|
|
*" SSE2 "*) FEATURES="-mfpmath=sse -msse2" ;;
|
|
*" SSE "*) FEATURES="-mfpmath=sse -msse" ;;
|
|
*" MMX "*) FEATURES="-mmmx" ;;
|
|
esac
|
|
if [ -z "$FEATURES" ]; then # FEATURES empty: jail?
|
|
# failover: try sse from sysctl db
|
|
if [ "$(sysctl -n hw.instruction_sse 2>/dev/null)" = 1 ]; then
|
|
FEATURES="-mfpmath=sse -msse"
|
|
fi
|
|
fi
|
|
esac
|
|
|
|
echo $FEATURES
|
|
}
|