s3:net_idmap_delete do not lock two records at the same time
[Samba/gebeck_regimport.git] / lib / replace / libreplace_cc.m4
blob50cb73583ba377a7c00f86cec1feed98257827fd
2 AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START,
4 echo "LIBREPLACE_CC_CHECKS: START"
5 ])
7 AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END,
9 echo "LIBREPLACE_CC_CHECKS: END"
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,
22 AC__LIBREPLACE_ONLY_CC_CHECKS_START
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
28 savedCFLAGS=$CFLAGS
29 AC_PROG_CC
30 CFLAGS=$savedCFLAGS
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
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})
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])])
48 AC_PROG_INSTALL
50 AC_ISC_POSIX
51 AC_N_DEFINE(_XOPEN_SOURCE_EXTENDED)
53 AC_MSG_CHECKING(checking getconf LFS_CFLAGS for large file support flags)
54 LFS_CFLAGS=`(getconf LFS_CFLAGS) 2>/dev/null` || LFS_CFLAGS=""
56 AC_MSG_RESULT(${LFS_CFLAGS})
57 if test "x$LFS_CFLAGS" != 'x-1' || test "x$LFS_CFLAGS" != "xundefined"; then
58    CFLAGS="$CFLAGS $LFS_CFLAGS"
61 AC_SYS_LARGEFILE
63 dnl Add #include for broken IRIX header files
64 case "$host_os" in
65         *irix6*) AC_ADD_INCLUDE(<standards.h>)
66                 AC_N_DEFINE(_XOPEN_SOURCE,600)
67                 AC_N_DEFINE(_BSD_TYPES)
68                 ;;
69         *hpux*)
70                 # mmap on HPUX is completely broken...
71                 AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
72                 if test "`uname -r`" = "B.11.00" -o "`uname -r`" = "B.11.11"; then
73                         AC_MSG_WARN([Enabling HPUX 11.00/11.11 header bug workaround])
74                         CFLAGS="$CFLAGS -Dpread=pread64 -Dpwrite=pwrite64"
75                 fi
76                 if test "`uname -r`" = "B.11.23"; then
77                         AC_MSG_WARN([Enabling HPUX 11.23 machine/sys/getppdp.h bug workaround])
78                         CFLAGS="$CFLAGS -D_MACHINE_SYS_GETPPDP_INCLUDED"
79                 fi
80                 ;;
81         *aix*)
82                 AC_DEFINE(BROKEN_STRNDUP, 1, [Whether strndup is broken])
83                 AC_DEFINE(BROKEN_STRNLEN, 1, [Whether strnlen is broken])
84                 if test "${GCC}" != "yes"; then
85                         ## for funky AIX compiler using strncpy()
86                         CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
87                 fi
88                 ;;
89         *osf*)
90                 # this brings in socklen_t
91                 AC_N_DEFINE(_XOPEN_SOURCE,600)
92                 AC_N_DEFINE(_OSF_SOURCE)
93                 ;;
94         #
95         # VOS may need to have POSIX support and System V compatibility enabled.
96         #
97         *vos*)
98                 case "$CFLAGS" in
99                         *-D_POSIX_C_SOURCE*);;
100                         *)
101                                 CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
102                                 AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
103                                 ;;
104                 esac
105                 case "$CFLAGS" in
106                         *-D_SYSV*|*-D_SVID_SOURCE*);;
107                         *)
108                                 CFLAGS="$CFLAGS -D_SYSV"
109                                 AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
110                                 ;;
111                 esac
112                 ;;
113 esac
115 # Do not check for standards.h on darwin, we get nasty warnings on
116 # OS/X Lion. Probably a positive-list of OS'es like IRIX and AIX
117 # would be the better choice, but this seems to work fine
119 case "$host_os" in
120      *darwin*)
121         ;;
122      *)
123         AC_CHECK_HEADERS([standards.h])
124         ;;
125 esac
127 # Solaris needs HAVE_LONG_LONG defined
128 AC_CHECK_TYPES(long long)
130 AC_CHECK_SIZEOF(int)
131 AC_CHECK_SIZEOF(char)
132 AC_CHECK_SIZEOF(short)
133 AC_CHECK_SIZEOF(long)
134 AC_CHECK_SIZEOF(long long)
136 AC_CHECK_TYPE(int8_t, char)
137 AC_CHECK_TYPE(uint8_t, unsigned char)
138 AC_CHECK_TYPE(int16_t, short)
139 AC_CHECK_TYPE(uint16_t, unsigned short)
141 if test $ac_cv_sizeof_int -eq 4 ; then
142 AC_CHECK_TYPE(int32_t, int)
143 AC_CHECK_TYPE(uint32_t, unsigned int)
144 elif test $ac_cv_size_long -eq 4 ; then
145 AC_CHECK_TYPE(int32_t, long)
146 AC_CHECK_TYPE(uint32_t, unsigned long)
147 else
148 AC_MSG_ERROR([LIBREPLACE no 32-bit type found])
151 AC_CHECK_TYPE(int64_t, long long)
152 AC_CHECK_TYPE(uint64_t, unsigned long long)
154 AC_CHECK_TYPE(size_t, unsigned int)
155 AC_CHECK_TYPE(ssize_t, int)
157 AC_CHECK_SIZEOF(off_t)
158 AC_CHECK_SIZEOF(size_t)
159 AC_CHECK_SIZEOF(ssize_t)
161 AC_CHECK_TYPES([intptr_t, uintptr_t, ptrdiff_t])
163 if test x"$ac_cv_type_long_long" != x"yes";then
164         AC_MSG_ERROR([LIBREPLACE needs type 'long long'])
166 if test $ac_cv_sizeof_long_long -lt 8;then
167         AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8])
170 ############################################
171 # check if the compiler can do immediate structures
172 AC_SUBST(libreplace_cv_immediate_structures)
173 AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
174         AC_TRY_COMPILE([
175                 #include <stdio.h>
176         ],[
177                 typedef struct {unsigned x;} FOOBAR;
178                 #define X_FOOBAR(x) ((FOOBAR) { x })
179                 #define FOO_ONE X_FOOBAR(1)
180                 FOOBAR f = FOO_ONE;   
181                 static const struct {
182                         FOOBAR y; 
183                 } f2[] = {
184                         {FOO_ONE}
185                 };
186                 static const FOOBAR f3[] = {FOO_ONE};
187         ],
188         libreplace_cv_immediate_structures=yes,
189         libreplace_cv_immediate_structures=no,
190         libreplace_cv_immediate_structures=cross)
192 if test x"$libreplace_cv_immediate_structures" = x"yes"; then
193         AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
196 AC__LIBREPLACE_ONLY_CC_CHECKS_END
197 ]) dnl end AC_LIBREPLACE_CC_CHECKS