annotate src/libsamplerate-0.1.9/M4/endian.m4 @ 54:5f67a29f0fc7

Rebuild MAD with 64-bit FPM
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 30 Nov 2016 20:59:17 +0000
parents 481f5f8c5634
children
rev   line source
Chris@41 1 dnl @synopsis AC_C_FIND_ENDIAN
Chris@41 2 dnl
Chris@41 3 dnl Determine endian-ness of target processor.
Chris@41 4 dnl @version 1.1 Mar 03 2002
Chris@41 5 dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
Chris@41 6 dnl
Chris@41 7 dnl Majority written from scratch to replace the standard autoconf macro
Chris@41 8 dnl AC_C_BIGENDIAN. Only part remaining from the original it the invocation
Chris@41 9 dnl of the AC_TRY_RUN macro.
Chris@41 10 dnl
Chris@41 11 dnl Permission to use, copy, modify, distribute, and sell this file for any
Chris@41 12 dnl purpose is hereby granted without fee, provided that the above copyright
Chris@41 13 dnl and this permission notice appear in all copies. No representations are
Chris@41 14 dnl made about the suitability of this software for any purpose. It is
Chris@41 15 dnl provided "as is" without express or implied warranty.
Chris@41 16
Chris@41 17 dnl Find endian-ness in the following way:
Chris@41 18 dnl 1) Look in <endian.h>.
Chris@41 19 dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
Chris@41 20 dnl 3) If 1) and 2) fails and not cross compiling run a test program.
Chris@41 21 dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
Chris@41 22
Chris@41 23 AC_DEFUN([AC_C_FIND_ENDIAN],
Chris@41 24 [AC_CACHE_CHECK(processor byte ordering,
Chris@41 25 ac_cv_c_byte_order,
Chris@41 26
Chris@41 27 # Initialize to unknown
Chris@41 28 ac_cv_c_byte_order=unknown
Chris@41 29
Chris@41 30 if test x$ac_cv_header_endian_h = xyes ; then
Chris@41 31
Chris@41 32 # First try <endian.h> which should set BYTE_ORDER.
Chris@41 33
Chris@41 34 [AC_TRY_LINK([
Chris@41 35 #include <endian.h>
Chris@41 36 #if BYTE_ORDER != LITTLE_ENDIAN
Chris@41 37 not big endian
Chris@41 38 #endif
Chris@41 39 ], return 0 ;,
Chris@41 40 ac_cv_c_byte_order=little
Chris@41 41 )]
Chris@41 42
Chris@41 43 [AC_TRY_LINK([
Chris@41 44 #include <endian.h>
Chris@41 45 #if BYTE_ORDER != BIG_ENDIAN
Chris@41 46 not big endian
Chris@41 47 #endif
Chris@41 48 ], return 0 ;,
Chris@41 49 ac_cv_c_byte_order=big
Chris@41 50 )]
Chris@41 51
Chris@41 52 fi
Chris@41 53
Chris@41 54 if test $ac_cv_c_byte_order = unknown ; then
Chris@41 55
Chris@41 56 [AC_TRY_LINK([
Chris@41 57 #include <sys/types.h>
Chris@41 58 #include <sys/param.h>
Chris@41 59 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
Chris@41 60 bogus endian macros
Chris@41 61 #endif
Chris@41 62 ], return 0 ;,
Chris@41 63
Chris@41 64 [AC_TRY_LINK([
Chris@41 65 #include <sys/types.h>
Chris@41 66 #include <sys/param.h>
Chris@41 67 #if BYTE_ORDER != LITTLE_ENDIAN
Chris@41 68 not big endian
Chris@41 69 #endif
Chris@41 70 ], return 0 ;,
Chris@41 71 ac_cv_c_byte_order=little
Chris@41 72 )]
Chris@41 73
Chris@41 74 [AC_TRY_LINK([
Chris@41 75 #include <sys/types.h>
Chris@41 76 #include <sys/param.h>
Chris@41 77 #if BYTE_ORDER != LITTLE_ENDIAN
Chris@41 78 not big endian
Chris@41 79 #endif
Chris@41 80 ], return 0 ;,
Chris@41 81 ac_cv_c_byte_order=little
Chris@41 82 )]
Chris@41 83
Chris@41 84 )]
Chris@41 85
Chris@41 86 fi
Chris@41 87
Chris@41 88 if test $ac_cv_c_byte_order = unknown ; then
Chris@41 89 if test $cross_compiling = yes ; then
Chris@41 90 # This is the last resort. Try to guess the target processor endian-ness
Chris@41 91 # by looking at the target CPU type.
Chris@41 92 [
Chris@41 93 case "$target_cpu" in
Chris@41 94 alpha* | i?86* | mipsel* | ia64*)
Chris@41 95 ac_cv_c_byte_order=little
Chris@41 96 ;;
Chris@41 97
Chris@41 98 m68* | mips* | powerpc* | hppa* | sparc*)
Chris@41 99 ac_cv_c_byte_order=big
Chris@41 100 ;;
Chris@41 101
Chris@41 102 esac
Chris@41 103 ]
Chris@41 104 else
Chris@41 105 AC_TRY_RUN(
Chris@41 106 [[
Chris@41 107 int main (void)
Chris@41 108 { /* Are we little or big endian? From Harbison&Steele. */
Chris@41 109 union
Chris@41 110 { long l ;
Chris@41 111 char c [sizeof (long)] ;
Chris@41 112 } u ;
Chris@41 113 u.l = 1 ;
Chris@41 114 return (u.c [sizeof (long) - 1] == 1);
Chris@41 115 }
Chris@41 116 ]], , ac_cv_c_byte_order=big,
Chris@41 117 )
Chris@41 118
Chris@41 119 AC_TRY_RUN(
Chris@41 120 [[int main (void)
Chris@41 121 { /* Are we little or big endian? From Harbison&Steele. */
Chris@41 122 union
Chris@41 123 { long l ;
Chris@41 124 char c [sizeof (long)] ;
Chris@41 125 } u ;
Chris@41 126 u.l = 1 ;
Chris@41 127 return (u.c [0] == 1);
Chris@41 128 }]], , ac_cv_c_byte_order=little,
Chris@41 129 )
Chris@41 130 fi
Chris@41 131 fi
Chris@41 132
Chris@41 133 )
Chris@41 134
Chris@41 135 if test $ac_cv_c_byte_order = big ; then
Chris@41 136 ac_cv_c_big_endian=1
Chris@41 137 ac_cv_c_little_endian=0
Chris@41 138 elif test $ac_cv_c_byte_order = little ; then
Chris@41 139 ac_cv_c_big_endian=0
Chris@41 140 ac_cv_c_little_endian=1
Chris@41 141 else
Chris@41 142 ac_cv_c_big_endian=0
Chris@41 143 ac_cv_c_little_endian=0
Chris@41 144
Chris@41 145 AC_MSG_WARN([[*****************************************************************]])
Chris@41 146 AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]])
Chris@41 147 AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]])
Chris@41 148 AC_MSG_WARN([[*** src/config.h may need to be hand editied. ]])
Chris@41 149 AC_MSG_WARN([[*****************************************************************]])
Chris@41 150 fi
Chris@41 151
Chris@41 152 ]
Chris@41 153 )# AC_C_FIND_ENDIAN
Chris@41 154
Chris@41 155