summaryrefslogtreecommitdiff
path: root/source3/aclocal.m4
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-09-14 11:58:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:51:45 -0500
commit5077d280811a084d955b9d39bcb0d86faa80f680 (patch)
tree3700fe6266ba30a15a89a854b1552537cb776eb4 /source3/aclocal.m4
parent2ad8c705b238e8ebb87fed51b962b4e165c1202f (diff)
downloadsamba-5077d280811a084d955b9d39bcb0d86faa80f680.tar.gz
samba-5077d280811a084d955b9d39bcb0d86faa80f680.tar.bz2
samba-5077d280811a084d955b9d39bcb0d86faa80f680.zip
r18519: Copy over the Samba4 code to figure out options for the named initializers.
Volker (This used to be commit 1786c28cc353e2ba70abe2750b9ef804cec84bf0)
Diffstat (limited to 'source3/aclocal.m4')
-rw-r--r--source3/aclocal.m472
1 files changed, 72 insertions, 0 deletions
diff --git a/source3/aclocal.m4 b/source3/aclocal.m4
index b0f1f6c44d..54b1a56040 100644
--- a/source3/aclocal.m4
+++ b/source3/aclocal.m4
@@ -796,3 +796,75 @@ int main(void)
])
])
+############################################
+# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags
+# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action)
+# changes CFLAGS to add -AC99 or -c99 if needed
+AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT],
+[
+saved_CFLAGS="$CFLAGS";
+c99_init=no
+if test x"$c99_init" = x"no"; then
+ AC_MSG_CHECKING(for C99 designated initializers)
+ CFLAGS="$saved_CFLAGS";
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [ struct foo {int x;char y;};
+ struct foo bar = { .y = 'X', .x = 1 };
+ ],
+ [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
+fi
+if test x"$c99_init" = x"no"; then
+ AC_MSG_CHECKING(for C99 designated initializers with -AC99)
+ CFLAGS="$saved_CFLAGS -AC99";
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [ struct foo {int x;char y;};
+ struct foo bar = { .y = 'X', .x = 1 };
+ ],
+ [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
+fi
+if test x"$c99_init" = x"no"; then
+ AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99)
+ CFLAGS="$saved_CFLAGS -qlanglvl=extc99";
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [ struct foo {int x;char y;};
+ struct foo bar = { .y = 'X', .x = 1 };
+ ],
+ [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
+fi
+if test x"$c99_init" = x"no"; then
+ AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99)
+ CFLAGS="$saved_CFLAGS -qlanglvl=stdc99";
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [ struct foo {int x;char y;};
+ struct foo bar = { .y = 'X', .x = 1 };
+ ],
+ [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
+fi
+if test x"$c99_init" = x"no"; then
+ AC_MSG_CHECKING(for C99 designated initializers with -c99)
+ CFLAGS="$saved_CFLAGS -c99"
+ AC_TRY_COMPILE([#include <stdio.h>],
+ [ struct foo {int x;char y;};
+ struct foo bar = { .y = 'X', .x = 1 };
+ ],
+ [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
+fi
+
+if test "`uname`" = "HP-UX"; then
+ if test "$ac_cv_c_compiler_gnu" = no; then
+ # special override for broken HP-UX compiler - I can't find a way to test
+ # this properly (its a compiler bug)
+ CFLAGS="$CFLAGS -AC99";
+ c99_init=yes;
+ fi
+fi
+
+if test x"$c99_init" = x"yes"; then
+ saved_CFLAGS=""
+ $1
+else
+ CFLAGS="$saved_CFLAGS"
+ saved_CFLAGS=""
+ $2
+fi
+])