Mercurial > mplayer.hg
comparison configure @ 10662:5cf84c487446
Reworked the CPU optimization detection code, now it works nice for non-x86 platforms aswell (tested on Alpha, PPC, x86)
author | alex |
---|---|
date | Mon, 18 Aug 2003 14:24:29 +0000 |
parents | c5e7b34bfc19 |
children | c6c54f467984 |
comparison
equal
deleted
inserted
replaced
10661:49d7d02f4485 | 10662:5cf84c487446 |
---|---|
553 if test "$_as" = auto ; then | 553 if test "$_as" = auto ; then |
554 _as=`$_cc -print-prog-name=as` | 554 _as=`$_cc -print-prog-name=as` |
555 test -z "$_as" && _as=as | 555 test -z "$_as" && _as=as |
556 fi | 556 fi |
557 | 557 |
558 # Try to find the available options for the current CPU | 558 # XXX: this should be ok.. |
559 if x86 || ppc; then | 559 _cpuinfo="echo" |
560 if test -r /proc/cpuinfo ; then | 560 if test -r /proc/cpuinfo ; then |
561 # Linux with /proc mounted, extract CPU information from it | 561 # Linux with /proc mounted, extract CPU information from it |
562 _cpuinfo="cat /proc/cpuinfo" | 562 _cpuinfo="cat /proc/cpuinfo" |
563 elif test -r /compat/linux/proc/cpuinfo ; then | 563 elif test -r /compat/linux/proc/cpuinfo ; then |
564 # FreeBSD with Linux emulation /proc mounted, | 564 # FreeBSD with Linux emulation /proc mounted, |
565 # extract CPU information from it | 565 # extract CPU information from it |
566 _cpuinfo="cat /compat/linux/proc/cpuinfo" | 566 _cpuinfo="cat /compat/linux/proc/cpuinfo" |
567 elif x86; then | 567 elif x86; then |
568 # all other OSes try to extract CPU information from a small helper | 568 # all other OSes try to extract CPU information from a small helper |
569 # program TOOLS/cpuinfo instead | 569 # program TOOLS/cpuinfo instead |
570 $_cc -o TOOLS/cpuinfo TOOLS/cpuinfo.c | 570 $_cc -o TOOLS/cpuinfo TOOLS/cpuinfo.c |
571 _cpuinfo="TOOLS/cpuinfo" | 571 _cpuinfo="TOOLS/cpuinfo" |
572 fi | 572 fi |
573 | |
574 case "$host_arch" in | |
575 i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) | |
576 _def_arch="#define ARCH_X86 1" | |
577 _target_arch="TARGET_ARCH_X86 = yes" | |
573 | 578 |
574 pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` | 579 pname=`$_cpuinfo | grep 'model name' | cut -d ':' -f 2 | head -1` |
575 pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` | 580 pvendor=`$_cpuinfo | grep 'vendor_id' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` |
576 pfamily=`$_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` | 581 pfamily=`$_cpuinfo | grep 'cpu family' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` |
577 pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` | 582 pmodel=`$_cpuinfo | grep -v 'model name' | grep 'model' | cut -d ':' -f 2 | cut -d ' ' -f 2 | head -1` |
587 _3dnowex=no | 592 _3dnowex=no |
588 _mmx2=no | 593 _mmx2=no |
589 _sse=no | 594 _sse=no |
590 _sse2=no | 595 _sse2=no |
591 _mtrr=no | 596 _mtrr=no |
592 _altivec=no | |
593 | 597 |
594 for i in $pparam ; do | 598 for i in $pparam ; do |
595 case "$i" in | 599 case "$i" in |
596 3dnow) _3dnow=yes ;; | 600 3dnow) _3dnow=yes ;; |
597 3dnowext) _3dnow=yes _3dnowex=yes ;; | 601 3dnowext) _3dnow=yes _3dnowex=yes ;; |
598 mmx) _mmx=yes ;; | 602 mmx) _mmx=yes ;; |
599 altivec) _altivec=yes ;; | |
600 mmxext) _mmx2=yes ;; | 603 mmxext) _mmx2=yes ;; |
601 mtrr|k6_mtrr|cyrix_arr) _mtrr=yes ;; | 604 mtrr|k6_mtrr|cyrix_arr) _mtrr=yes ;; |
602 xmm|sse|kni) _sse=yes _mmx2=yes ;; | 605 xmm|sse|kni) _sse=yes _mmx2=yes ;; |
603 sse2) _sse2=yes ;; | 606 sse2) _sse2=yes ;; |
604 esac | 607 esac |
607 echocheck "CPU vendor" | 610 echocheck "CPU vendor" |
608 echores "$pvendor ($pfamily:$pmodel:$pstepping)" | 611 echores "$pvendor ($pfamily:$pmodel:$pstepping)" |
609 | 612 |
610 echocheck "CPU type" | 613 echocheck "CPU type" |
611 echores "$pname" | 614 echores "$pname" |
612 | |
613 # leaving this here because of the non-x86 optimizations | |
614 if test "$_runtime_cpudetection" = yes ; then | |
615 if x86; then | |
616 _mmx=yes | |
617 _3dnow=yes | |
618 _3dnowex=yes | |
619 _mmx2=yes | |
620 _sse=yes | |
621 _sse2=yes | |
622 _mtrr=yes | |
623 fi | |
624 _optimizing="Runtime CPU-Detection enabled" | |
625 fi | |
626 | |
627 fi | |
628 | |
629 | |
630 if [ "$host_arch" = alpha ]; then | |
631 echocheck "CPU type" | |
632 cat > $TMPC << EOF | |
633 int main() { | |
634 unsigned long ver, mask; | |
635 asm ("implver %0" : "=r" (ver)); | |
636 asm ("amask %1, %0" : "=r" (mask) : "r" (-1)); | |
637 printf("%ld-%x\n", ver, ~mask); | |
638 return 0; | |
639 } | |
640 EOF | |
641 $_cc -o "$TMPO" "$TMPC" | |
642 case `"$TMPO"` in | |
643 0-0) proc="ev4" ;; | |
644 1-0) proc="ev5" ;; | |
645 1-1) proc="ev56" ;; | |
646 1-101) proc="pca56" ;; | |
647 2-303) proc="ev6" ;; | |
648 2-307) proc="ev67" ;; | |
649 2-1307) proc="ev68" ;; | |
650 esac | |
651 echores "$proc" | |
652 fi | |
653 | |
654 | |
655 # x86/x86pc is used by QNX | |
656 case "$host_arch" in | |
657 i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686) | |
658 _def_arch="#define ARCH_X86 1" | |
659 _target_arch="TARGET_ARCH_X86 = yes" | |
660 | 615 |
661 case "$pvendor" in | 616 case "$pvendor" in |
662 AuthenticAMD) | 617 AuthenticAMD) |
663 case "$pfamily" in | 618 case "$pfamily" in |
664 3) proc=i386 iproc=386 ;; | 619 3) proc=i386 iproc=386 ;; |
827 _target_arch='TARGET_ARCH_IA64 = yes' | 782 _target_arch='TARGET_ARCH_IA64 = yes' |
828 iproc='ia64' | 783 iproc='ia64' |
829 proc='' | 784 proc='' |
830 _march='' | 785 _march='' |
831 _mcpu='' | 786 _mcpu='' |
787 _optimizing='' | |
832 ;; | 788 ;; |
833 | 789 |
834 x86_64) | 790 x86_64) |
835 _def_arch='#define ARCH_X86_64 1' | 791 _def_arch='#define ARCH_X86_64 1' |
836 _target_arch='TARGET_ARCH_X86_64 = yes' | 792 _target_arch='TARGET_ARCH_X86_64 = yes' |
837 iproc='x86_64' | 793 iproc='x86_64' |
838 proc='' | 794 proc='' |
839 _march='' | 795 _march='' |
840 _mcpu='' | 796 _mcpu='' |
797 _optimizing='' | |
841 ;; | 798 ;; |
842 | 799 |
843 sparc) | 800 sparc) |
844 _def_arch='#define ARCH_SPARC 1' | 801 _def_arch='#define ARCH_SPARC 1' |
845 _target_arch='TARGET_ARCH_SPARC = yes' | 802 _target_arch='TARGET_ARCH_SPARC = yes' |
846 iproc='sparc' | 803 iproc='sparc' |
847 proc='v8' | 804 proc='v8' |
848 _march='' | 805 _march='' |
849 _mcpu="-mcpu=$proc" | 806 _mcpu="-mcpu=$proc" |
807 _optimizing="$proc" | |
850 ;; | 808 ;; |
851 | 809 |
852 arm|armv4l|armv5tel) | 810 arm|armv4l|armv5tel) |
853 _def_arch='#define ARCH_ARMV4L 1' | 811 _def_arch='#define ARCH_ARMV4L 1' |
854 _target_arch='TARGET_ARCH_ARMV4L = yes' | 812 _target_arch='TARGET_ARCH_ARMV4L = yes' |
855 iproc=arm | 813 iproc='arm' |
856 proc='' | 814 proc='' |
857 _march='' | 815 _march='' |
858 _mcpu='' | 816 _mcpu='' |
817 _optimizing='' | |
859 ;; | 818 ;; |
860 | 819 |
861 ppc) | 820 ppc) |
862 _def_arch='#define ARCH_POWERPC 1' | 821 _def_arch='#define ARCH_POWERPC 1' |
863 _target_arch='TARGET_ARCH_POWERPC = yes' | 822 _target_arch='TARGET_ARCH_POWERPC = yes' |
864 iproc='ppc' | 823 iproc='ppc' |
865 proc='' | 824 proc='' |
866 _march='' | 825 _march='' |
867 _mcpu='' | 826 _mcpu='' |
827 _altivec=no | |
868 _altivec_gcc_flags='' | 828 _altivec_gcc_flags='' |
869 # XXX: this should be removed imho... | 829 |
870 cpu750=`$_cpuinfo | grep "cpu.*750"` | 830 echocheck "CPU type" |
871 if test -n "$cpu750"; then | 831 if linux && test -n "$_cpuinfo"; then |
872 _march='-mcpu=750' | |
873 _mcpu='-mtune=750' | |
874 fi | |
875 if linux ; then | |
876 proc=`$_cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -b 2- | head -1` | 832 proc=`$_cpuinfo | grep 'cpu' | cut -d ':' -f 2 | cut -d ',' -f 1 | cut -b 2- | head -1` |
877 if test -n "`$_cpuinfo | grep altivec`"; then | 833 if test -n "`$_cpuinfo | grep altivec`"; then |
878 _altivec=yes | 834 _altivec=yes |
879 _altivec_gcc_flags='-maltivec -mabi=altivec' | 835 _altivec_gcc_flags='-maltivec -mabi=altivec' |
880 fi | 836 fi |
883 if [ `sysctl -n hw.vectorunit` -eq 1 ]; then | 839 if [ `sysctl -n hw.vectorunit` -eq 1 ]; then |
884 _altivec=yes | 840 _altivec=yes |
885 _altivec_gcc_flags='-faltivec' | 841 _altivec_gcc_flags='-faltivec' |
886 fi | 842 fi |
887 fi | 843 fi |
844 echores "$proc" | |
845 | |
846 echocheck "GCC & CPU optimization abilities" | |
888 if test -n "$proc"; then | 847 if test -n "$proc"; then |
889 case "$proc" in | 848 case "$proc" in |
890 601) _march='-mcpu=601' _mcpu='-mtune=601' ;; | 849 601) _march='-mcpu=601' _mcpu='-mtune=601' ;; |
891 603) _march='-mcpu=603' _mcpu='-mtune=603' ;; | 850 603) _march='-mcpu=603' _mcpu='-mtune=603' ;; |
892 603e|603ev) _march='-mcpu=603e' _mcpu='-mtune=603e' ;; | 851 603e|603ev) _march='-mcpu=603e' _mcpu='-mtune=603e' ;; |
902 7450*) _march='-mcpu=7450' _mcpu='-mtune=7450' ;; | 861 7450*) _march='-mcpu=7450' _mcpu='-mtune=7450' ;; |
903 *) ;; | 862 *) ;; |
904 esac | 863 esac |
905 fi | 864 fi |
906 fi | 865 fi |
866 echores "$proc" | |
867 | |
868 _optimizing="$proc" | |
869 | |
907 _mcpu="$_mcpu $_altivec_gcc_flags" | 870 _mcpu="$_mcpu $_altivec_gcc_flags" |
908 ;; | 871 ;; |
909 | 872 |
910 alpha) | 873 alpha) |
911 _def_arch='#define ARCH_ALPHA 1' | 874 _def_arch='#define ARCH_ALPHA 1' |
912 _target_arch='TARGET_ARCH_ALPHA = yes' | 875 _target_arch='TARGET_ARCH_ALPHA = yes' |
913 iproc='alpha' | 876 iproc='alpha' |
914 _march='' | 877 _march='' |
878 | |
879 echocheck "CPU type" | |
880 cat > $TMPC << EOF | |
881 int main() { | |
882 unsigned long ver, mask; | |
883 asm ("implver %0" : "=r" (ver)); | |
884 asm ("amask %1, %0" : "=r" (mask) : "r" (-1)); | |
885 printf("%ld-%x\n", ver, ~mask); | |
886 return 0; | |
887 } | |
888 EOF | |
889 $_cc -o "$TMPO" "$TMPC" | |
890 case `"$TMPO"` in | |
891 0-0) proc="ev4" ;; | |
892 1-0) proc="ev5" ;; | |
893 1-1) proc="ev56" ;; | |
894 1-101) proc="pca56" ;; | |
895 2-303) proc="ev6" ;; | |
896 2-307) proc="ev67" ;; | |
897 2-1307) proc="ev68" ;; | |
898 esac | |
899 echores "$proc" | |
900 | |
915 echocheck "GCC & CPU optimization abilities" | 901 echocheck "GCC & CPU optimization abilities" |
916 if test "$proc" = "ev68" ; then | 902 if test "$proc" = "ev68" ; then |
917 cc_check -mcpu=$proc || proc=ev67 | 903 cc_check -mcpu=$proc || proc=ev67 |
918 fi | 904 fi |
919 if test "$proc" = "ev67" ; then | 905 if test "$proc" = "ev67" ; then |
920 cc_check -mcpu=$proc || proc=ev6 | 906 cc_check -mcpu=$proc || proc=ev6 |
921 fi | 907 fi |
922 _mcpu="-mcpu=$proc" | 908 _mcpu="-mcpu=$proc" |
923 echores "$proc" | 909 echores "$proc" |
910 | |
911 _optimizing="$proc" | |
924 | 912 |
925 echocheck "MVI instruction support in GCC" | 913 echocheck "MVI instruction support in GCC" |
926 if test "$_cc_major" -ge "3"; then | 914 if test "$_cc_major" -ge "3"; then |
927 _def_gcc_mvi_support="#define CAN_COMPILE_ALPHA_MVI 1" | 915 _def_gcc_mvi_support="#define CAN_COMPILE_ALPHA_MVI 1" |
928 echores "yes" | 916 echores "yes" |
937 _target_arch='TARGET_ARCH_SGI_MIPS = yes' | 925 _target_arch='TARGET_ARCH_SGI_MIPS = yes' |
938 iproc='sgi-mips' | 926 iproc='sgi-mips' |
939 proc='' | 927 proc='' |
940 _march='' | 928 _march='' |
941 _mcpu='' | 929 _mcpu='' |
930 _optimizing='' | |
942 ;; | 931 ;; |
943 | 932 |
944 hppa) | 933 hppa) |
945 _def_arch='#define ARCH_PA_RISC 1' | 934 _def_arch='#define ARCH_PA_RISC 1' |
946 _target_arch='TARGET_ARCH_PA_RISC = yes' | 935 _target_arch='TARGET_ARCH_PA_RISC = yes' |
947 iproc='PA-RISC' | 936 iproc='PA-RISC' |
948 proc='' | 937 proc='' |
949 _march='' | 938 _march='' |
950 _mcpu='' | 939 _mcpu='' |
940 _optimizing='' | |
951 ;; | 941 ;; |
952 | 942 |
953 s390) | 943 s390) |
954 _def_arch='#define ARCH_S390 1' | 944 _def_arch='#define ARCH_S390 1' |
955 _target_arch='TARGET_ARCH_S390 = yes' | 945 _target_arch='TARGET_ARCH_S390 = yes' |
956 iproc='390' | 946 iproc='390' |
957 proc='' | 947 proc='' |
958 _march='' | 948 _march='' |
959 _mcpu='' | 949 _mcpu='' |
950 _optimizing='' | |
960 ;; | 951 ;; |
961 | 952 |
962 s390x) | 953 s390x) |
963 _def_arch='#define ARCH_S390X 1' | 954 _def_arch='#define ARCH_S390X 1' |
964 _target_arch='TARGET_ARCH_S390X = yes' | 955 _target_arch='TARGET_ARCH_S390X = yes' |
965 iproc='390x' | 956 iproc='390x' |
966 proc='' | 957 proc='' |
967 _march='' | 958 _march='' |
968 _mcpu='' | 959 _mcpu='' |
960 _optimizing='' | |
969 ;; | 961 ;; |
970 | 962 |
971 *) | 963 *) |
972 echo "The architecture of your CPU ($host_arch) is not supported by this configure script" | 964 echo "The architecture of your CPU ($host_arch) is not supported by this configure script" |
973 echo "It seems nobody has ported MPlayer to your OS or CPU type yet." | 965 echo "It seems nobody has ported MPlayer to your OS or CPU type yet." |
974 die "unsupported architecture $host_arch" | 966 die "unsupported architecture $host_arch" |
975 ;; | 967 ;; |
976 esac | 968 esac |
977 | 969 |
970 if test "$_runtime_cpudetection" = yes ; then | |
971 if x86; then | |
972 _mmx=yes | |
973 _3dnow=yes | |
974 _3dnowex=yes | |
975 _mmx2=yes | |
976 _sse=yes | |
977 _sse2=yes | |
978 _mtrr=yes | |
979 fi | |
980 _optimizing="Runtime CPU-Detection enabled" | |
981 fi | |
978 | 982 |
979 if x86 && test "$_runtime_cpudetection" = no ; then | 983 if x86 && test "$_runtime_cpudetection" = no ; then |
980 extcheck() { | 984 extcheck() { |
981 if test "$1" = yes ; then | 985 if test "$1" = yes ; then |
982 echocheck "kernel support of $2" | 986 echocheck "kernel support of $2" |