summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2002-04-05 13:49:45 (GMT)
committerdas <das>2002-04-05 13:49:45 (GMT)
commite75570f82d33340ffc101a748a22567a87b390ab (patch)
tree2b1c29c8a7a764776f6e75f1805b1d936b1a4ddf
parent37b27cd0cd6481353bcaf37273d225c223a122f6 (diff)
downloadtcl-tip_59_implementation.zip
tcl-tip_59_implementation.tar.gz
tcl-tip_59_implementation.tar.bz2
2002-04-05 Daniel Steffen <das@users.sourceforge.net> tip_59_implementation
* mac/tclMacPkgConfig.c: Added Mac implementation of pkgconfig. * tests/config.test: fixed failing tests.
-rw-r--r--ChangeLog5
-rw-r--r--mac/tclMacPkgConfig.c107
-rw-r--r--tests/config.test8
3 files changed, 116 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c54de8..ae7092f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-04-05 Daniel Steffen <das@users.sourceforge.net>
+
+ * mac/tclMacPkgConfig.c: Added Mac implementation of pkgconfig.
+ * tests/config.test: fixed failing tests.
+
2002-02-05 Andreas Kupries <andreas_kupries@users.sourceforge.net>
* tests/config.test: Added a testsuite for pkgconfig.
diff --git a/mac/tclMacPkgConfig.c b/mac/tclMacPkgConfig.c
new file mode 100644
index 0000000..b15e391
--- /dev/null
+++ b/mac/tclMacPkgConfig.c
@@ -0,0 +1,107 @@
+/*
+ * tclMacPkgConfig.c --
+ *
+ * This file contains the Mac configuration information to
+ * embed into the tcl binary library.
+ *
+ * Copyright (c) 2002 Daniel Steffen <das@users.sourceforge.net>
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * RCS: @(#) $Id: tclMacPkgConfig.c,v 1.1.2.1 2002/04/05 13:49:45 das Exp $
+ */
+
+#include "tclInt.h"
+
+#ifdef __MWERKS__
+
+/* define DEBUG/OPTIMIZED macros depending on the value of
+ * Metrowerks specific precompiler functions.
+ * (traceback is for PPC, macsbug for 68k) */
+# if __option(traceback) || __option(macsbug)
+# define TCL_CFG_DEBUG
+# else
+# define TCL_CFG_OPTIMIZED
+# endif
+
+/* define PROFILED macros depending depending on the value of
+ * Metrowerks specific precompiler functions. */
+# if __option(profile)
+# define TCL_CFG_PROFILED
+# endif
+
+#else
+
+# ifdef TCL_DEBUG
+# define TCL_CFG_DEBUG
+# else
+# define TCL_CFG_OPTIMIZED
+# endif
+
+#endif
+
+/* the CFG_*DIR values need to be built up dynamically at runtime
+ * because the name of the Macintosh Extension directory on a user's
+ * system is not known at build time */
+#define CFG_RUNTIME_PREFIX "${::env(EXT_FOLDER)}Tool Command Language"
+#define CFG_RUNTIME_LIBDIR CFG_RUNTIME_PREFIX
+#define CFG_RUNTIME_BINDIR CFG_RUNTIME_PREFIX
+#define CFG_RUNTIME_SCRDIR CFG_RUNTIME_PREFIX":tcl"TCL_VERSION
+#define CFG_RUNTIME_INCDIR CFG_RUNTIME_PREFIX
+#define CFG_RUNTIME_DOCDIR CFG_RUNTIME_PREFIX
+#define CFG_INSTALL_LIBDIR CFG_RUNTIME_LIBDIR
+#define CFG_INSTALL_BINDIR CFG_RUNTIME_BINDIR
+#define CFG_INSTALL_SCRDIR CFG_RUNTIME_SCRDIR
+#define CFG_INSTALL_INCDIR CFG_RUNTIME_INCDIR
+#define CFG_INSTALL_DOCDIR CFG_RUNTIME_DOCDIR
+
+/* use system encoding */
+#define TCL_CFGVAL_ENCODING NULL
+
+/* We want to include tclPkgConfig.c to get the remaining CFG_* macros
+ * and the cfg array declaration, but need our own definition of
+ * TclInitEmbeddedConfigurationInformation, so we rename this routine
+ * for the duration of the inclusion and declare it static */
+static void TclUnusedInitEmbeddedConfigurationInformation
+ _ANSI_ARGS_((Tcl_Interp *interp));
+#define TclInitEmbeddedConfigurationInformation \
+ TclUnusedInitEmbeddedConfigurationInformation
+#include "tclPkgConfig.c"
+#undef TclInitEmbeddedConfigurationInformation
+
+
+void
+TclInitEmbeddedConfigurationInformation (interp)
+ Tcl_Interp* interp; /* Interpreter the configuration
+ * command is registered in. */
+{
+ Tcl_Config *cfgp;
+ Tcl_Obj *valObj, *substObj;
+ char *subst;
+ int len;
+
+ valObj = Tcl_NewObj();
+
+ /* Call Tcl_SubstObj on all values in the cfg array and replace
+ * the existing value by the result if any substitution has
+ * occurred. This is needed because on the Mac the CFG_*DIR
+ * macros contain variables that are not known until runtime */
+ for (cfgp = cfg;
+ (cfgp->key != (CONST char*) NULL) && (cfgp->key [0] != '\0') ;
+ cfgp++)
+ {
+ Tcl_SetStringObj(valObj, cfgp->value, -1);
+ substObj = Tcl_SubstObj(interp, valObj, TCL_SUBST_VARIABLES);
+ if( substObj ) {
+ subst = Tcl_GetStringFromObj(substObj, &len);
+ if ( strcmp(cfgp->value, subst) )
+ cfgp->value = strcpy(ckalloc((unsigned)len+1), subst);
+ Tcl_DecrRefCount(substObj);
+ }
+ }
+
+ Tcl_DecrRefCount(valObj);
+
+ Tcl_RegisterConfig (interp, "tcl", cfg, TCL_CFGVAL_ENCODING);
+}
diff --git a/tests/config.test b/tests/config.test
index e4e3aaf..323c444 100644
--- a/tests/config.test
+++ b/tests/config.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: config.test,v 1.1.2.1 2002/02/05 23:58:02 andreas_kupries Exp $
+# RCS: @(#) $Id: config.test,v 1.1.2.2 2002/04/05 13:49:57 das Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -21,7 +21,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
test pkgconfig-1.1 {query keys} {
lsort [::tcl::pkgconfig list]
-} {64bit compile_debug compile_stats debug exec_prefix,install exec_prefix,runtime mem_debug optimized prefix,install prefix,runtime profiled threaded}
+} {64bit bindir,install bindir,runtime compile_debug compile_stats debug docdir,install docdir,runtime includedir,install includedir,runtime libdir,install libdir,runtime mem_debug optimized profiled scriptdir,install scriptdir,runtime threaded}
test pkgconfig-1.2 {query keys multiple times} {
string compare [::tcl::pkgconfig list] [::tcl::pkgconfig list]
@@ -29,8 +29,8 @@ test pkgconfig-1.2 {query keys multiple times} {
test pkgconfig-1.3 {query value multiple times} {
string compare \
- [::tcl::pkgconfig get exec_prefix,install] \
- [::tcl::pkgconfig get exec_prefix,install]
+ [::tcl::pkgconfig get bindir,install] \
+ [::tcl::pkgconfig get bindir,install]
} 0