| 1 | 
 | 
|---|
| 2 | AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START,
 | 
|---|
| 3 | [
 | 
|---|
| 4 | echo "LIBREPLACE_CC_CHECKS: START"
 | 
|---|
| 5 | ])
 | 
|---|
| 6 | 
 | 
|---|
| 7 | AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END,
 | 
|---|
| 8 | [
 | 
|---|
| 9 | echo "LIBREPLACE_CC_CHECKS: END"
 | 
|---|
| 10 | ])
 | 
|---|
| 11 | 
 | 
|---|
| 12 | dnl
 | 
|---|
| 13 | dnl
 | 
|---|
| 14 | dnl AC_LIBREPLACE_CC_CHECKS
 | 
|---|
| 15 | dnl
 | 
|---|
| 16 | dnl Note: we need to use m4_define instead of AC_DEFUN because
 | 
|---|
| 17 | dnl       of the ordering of tests
 | 
|---|
| 18 | dnl       
 | 
|---|
| 19 | dnl 
 | 
|---|
| 20 | m4_define(AC_LIBREPLACE_CC_CHECKS,
 | 
|---|
| 21 | [
 | 
|---|
| 22 | AC__LIBREPLACE_ONLY_CC_CHECKS_START
 | 
|---|
| 23 | 
 | 
|---|
| 24 | dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it
 | 
|---|
| 25 | dnl which conflicts with C99 on HPUX
 | 
|---|
| 26 | ac_cv_prog_cc_Ae=no
 | 
|---|
| 27 | 
 | 
|---|
| 28 | savedCFLAGS=$CFLAGS
 | 
|---|
| 29 | AC_PROG_CC
 | 
|---|
| 30 | CFLAGS=$savedCFLAGS
 | 
|---|
| 31 | 
 | 
|---|
| 32 | dnl don't try for C99 if we are using gcc, as otherwise we 
 | 
|---|
| 33 | dnl lose immediate structure constants
 | 
|---|
| 34 | if test x"$GCC" != x"yes" ; then
 | 
|---|
| 35 | AC_PROG_CC_C99
 | 
|---|
| 36 | fi
 | 
|---|
| 37 | 
 | 
|---|
| 38 | if test x"$GCC" = x"yes" ; then
 | 
|---|
| 39 |         AC_MSG_CHECKING([for version of gcc])
 | 
|---|
| 40 |         GCC_VERSION=`$CC -dumpversion`
 | 
|---|
| 41 |         AC_MSG_RESULT(${GCC_VERSION})
 | 
|---|
| 42 | fi
 | 
|---|
| 43 | AC_USE_SYSTEM_EXTENSIONS
 | 
|---|
| 44 | AC_C_BIGENDIAN
 | 
|---|
| 45 | AC_C_INLINE
 | 
|---|
| 46 | LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])])
 | 
|---|
| 47 | 
 | 
|---|
| 48 | AC_PROG_INSTALL
 | 
|---|
| 49 | 
 | 
|---|
| 50 | AC_ISC_POSIX
 | 
|---|
| 51 | AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED)
 | 
|---|
| 52 | 
 | 
|---|
| 53 | AC_SYS_LARGEFILE
 | 
|---|
| 54 | 
 | 
|---|
| 55 | dnl Add #include for broken IRIX header files
 | 
|---|
| 56 | case "$host_os" in
 | 
|---|
| 57 |         *irix6*) AC_ADD_INCLUDE(<standards.h>)
 | 
|---|
| 58 |                 ;;
 | 
|---|
| 59 |         *hpux*)
 | 
|---|
| 60 |                 # mmap on HPUX is completely broken...
 | 
|---|
| 61 |                 AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
 | 
|---|
| 62 |                 if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then
 | 
|---|
| 63 |                         AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround])
 | 
|---|
| 64 |                         CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64"
 | 
|---|
| 65 |                 fi
 | 
|---|
| 66 |                 if test "`uname -r`" = "B.11.23"; then
 | 
|---|
| 67 |                         AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround])
 | 
|---|
| 68 |                         CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED"
 | 
|---|
| 69 |                 fi
 | 
|---|
| 70 |                 ;;
 | 
|---|
| 71 |         *aix*)
 | 
|---|
| 72 |                 AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken])
 | 
|---|
| 73 |                 AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken])
 | 
|---|
| 74 |                 if test "${GCC}" != "yes"; then
 | 
|---|
| 75 |                         ## for funky AIX compiler using strncpy()
 | 
|---|
| 76 |                         CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
 | 
|---|
| 77 |                 fi
 | 
|---|
| 78 |                 ;;
 | 
|---|
| 79 |         *osf*)
 | 
|---|
| 80 |                 # this brings in socklen_t
 | 
|---|
| 81 |                 AC_N_DEFINE(_XOPEN_SOURCE,600)
 | 
|---|
| 82 |                 AC_N_DEFINE(_OSF_SOURCE)
 | 
|---|
| 83 |                 ;;
 | 
|---|
| 84 |         #
 | 
|---|
| 85 |         # VOS may need to have POSIX support and System V compatibility enabled.
 | 
|---|
| 86 |         #
 | 
|---|
| 87 |         *vos*)
 | 
|---|
| 88 |                 case "$CFLAGS" in
 | 
|---|
| 89 |                         *-D_POSIX_C_SOURCE*);;
 | 
|---|
| 90 |                         *)
 | 
|---|
| 91 |                                 CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
 | 
|---|
| 92 |                                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
 | 
|---|
| 93 |                                 ;;
 | 
|---|
| 94 |                 esac
 | 
|---|
| 95 |                 case "$CFLAGS" in
 | 
|---|
| 96 |                         *-D_SYSV*|*-D_SVID_SOURCE*);;
 | 
