changeset 100:1e4eef5bf88d release-0.1

Set up some real builtin macro config instead of hardwiring my platform.
author David A. Holland
date Tue, 11 Jun 2013 00:14:31 -0400
parents 60184aa42604
children 110a1bc4de02
files config.h
diffstat 1 files changed, 104 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/config.h	Mon Jun 10 23:51:07 2013 -0400
+++ b/config.h	Tue Jun 11 00:14:31 2013 -0400
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2010, 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -27,17 +27,118 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * Config for predefined macros. If this doesn't do what you want you
+ * can set any or all of the CONFIG_ defines from the compiler command
+ * line; or patch the list in main.c; or both.
+ */
+
+/*
+ * Paths
+ */
+
+#ifndef CONFIG_LOCALINCLUDE
 #define CONFIG_LOCALINCLUDE "/usr/local/include"
+#endif
+
+#ifndef CONFIG_SYSTEMINCLUDE
 #define CONFIG_SYSTEMINCLUDE "/usr/include"
+#endif
 
+/*
+ * Operating system
+ */
+
+#ifndef CONFIG_OS
+#if defined(__NetBSD__)
 #define CONFIG_OS "__NetBSD__"
 #define CONFIG_OS_2 "__unix__"
+#elif defined(__FreeBSD__)
+#define CONFIG_OS "__FreeBSD__"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__OpenBSD__)
+#define CONFIG_OS "__OpenBSD__"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__DragonFly__)
+#define CONFIG_OS "__DragonFly__"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__bsdi__)
+#define CONFIG_OS "__bsdi__"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__sun)
+#define CONFIG_OS "__sun"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__sgi)
+#define CONFIG_OS "__sgi"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__SVR4)
+#define CONFIG_OS "__SVR4"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__APPLE__)
+#define CONFIG_OS "__APPLE__"
+#define CONFIG_OS_2 "__unix__"
+#elif defined(__linux__)
+#define CONFIG_OS "__linux__"
+#elif defined(__CYGWIN__)
+#define CONFIG_OS "__CYGWIN__"
+#elif defined(__INTERIX)
+#define CONFIG_OS "__INTERIX"
+#elif defined(__MINGW32)
+#define CONFIG_OS "__MINGW32"
+#else
+/* we could error... but let's instead assume generic unix */
+#define CONFIG_OS "__unix__"
+#endif
+#endif
 
+/*
+ * CPU
+ */
+
+#ifndef CONFIG_CPU
+#if defined(__x86_64__)
 #define CONFIG_CPU "__x86_64__"
 #define CONFIG_CPU_2 "__amd64__"
+#elif defined(__i386__) || defined(__i386)
+#define CONFIG_CPU "__i386__"
+#define CONFIG_CPU_2 "__i386"
+#elif defined(__sparc)
+#define CONFIG_CPU "__sparc"
+#elif defined(__mips)
+#define CONFIG_CPU "__mips"
+#elif defined(__POWERPC__)
+#define CONFIG_CPU "__POWERPC__"
+#elif defined(__ARM__)
+#define CONFIG_CPU "__ARM__"
+#else
+/* let it go */
+#endif
+#endif
 
+/*
+ * Other stuff
+ */
+
+#ifndef CONFIG_SIZE
+#ifdef __LP64__
 #define CONFIG_SIZE "__LP64__"
+#else
+#define CONFIG_SIZE "__ILP32__"
+#endif
+#endif
+
+#ifndef CONFIG_BINFMT
+#ifdef __ELF__
 #define CONFIG_BINFMT "__ELF__"
+#endif
+#endif
 
-#define CONFIG_COMPILER "__NBCC__"
-#define CONFIG_COMPILER_MINOR "__NBCC_MINOR__"
+/*
+ * We are __TRADCPP__ by default, but if you want to masquerade as
+ * some other compiler this is a convenient place to change it.
+ */
+
+#ifndef CONFIG_COMPILER
+#define CONFIG_COMPILER "__TRADCPP__"
+#define CONFIG_COMPILER_MINOR "__TRADCPP_MINOR__"
+#endif