Bug 97954: Record configuration details in an installable header. r=bsmedberg
authorJim Blandy <jimb@mozilla.org>
Wed, 29 Oct 2008 08:29:37 -0700
changeset 21063 14284381d56d8a392f38aef95a80dfc5a9689501
parent 21062 8c52a9486c8f25a93063f5b628575837156f266b
child 21064 890e122872e743f1930709feacadbd1da80162c4
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs97954
milestone1.9.1b2pre
Bug 97954: Record configuration details in an installable header. r=bsmedberg Have js/src/configure create a header file, js-config.h, that records configure-controlled options that affect the SpiderMonkey API, like '--enable-threadsafe'. js-config.h is namespace-clean, so it can be installed with jsapi.h. This means that clients can configure SpiderMonkey however they like, and then simply #include "jsapi.h" and have everything work; they don't have to remember to match their own compiler -D flags with those SpiderMonkey's configure script chose. For example, mozilla-config.h needn't concern itself with JS_THREADSAFE. It seems to me this could also be done by having js-config --cflags print -D options. The approach taken here seems a bit more robust: if you can find jsapi.h at all, then you know you're getting the right settings.
configure.in
js/src/Makefile.in
js/src/configure.in
js/src/js-config.h.in
js/src/jsapi.h
--- a/configure.in
+++ b/configure.in
@@ -8043,18 +8043,16 @@ elif test "$OS_ARCH" = "OpenVMS"; then
   AC_DEFINE(XP_UNIX)
 elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" -a "$OS_ARCH" != "WINCE"; then
   AC_DEFINE(XP_UNIX)
   AC_DEFINE(UNIX_ASYNC_DNS)
   MOZ_MOVEMAIL=1
 fi
 AC_SUBST(MOZ_MOVEMAIL)
 
-AC_DEFINE(JS_THREADSAFE)
-
 if test "$MOZ_DEBUG"; then
     AC_DEFINE(MOZ_REFLOW_PERF)
     AC_DEFINE(MOZ_REFLOW_PERF_DSP)
 fi
 
 if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then
     AC_DEFINE(MOZ_ACCESSIBILITY_ATK)
     ATK_FULL_VERSION=`$PKG_CONFIG --modversion atk`
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -165,16 +165,17 @@ CPPSRCS		= \
 		$(NULL)
 
 ifdef HAVE_DTRACE
 CSRCS 		+= \
 		jsdtracef.c
 endif
 
 INSTALLED_HEADERS = \
+		js-config.h \
 		jsautocfg.h \
 		jsautokw.h \
 		js.msg \
 		jsapi.h \
 		jsarray.h \
 		jsarena.h \
 		jsatom.h \
 		jsbit.h \
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -58,16 +58,17 @@ dnl
 dnl ***** END LICENSE BLOCK *****
 
 dnl Process this file with autoconf to produce a configure script.
 dnl ========================================================
 
 AC_PREREQ(2.13)
 AC_INIT(jsapi.h)
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
+AC_CONFIG_HEADER(js-config.h)
 AC_CANONICAL_SYSTEM
 TARGET_CPU="${target_cpu}"
 TARGET_VENDOR="${target_vendor}"
 TARGET_OS="${target_os}"
 
 dnl ========================================================
 dnl =
 dnl = Don't change the following two lines.  Doing so breaks:
new file mode 100644
--- /dev/null
+++ b/js/src/js-config.h.in
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: set ts=8 sw=4 et tw=78:
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef js_config_h___
+#define js_config_h___
+
+/* Definitions set at build time that affect SpiderMonkey's public API.
+   This header file is generated by the SpiderMonkey configure script,
+   and installed along with jsapi.h.  */
+
+/* Define to 1 if SpiderMonkey should support multi-threaded clients.  */
+#undef JS_THREADSAFE
+
+/* Define to 1 if SpiderMonkey should support the ability to perform
+   entirely too much GC.  */
+#undef JS_GC_ZEAL
+
+#endif /* js_config_h___ */
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -40,16 +40,17 @@
 
 #ifndef jsapi_h___
 #define jsapi_h___
 /*
  * JavaScript API.
  */
 #include <stddef.h>
 #include <stdio.h>
+#include "js-config.h"
 #include "jspubtd.h"
 #include "jsutil.h"
 
 JS_BEGIN_EXTERN_C
 
 /*
  * Type tags stored in the low bits of a jsval.
  */