From 0d66d1b25c95259a07aeb4162a7edc9528ec53b7 Mon Sep 17 00:00:00 2001 From: abs Date: Wed, 22 Aug 2007 09:18:43 +0000 Subject: add file missing in 1.12 - noted by tron --- devel/cpuflags/files/subr_FreeBSD | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 devel/cpuflags/files/subr_FreeBSD (limited to 'devel/cpuflags') diff --git a/devel/cpuflags/files/subr_FreeBSD b/devel/cpuflags/files/subr_FreeBSD new file mode 100644 index 00000000000..4276a120dab --- /dev/null +++ b/devel/cpuflags/files/subr_FreeBSD @@ -0,0 +1,80 @@ + +AWK=awk +SED=sed + +display_hw_details() + { + cat </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=prescott' ;; + 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 + } -- cgit v1.2.3