source: branches/samba-3.2.x/source/lib/replace/libreplace_macros.m4@ 198

Last change on this file since 198 was 133, checked in by Paul Smedley, 18 years ago

Update trunk to 3.2.0pre3

File size: 9.9 KB
Line 
1#
2# This is a collection of useful autoconf macros
3#
4
5############################################
6# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags
7# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action)
8# changes CFLAGS to add -AC99 or -c99 if needed
9AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT],
10[
11saved_CFLAGS="$CFLAGS";
12c99_init=no
13if test x"$c99_init" = x"no"; then
14 AC_MSG_CHECKING(for C99 designated initializers)
15 CFLAGS="$saved_CFLAGS";
16 AC_TRY_COMPILE([#include <stdio.h>],
17 [ struct foo {int x;char y;};
18 struct foo bar = { .y = 'X', .x = 1 };
19 ],
20 [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
21fi
22if test x"$c99_init" = x"no"; then
23 AC_MSG_CHECKING(for C99 designated initializers with -AC99)
24 CFLAGS="$saved_CFLAGS -AC99";
25 AC_TRY_COMPILE([#include <stdio.h>],
26 [ struct foo {int x;char y;};
27 struct foo bar = { .y = 'X', .x = 1 };
28 ],
29 [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
30fi
31if test x"$c99_init" = x"no"; then
32 AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99)
33 CFLAGS="$saved_CFLAGS -qlanglvl=extc99";
34 AC_TRY_COMPILE([#include <stdio.h>],
35 [ struct foo {int x;char y;};
36 struct foo bar = { .y = 'X', .x = 1 };
37 ],
38 [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
39fi
40if test x"$c99_init" = x"no"; then
41 AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99)
42 CFLAGS="$saved_CFLAGS -qlanglvl=stdc99";
43 AC_TRY_COMPILE([#include <stdio.h>],
44 [ struct foo {int x;char y;};
45 struct foo bar = { .y = 'X', .x = 1 };
46 ],
47 [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
48fi
49if test x"$c99_init" = x"no"; then
50 AC_MSG_CHECKING(for C99 designated initializers with -c99)
51 CFLAGS="$saved_CFLAGS -c99"
52 AC_TRY_COMPILE([#include <stdio.h>],
53 [ struct foo {int x;char y;};
54 struct foo bar = { .y = 'X', .x = 1 };
55 ],
56 [AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])