annotate src/libsamplerate-0.1.8/M4/endian.m4 @ 83:ae30d91d2ffe

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