1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

r18519: Copy over the Samba4 code to figure out options for the named initializers.

Volker
This commit is contained in:
Volker Lendecke 2006-09-14 11:58:22 +00:00 committed by Gerald (Jerry) Carter
parent 398f368c8a
commit 1786c28cc3
2 changed files with 76 additions and 0 deletions

72
source/aclocal.m4 vendored
View File

@ -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
])

View File

@ -540,6 +540,10 @@ if test x"$samba_cv_volatile" = x"yes"; then
AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
fi
dnl Figure out the flags to support named structure initializers
LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])])
UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
AC_MSG_CHECKING(uname -s)
AC_MSG_RESULT(${UNAME_S})