From d442d2846a00c0ac2f031deba06b7e0d003f14ad Mon Sep 17 00:00:00 2001
From: Eric Christopher <echristo@apple.com>
Date: Sun, 8 Aug 2010 09:18:29 +0000
Subject: [PATCH] Add a bit of a hack to avoid multiple defines of variables in
 config.h and llvm-config.h.  This could probably be improved.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110547 91177308-0d34-0410-b5e6-96231b3b80d8
---
 autoconf/configure.ac                | 4 ++++
 include/llvm/Config/config.h.in      | 5 +++++
 include/llvm/Config/llvm-config.h.in | 7 +++++++
 3 files changed, 16 insertions(+)

diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 5def41f8421..29a57b8385e 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -1581,6 +1581,10 @@ dnl you MUST also update Makefile.rules so that the variable FilesToConfig
 dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the
 dnl files can be updated automatically when their *.in sources change.
 AC_CONFIG_HEADERS([include/llvm/Config/config.h include/llvm/Config/llvm-config.h])
+AH_TOP([#ifndef CONFIG_H
+#define CONFIG_H])
+AH_BOTTOM([#endif])
+
 AC_CONFIG_FILES([include/llvm/Config/Targets.def])
 AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def])
 AC_CONFIG_FILES([include/llvm/Config/AsmParsers.def])
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 9a10f7f06c2..5fe3da25706 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -1,5 +1,8 @@
 /* include/llvm/Config/config.h.in.  Generated from autoconf/configure.ac by autoheader.  */
 
+#ifndef CONFIG_H
+#define CONFIG_H
+
 /* 32 bit multilib directory. */
 #undef CXX_INCLUDE_32BIT_DIR
 
@@ -607,3 +610,5 @@
 
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
+
+#endif
diff --git a/include/llvm/Config/llvm-config.h.in b/include/llvm/Config/llvm-config.h.in
index 1557e272b85..f35859ea041 100644
--- a/include/llvm/Config/llvm-config.h.in
+++ b/include/llvm/Config/llvm-config.h.in
@@ -11,6 +11,11 @@
    they can be in exported headers and won't override package specific
    directives.  This is a C file so we can include it in the llvm-c headers.  */
 
+/* To avoid multiple inclusions of these variables when we include the exported
+   headers and config.h, conditionally include these.  */
+/* TODO: This is a bit of a hack.  */
+#ifndef CONFIG_H
+
 /* Installation directory for binary executables */
 #undef LLVM_BINDIR
 
@@ -82,3 +87,5 @@
 
 /* Installation prefix directory */
 #undef LLVM_PREFIX
+
+#endif