|---|
| 97 |                         *)
 | 
|---|
| 98 |                                 CFLAGS="$CFLAGS -D_SYSV"
 | 
|---|
| 99 |                                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
 | 
|---|
| 100 |                                 ;;
 | 
|---|
| 101 |                 esac
 | 
|---|
| 102 |                 ;;
 | 
|---|
| 103 | esac
 | 
|---|
| 104 | 
 | 
|---|
| 105 | 
 | 
|---|
| 106 | 
 | 
|---|
| 107 | AC_CHECK_HEADERS([standards.h])
 | 
|---|
| 108 | 
 | 
|---|
| 109 | # Solaris needs HAVE_LONG_LONG defined
 | 
|---|
| 110 | AC_CHECK_TYPES(long long)
 | 
|---|
| 111 | 
 | 
|---|
| 112 | AC_CHECK_SIZEOF(int)
 | 
|---|
| 113 | AC_CHECK_SIZEOF(char)
 | 
|---|
| 114 | AC_CHECK_SIZEOF(short)
 | 
|---|
| 115 | AC_CHECK_SIZEOF(long)
 | 
|---|
| 116 | AC_CHECK_SIZEOF(long long)
 | 
|---|
| 117 | 
 | 
|---|
| 118 | AC_CHECK_TYPE(int8_t, char)
 | 
|---|
| 119 | AC_CHECK_TYPE(uint8_t, unsigned char)
 | 
|---|
| 120 | AC_CHECK_TYPE(int16_t, short)
 | 
|---|
| 121 | AC_CHECK_TYPE(uint16_t, unsigned short)
 | 
|---|
| 122 | 
 | 
|---|
| 123 | if test $ac_cv_sizeof_int -eq 4 ; then
 | 
|---|
| 124 | AC_CHECK_TYPE(int32_t, int)
 | 
|---|
| 125 | AC_CHECK_TYPE(uint32_t, unsigned int)
 | 
|---|
| 126 | elif test $ac_cv_size_long -eq 4 ; then
 | 
|---|
| 127 | AC_CHECK_TYPE(int32_t, long)
 | 
|---|
| 128 | AC_CHECK_TYPE(uint32_t, unsigned long)
 | 
|---|
| 129 | else
 | 
|---|
| 130 | AC_MSG_ERROR([LIBREPLACE no 32-bit type found])
 | 
|---|
| 131 | fi
 | 
|---|
| 132 | 
 | 
|---|
| 133 | AC_CHECK_TYPE(int64_t, long long)
 | 
|---|
| 134 | AC_CHECK_TYPE(uint64_t, unsigned long long)
 | 
|---|
| 135 | 
 | 
|---|
| 136 | AC_CHECK_TYPE(size_t, unsigned int)
 | 
|---|
| 137 | AC_CHECK_TYPE(ssize_t, int)
 | 
|---|
| 138 | 
 | 
|---|
| 139 | AC_CHECK_SIZEOF(off_t)
 | 
|---|
| 140 | AC_CHECK_SIZEOF(size_t)
 | 
|---|
| 141 | AC_CHECK_SIZEOF(ssize_t)
 | 
|---|
| 142 | 
 | 
|---|
| 143 | AC_CHECK_TYPES([intptr_t, uintptr_t, ptrdiff_t])
 | 
|---|
| 144 | 
 | 
|---|
| 145 | if test x"$ac_cv_type_long_long" != x"yes";then
 | 
|---|
| 146 |         AC_MSG_ERROR([LIBREPLACE needs type 'long long'])
 | 
|---|
| 147 | fi
 | 
|---|
| 148 | if test $ac_cv_sizeof_long_long -lt 8;then
 | 
|---|
| 149 |         AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8])
 | 
|---|
| 150 | fi
 | 
|---|
| 151 | 
 | 
|---|
| 152 | ############################################
 | 
|---|
| 153 | # check if the compiler can do immediate structures
 | 
|---|
| 154 | AC_SUBST(libreplace_cv_immediate_structures)
 | 
|---|
| 155 | AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
 | 
|---|
| 156 |         AC_TRY_COMPILE([
 | 
|---|
| 157 |                 #include <stdio.h>
 | 
|---|
| 158 |         ],[
 | 
|---|
| 159 |                 typedef struct {unsigned x;} FOOBAR;
 | 
|---|
| 160 |                 #define X_FOOBAR(x) ((FOOBAR) { x })
 | 
|---|
| 161 |                 #define FOO_ONE X_FOOBAR(1)
 | 
|---|
| 162 |                 FOOBAR f = FOO_ONE;   
 | 
|---|
| 163 |                 static const struct {
 | 
|---|
| 164 |                         FOOBAR y; 
 | 
|---|
| 165 |                 } f2[] = {
 | 
|---|
| 166 |                         {FOO_ONE}
 | 
|---|
| 167 |                 };
 | 
|---|
| 168 |                 static const FOOBAR f3[] = {FOO_ONE};
 | 
|---|
| 169 |         ],
 | 
|---|
| 170 |         libreplace_cv_immediate_structures=yes,
 | 
|---|
| 171 |         libreplace_cv_immediate_structures=no,
 | 
|---|
| 172 |         libreplace_cv_immediate_structures=cross)
 | 
|---|
| 173 | ])
 | 
|---|
| 174 | if test x"$libreplace_cv_immediate_structures" = x"yes"; then
 | 
|---|
| 175 |         AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
 | 
|---|
| 176 | fi
 | 
|---|
| 177 | 
 | 
|---|
| 178 | AC__LIBREPLACE_ONLY_CC_CHECKS_END
 | 
|---|
| 179 | ]) dnl end AC_LIBREPLACE_CC_CHECKS
 | 
|---|