diff options
author | abs <abs@pkgsrc.org> | 2007-08-22 09:18:43 +0000 |
---|---|---|
committer | abs <abs@pkgsrc.org> | 2007-08-22 09:18:43 +0000 |
commit | 0d66d1b25c95259a07aeb4162a7edc9528ec53b7 (patch) | |
tree | 168144f913c503e04ef85b742b4c97e40a544fa9 /devel/cpuflags | |
parent | a50543dc979d2f0c287e04dcc69f93c281407708 (diff) | |
download | pkgsrc-0d66d1b25c95259a07aeb4162a7edc9528ec53b7.tar.gz |
add file missing in 1.12 - noted by tron
Diffstat (limited to 'devel/cpuflags')
-rw-r--r-- | devel/cpuflags/files/subr_FreeBSD | 80 |
1 files changed, 80 insertions, 0 deletions
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 <<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=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 + } |