⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpuinfo.sh

📁 Motion JPEG编解码器源代码
💻 SH
字号:
#!/bin/shif test x"$CC" = x; then   CC=gccfiif test $# -ne 1; then   echo "Please give the arch (ppc or x86) as an argument!" 1>&2   exit 1fiif test `uname -s` = Darwin; then   IsDarwin=yeselse   IsDarwin=nofitarget=$1cc_version=`$CC -dumpversion`_cc_major=`echo $cc_version | cut -d'.' -f1`_cc_minor=`echo $cc_version | cut -d'.' -f2`if test $_cc_major -ge 4; then  _opt_mcpu="-mtune"else  _opt_mcpu="-mcpu"fido_cc(){	$CC -o conftest conftest.c $@ >/dev/null 2>&1}extcheck(){cat > conftest.c <<EOF#include <signal.h>void catch() { exit(1); }int main(void){  signal(SIGILL, catch);  __asm__ __volatile__ ("$1":::"memory");  exit(0);}EOFdo_ccif test -x ./conftest; then     ./conftest     if test $? -ne 0; then        return 1     fi     return 0else     return 1fi}do_x86(){if test -r /proc/cpuinfo; then	_cpuinfo="cat /proc/cpuinfo"else	$CC -o cpuinfo utils/cpuinfo.c	_cpuinfo="./cpuinfo"fi# Cpu determination logic adapted from the MPlayer configure script.pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1`pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d':' -f2 | cut -d' ' -f2 | head -1`pfamily=`$_cpuinfo | grep 'cpu family' | cut -d':' -f2 | cut -d' ' -f2 | head -1`pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d':' -f2 | cut -d' ' -f2 | head -1`pstep=`$_cpuinfo | grep 'stepping' | cut -d':' -f2 | cut -d' ' -f2 | head -1`pparam=`$_cpuinfo | grep 'features' | cut -d':' -f2 | head -1`if test -z "$pparam" ; then pparam=`$_cpuinfo | grep 'flags' | cut -d ':' -f 2 | head -1`fi_mmx=no_3dnow=no_3dnowex=no_mmx2=no_sse=no_sse2=no_mtrr=nofor i in $pparam ; do case "$i" in  3dnow)        _3dnow=yes               ;;  3dnowext)     _3dnow=yes  _3dnowex=yes ;;  mmx)          _mmx=yes                 ;;  mmxext)       _mmx2=yes                ;;  mtrr|k6_mtrr|cyrix_arr)   _mtrr=yes    ;;  xmm|sse|kni)  _sse=yes    _mmx2=yes    ;;  sse2)         _sse2=yes                ;; esacdonecase "$pvendor" in	AuthenticAMD)		case "$pfamily" in			3)proc=i386			  ;;			4) proc=i486			  ;;			5) iproc=586			# models are: K5/SSA5 K5 K5 K5 ? ? K6 K6 K6-2 K6-3			# K6 model 13 are the K6-2+ and K6-III+			   if test "$pmodel" -eq 9 -o "$pmodel" -eq 13; then				proc=k6-3			   elif test "$pmodel" -ge 8; then				proc=k6-2			   elif test "$pmodel" -ge 6; then				proc=k6			   else				proc=i586			   fi			   ;;			6) iproc=686			   if test "$pmodel" -ge 7; then				proc=athlon-4			   elif test "$pmodel" -ge 6; then			       if test "$_sse" = yes && test "$pstep" -ge 2; then				   proc=athlon-xp			       else				   proc=athlon-4			       fi			   elif test "$pmodel" -ge 4; then				proc=athlon-tbird			   else				proc=athlon			   fi			   ;;			15) 			    # Despite what the gcc into says 'athlon64' is not accepted as 			    # synonym for 'k8'			   proc=k8			   ;;			*) proc=athlon-xp			   ;;		esac		;;	GenuineIntel)		case "$pfamily" in			3) proc=i386			   ;;			4) proc=i486			   ;;			5) iproc=586			   if test "$pmodel" -eq 4 || test "$pmodel" -eq 8; then				proc=pentium-mmx # 4 is desktop, 8 is mobile			   else				proc=i586			   fi			   ;;			6) iproc=686			   if test "$pmodel" -ge 7; then				proc=pentium3			   elif test "$pmodel" -ge 3; then				proc=pentium2			   else				proc=i686			   fi			   ;;			15) proc=pentium4			   ;;			*) proc=pentium4			   ;;		esac		;;	unknown)		case "$pfamily" in			3) proc=i386			   ;;			4) proc=i486			   ;;			*) proc=i586			   ;;  		esac		;;	*)	   proc=i586	   ;;esac# check that gcc supports our CPU, if not, fall back to earlier onescat > conftest.c << EOFint main(void) { return 0; }EOFif  test "$proc" = "athlon64" ; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=athlon-xpfiif test "$proc" = "athlon-xp" || test "$proc" = "athlon-4" || test "$proc" = "athlon-tbird"; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=athlonfiif test "$proc" = "k6-3" || test "$proc" = "k6-2"; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=k6fiif test "$proc" = "k6"; then    do_cc -march=$proc $_opt_mcpu=$proc    if test $? -ne 0; then        if do_cc -march=i586 $_opt_mcpu=i686; then          proc=i586-i686        else           proc=i586	fi    fifiif test "$proc" = "pentium4" || test "$proc" = "pentium3" || test "$proc" = "pentium2" || test "$proc" = "athlon"; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=i686fiif test "$proc" = "i686" || test "$proc" = "pentium-mmx"; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=i586fiif test "$proc" = "i586" ; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=i486fiif test "$proc" = "i486" ; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=i386fiif test "$proc" = "i386" ; then	do_cc -march=$proc $_opt_mcpu=$proc || proc=errorfiif test "$proc" = "error" ; then	echo "Your $_cc does not even support \"i386\" for '-march' and '$_opt_mcpu'."	_mcpu=""	_march=""elif test "$proc" = "i586-i686"; then	_march="-march=i586"	_mcpu="$_opt_mcpu=i686"else      _march="-march=$proc"      _mcpu="$_opt_mcpu=$proc"fiif test $_cc_major -ge 3; then   extcheck "xorps %%xmm0, %%xmm0" || _gcc3_ext="$_gcc3_ext -mno-sse"   extcheck "xorpd %%xmm0, %%xmm0" || _gcc3_ext="$_gcc3_ext -mno-sse2"   if test x"$_gcc3_ext" != "x"; then    # if we had to disable sse/sse2 because the active kernel does not    # support this instruction set extension, we also have to tell    # gcc3 to not generate sse/sse2 instructions for normal C code    cat > conftest.c << EOFint main(void) { return 0; }EOF    do_cc $_march $_gcc3_ext && _march="$_march $_gcc3_ext"   fifiecho $_march $_mcpurm -f conftest.c conftest cpuinforeturn 0}do_ppc(){# Linux on a PPC has /proc/info# Darwin (OS/X) has the hostinfo command# If neither of those we have no idea what to do - so do nothing.if test -r /proc/cpuinfo; then	proc=`grep cpu /proc/cpuinfo | cut -d':' -f2 | cut -d',' -f1 | cut -b 2- | head -1`elif test $IsDarwin = yes; then	proc=`hostinfo | grep "Processor type" | cut -f3 -d' ' | sed 's/ppc//'`else	return 0ficase "$proc" in	601) _march='$_opt_mcpu=601' _mcpu='-mtune=601'	     ;;	603) _march='$_opt_mcpu=603' _mcpu='-mtune=603'	     ;;	603e|603ev) _march='$_opt_mcpu=603e' _mcpu='-mtune=603e'	     ;;	604|604e|604r|604ev) _march='$_opt_mcpu=604' _mcpu='-mtune=604'	     ;;	740|740/750|745/755) _march='$_opt_mcpu=740' _mcpu='-mtune=740'	     ;;	750|750CX) _march='$_opt_mcpu=750' _mcpu='-mtune=750'	     ;;	*) ;;esac# gcc 3.1(.1) and up supports 7400 and 7450if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "1" || test "$_cc_major" -ge "4"; then	case "$proc" in		7400*|7410*) _march='$_opt_mcpu=7400' _mcpu='-mtune=7400' ;;		7450*|7455*) _march='$_opt_mcpu=7450' _mcpu='-mtune=7450' ;;		*) ;;	esacfi# gcc 3.2 and up supports 970if test "$_cc_major" -ge "3" && test "$_cc_minor" -ge "3" || test "$_cc_major" -ge "4"; then	case "$proc" in	     970*) if test $IsDarwin = yes; then		      _march='$_opt_mcpu=G5 -mpowerpc64 -mpowerpc-gpopt -falign-loops=16' _mcpu='-mtune=G5'		   else		      _march='$_opt_mcpu=970' _mcpu='-mtune=970'		   fi		   ;;		*) ;;	esacfiecho $_march $_mcpureturn 0}## The script that runs the various functions above#if test $target = x86; then	do_x86elif test $target = ppc; then        do_ppcfi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -