summaryrefslogtreecommitdiff
path: root/source4/lib/replace
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-05 07:58:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:17:10 -0500
commit8e9c4e83fa02642d6c8671e9fe0108f417c9268f (patch)
tree8769c3e4e0463ae1d027f242454b3304db01b84b /source4/lib/replace
parent10d58661be5588e8877c696abf67a932d5a5373c (diff)
downloadsamba-8e9c4e83fa02642d6c8671e9fe0108f417c9268f.tar.gz
samba-8e9c4e83fa02642d6c8671e9fe0108f417c9268f.tar.bz2
samba-8e9c4e83fa02642d6c8671e9fe0108f417c9268f.zip
r18067: some tweaks for irix and hpux
this checks for -AC99 or -c99 to get C99 structure init to work. It's based on a similar macro metze did for Samba4. the double sinclude() is weird, but I can't see any other way to use a common config.m4 between libreplace and all the projects that use it (This used to be commit 8d80024976bc508d73b42b4cf12315fe8f7a6322)
Diffstat (limited to 'source4/lib/replace')
-rw-r--r--source4/lib/replace/cc_features.m442
-rw-r--r--source4/lib/replace/config.m46
-rw-r--r--source4/lib/replace/replace.h8
3 files changed, 50 insertions, 6 deletions
diff --git a/source4/lib/replace/cc_features.m4 b/source4/lib/replace/cc_features.m4
new file mode 100644
index 0000000000..a109dfb414
--- /dev/null
+++ b/source4/lib/replace/cc_features.m4
@@ -0,0 +1,42 @@
+dnl C99 compiler check
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004,2005
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+dnl adapted for libreplace by Andrew Tridgell
+
+############################################
+# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags
+# Usage: LIBREPLACE_CC_SUPPORTS_C99_STRUCT_INIT(success-action,failure-action)
+# changes CFLAGS to add -AC99 or -c99 if needed
+
+AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT],
+[
+AC_MSG_CHECKING(for C99 designated initializers)
+saved_CFLAGS="$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; $1], [c99_init=no; AC_MSG_RESULT(no)])
+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; $1],[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); $1],[AC_MSG_RESULT(no);CFLAGS="$saved_CFLAGS"; $2])
+fi
+])
+
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index 53eda9e8ed..a846f5168f 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -142,6 +142,12 @@ AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
[AC_MSG_ERROR([Required function not found])])
sinclude(lib/replace/getpass.m4)
+sinclude(getpass.m4)
+sinclude(lib/replace/cc_features.m4)
+sinclude(cc_features.m4)
+
+LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes,
+ c99_struct_initialization=no)
dnl VA_COPY
AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 4f0308ce52..1d07361a28 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -51,9 +51,7 @@
#ifdef HAVE_STDINT_H
#include <stdint.h>
-#endif
-
-#ifdef HAVE_INTTYPES_H
+#elif HAVE_INTTYPES_H
#include <inttypes.h>
#endif
@@ -257,9 +255,7 @@ char *rep_mkdtemp(char *template);
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
-#endif
-
-#ifndef HAVE_BOOL
+#elif !defined(HAVE_BOOL)
#define __bool_true_false_are_defined
typedef int bool;
#define false (0)