| 735 | # |
| 736 | # Check for endianness |
| 737 | # |
| 738 | echo_n "Checking endianness... " |
| 739 | cat <<EOF >tmp_endianness_check.cpp |
| 740 | short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; |
| 741 | short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; |
| 742 | void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; } |
| 743 | short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; |
| 744 | short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; |
| 745 | void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; } |
| 746 | int main() { _ascii (); _ebcdic (); return 0; } |
| 747 | EOF |
| 748 | $CXX $CXXFLAGS -c -o tmp_endianness_check.o tmp_endianness_check.cpp |
| 749 | if grep BIGenDianSyS tmp_endianness_check.o >/dev/null; then |
| 750 | _endian=big |
| 751 | else |
| 752 | _endian=little |
| 753 | fi |
| 754 | echo $_endian; |
| 755 | rm -f tmp_endianness_check.o tmp_endianness_check.cpp |
| 756 | |
| 757 | # |
| 758 | # Determine data type sizes |
| 759 | # TODO: proper error checking |
| 760 | # TODO: Actually, we should check individually for both signed & unsigned |
| 761 | # data types - there are systems on which the size of an unsigned int |
| 762 | # differs from that of a signed int! |
| 763 | # However, so far we haven't encountered one of those, so we can live with |
| 764 | # the limited check for now. |
| 765 | # |
| 766 | echo_n "Type with 1 byte... " |
| 767 | type_1_byte=`find_type_with_size 1` |
| 768 | echo "$type_1_byte" |
| 769 | |
| 770 | echo_n "Type with 2 bytes... " |
| 771 | type_2_byte=`find_type_with_size 2` |
| 772 | echo "$type_2_byte" |
| 773 | |
| 774 | echo_n "Type with 4 bytes... " |
| 775 | type_4_byte=`find_type_with_size 4` |
| 776 | echo "$type_4_byte" |
| 777 | |
| 778 | # |
| 779 | # Check whether we can use x86 asm routines |
| 780 | # |
| 781 | echo_n "Running on x86... " |
| 782 | case $_host_cpu in |
| 783 | i386|i486|i586|i686) |
| 784 | _have_x86=yes |
| 785 | ;; |
| 786 | *) |
| 787 | _have_x86=no |
| 788 | ;; |
| 789 | esac |
| 790 | echo "$_have_x86" |
| 791 | |
| 792 | # |
| 793 | # Determine build settings |
| 794 | # |
| 795 | # TODO - also add an command line option to override this?!? |
| 796 | echo_n "Checking hosttype... " |
| 797 | echo $_host_os |
| 798 | case $_host_os in |
| 799 | linux* | uclinux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* | beos*) |
| 800 | DEFINES="$DEFINES -DUNIX" |
| 801 | ;; |
| 802 | solaris*) |
| 803 | DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
| 804 | ;; |
| 805 | irix*) |
| 806 | DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
| 807 | LIBS="$LIBS -lmd " |
| 808 | _ranlib=: |
| 809 | ;; |
| 810 | darwin*) |
| 811 | DEFINES="$DEFINES -DUNIX -DMACOSX" |
| 812 | LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI" |
| 813 | ;; |
| 814 | mingw*) |
| 815 | DEFINES="$DEFINES -DWIN32" |
| 816 | LIBS="$LIBS -lmingw32 -lwinmm" |
| 817 | OBJS="$OBJS scummvmico.o" |
| 818 | ;; |
| 819 | cygwin*) |
| 820 | DEFINES="$DEFINES -mno-cygwin -DWIN32" |
| 821 | LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm" |
| 822 | OBJS="$OBJS scummvmico.o" |
| 823 | ;; |
| 824 | os2-emx*) |
| 825 | DEFINES="$DEFINES -DUNIX" |
| 826 | ;; |
| 827 | mint*) |
| 828 | DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
| 829 | ;; |
| 830 | # given this is a shell script assume some type of unix |
| 831 | *) |
| 832 | echo "WARNING: could not establish system type, assuming unix like" |
| 833 | DEFINES="$DEFINES -DUNIX" |
| 834 | ;; |
| 835 | esac |
| 836 | |
823 | | # Determine build settings |
824 | | # |
825 | | # TODO - also add an command line option to override this?!? |
826 | | echo_n "Checking hosttype... " |
827 | | echo $_host_os |
828 | | case $_host_os in |
829 | | linux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* | beos*) |
830 | | DEFINES="$DEFINES -DUNIX" |
831 | | ;; |
832 | | solaris*) |
833 | | DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
834 | | ;; |
835 | | irix*) |
836 | | DEFINES="$DEFINES -DUNIX -DIRIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
837 | | LIBS="$LIBS -lmd " |
838 | | _ranlib=: |
839 | | ;; |
840 | | darwin*) |
841 | | DEFINES="$DEFINES -DUNIX -DMACOSX" |
842 | | LIBS="$LIBS -framework QuickTime -framework AudioUnit -framework AudioToolbox -framework Carbon -framework CoreMIDI" |
843 | | ;; |
844 | | mingw*) |
845 | | DEFINES="$DEFINES -DWIN32" |
846 | | LIBS="$LIBS -lmingw32 -lwinmm" |
847 | | OBJS="$OBJS scummvmico.o" |
848 | | ;; |
849 | | cygwin*) |
850 | | DEFINES="$DEFINES -mno-cygwin -DWIN32" |
851 | | LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm" |
852 | | OBJS="$OBJS scummvmico.o" |
853 | | ;; |
854 | | os2-emx*) |
855 | | DEFINES="$DEFINES -DUNIX" |
856 | | ;; |
857 | | mint*) |
858 | | DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE" |
859 | | ;; |
860 | | # given this is a shell script assume some type of unix |
861 | | *) |
862 | | echo "WARNING: could not establish system type, assuming unix like" |
863 | | DEFINES="$DEFINES -DUNIX" |
864 | | ;; |
865 | | esac |
866 | | |
867 | | # |
868 | | # Check for endianness |
869 | | # |
870 | | echo_n "Checking endianness... " |
871 | | cat <<EOF >tmp_endianness_check.cpp |
872 | | #include <stdio.h> |
873 | | #include <stdlib.h> |
874 | | int main(int argc, char **argv) |
875 | | { |
876 | | unsigned int data = 0x01234567; |
877 | | char *ptr = (char *)&data; |
878 | | if (ptr[0] == 0x01 && ptr[1] == 0x23 && ptr[2] == 0x45 && ptr[3] == 0x67) |
879 | | printf("big\n"); |
880 | | else if (ptr[3] == 0x01 && ptr[2] == 0x23 && ptr[1] == 0x45 && ptr[0] == 0x67) |
881 | | printf("little\n"); |
882 | | else |
883 | | printf("unknown\n"); |
884 | | return 0; |
885 | | } |
886 | | EOF |
887 | | $CXX $CXXFLAGS -o tmp_endianness_check$EXEEXT tmp_endianness_check.cpp |
888 | | _endian=`./tmp_endianness_check` |
889 | | echo $_endian; |
890 | | rm -f tmp_endianness_check$EXEEXT tmp_endianness_check.cpp |
891 | | |
892 | | # |
893 | | # Check whether we can use x86 asm routines |
894 | | # |
895 | | echo_n "Running on x86... " |
896 | | case $_host_cpu in |
897 | | i386|i486|i586|i686) |
898 | | _have_x86=yes |
899 | | ;; |
900 | | *) |
901 | | _have_x86=no |
902 | | ;; |
903 | | esac |
904 | | echo "$_have_x86" |
905 | | |
906 | | # |
952 | | |
953 | | # |
954 | | # Determine data type sizes |
955 | | # TODO: proper error checking |
956 | | # TODO: Actually, we should check individually for both signed & unsigned |
957 | | # data types - there are systems on which the size of an unsigned int |
958 | | # differs from that of a signed int! |
959 | | # However, so far we haven't encountered one of those, so we can live with |
960 | | # the limited check for now. |
961 | | # |
962 | | echo_n "Type with 1 byte... " |
963 | | type_1_byte=`find_type_with_size 1` |
964 | | echo "$type_1_byte" |
965 | | |
966 | | echo_n "Type with 2 bytes... " |
967 | | type_2_byte=`find_type_with_size 2` |
968 | | echo "$type_2_byte" |
969 | | |
970 | | echo_n "Type with 4 bytes... " |
971 | | type_4_byte=`find_type_with_size 4` |
972 | | echo "$type_4_byte" |
973 | | |