diff options
-rw-r--r-- | generic/tkInt.h | 2 | ||||
-rw-r--r-- | generic/tkPkgConfig.c | 150 | ||||
-rw-r--r-- | generic/tkWindow.c | 6 | ||||
-rw-r--r-- | tests/pkgconfig.test | 60 | ||||
-rw-r--r-- | unix/Makefile.in | 32 | ||||
-rwxr-xr-x | unix/configure | 28 | ||||
-rw-r--r-- | unix/configure.ac | 6 | ||||
-rw-r--r-- | unix/tkConfig.h.in | 3 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 13 |
9 files changed, 286 insertions, 14 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h index 474cfb0..204cc66 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1222,6 +1222,8 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp, ClientData clientData); MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp, ClientData clientData); +MODULE_SCOPE void TkInitEmbeddedConfigurationInformation( + Tcl_Interp *interp); MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr); MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr); MODULE_SCOPE int TkListCreateFrame(ClientData clientData, diff --git a/generic/tkPkgConfig.c b/generic/tkPkgConfig.c new file mode 100644 index 0000000..d913fb1 --- /dev/null +++ b/generic/tkPkgConfig.c @@ -0,0 +1,150 @@ +/* + * tkPkgConfig.c -- + * + * This file contains the configuration information to embed into the tcl + * binary library. + * + * Copyright (c) 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net> + * + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. + */ + +/* Note, the definitions in this module are influenced by the following C + * preprocessor macros: + * + * OSCMa = shortcut for "old style configuration macro activates" + * NSCMdt = shortcut for "new style configuration macro declares that" + * + * - TCL_THREADS OSCMa compilation as threaded core. + * - TCL_MEM_DEBUG OSCMa memory debugging. + * - TCL_COMPILE_DEBUG OSCMa debugging of bytecode compiler. + * - TCL_COMPILE_STATS OSCMa bytecode compiler statistics. + * + * - TCL_CFG_DO64BIT NSCMdt tk is compiled for a 64bit system. + * - NDEBUG NSCMdt tk is compiled with symbol info off. + * - TCL_CFG_OPTIMIZED NSCMdt tk is compiled with cc optimizations on + * - TCL_CFG_PROFILED NSCMdt tk is compiled with profiling info. + * - HAVE_XFT NSCMdt tk is compiled with xft font support. + * + * - CFG_RUNTIME_* Paths to various stuff at runtime. + * - CFG_INSTALL_* Paths to various stuff at installation time. + * + * - TCL_CFGVAL_ENCODING string containing the encoding used for the + * configuration values. + */ + +#include "tkInt.h" + + +#ifndef TCL_CFGVAL_ENCODING +#define TCL_CFGVAL_ENCODING "ascii" +#endif + +/* + * Use C preprocessor statements to define the various values for the embedded + * configuration information. + */ + +#ifdef TCL_THREADS +# define CFG_THREADED "1" +#else +# define CFG_THREADED "0" +#endif + +#ifdef TCL_MEM_DEBUG +# define CFG_MEMDEBUG "1" +#else +# define CFG_MEMDEBUG "0" +#endif + +#ifdef TCL_COMPILE_DEBUG +# define CFG_COMPILE_DEBUG "1" +#else +# define CFG_COMPILE_DEBUG "0" +#endif + +#ifdef TCL_COMPILE_STATS +# define CFG_COMPILE_STATS "1" +#else +# define CFG_COMPILE_STATS "0" +#endif + +#ifdef TCL_CFG_DO64BIT +# define CFG_64 "1" +#else +# define CFG_64 "0" +#endif + +#ifndef NDEBUG +# define CFG_DEBUG "1" +#else +# define CFG_DEBUG "0" +#endif + +#ifdef TCL_CFG_OPTIMIZED +# define CFG_OPTIMIZED "1" +#else +# define CFG_OPTIMIZED "0" +#endif + +#ifdef TCL_CFG_PROFILED +# define CFG_PROFILED "1" +#else +# define CFG_PROFILED "0" +#endif + +#ifdef HAVE_XFT +# define CFG_FONTSYSTEM "xft" +#else +# define CFG_FONTSYSTEM "x11" +#endif + +static Tcl_Config const cfg[] = { + {"debug", CFG_DEBUG}, + {"threaded", CFG_THREADED}, + {"profiled", CFG_PROFILED}, + {"64bit", CFG_64}, + {"optimized", CFG_OPTIMIZED}, + {"mem_debug", CFG_MEMDEBUG}, + {"compile_debug", CFG_COMPILE_DEBUG}, + {"compile_stats", CFG_COMPILE_STATS}, + {"fontsystem", CFG_FONTSYSTEM}, + + /* Runtime paths to various stuff */ + + {"libdir,runtime", CFG_RUNTIME_LIBDIR}, + {"bindir,runtime", CFG_RUNTIME_BINDIR}, + {"scriptdir,runtime", CFG_RUNTIME_SCRDIR}, + {"includedir,runtime", CFG_RUNTIME_INCDIR}, + {"docdir,runtime", CFG_RUNTIME_DOCDIR}, + {"demodir,runtime", CFG_RUNTIME_DEMODIR}, + + /* Installation paths to various stuff */ + + {"libdir,install", CFG_INSTALL_LIBDIR}, + {"bindir,install", CFG_INSTALL_BINDIR}, + {"scriptdir,install", CFG_INSTALL_SCRDIR}, + {"includedir,install", CFG_INSTALL_INCDIR}, + {"docdir,install", CFG_INSTALL_DOCDIR}, + {"demodir,install", CFG_INSTALL_DEMODIR}, + + /* Last entry, closes the array */ + {NULL, NULL} +}; + +void +TkInitEmbeddedConfigurationInformation( + Tcl_Interp *interp) /* Interpreter the configuration command is + * registered in. */ +{ + Tcl_RegisterConfig(interp, "tk", cfg, TCL_CFGVAL_ENCODING); +} + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index d9b5dec..4368e7e 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3052,6 +3052,12 @@ Initialize( } /* + * TIP #59: Make embedded configuration information available. + */ + + TkInitEmbeddedConfigurationInformation(interp); + + /* * Ensure that our obj-types are registered with the Tcl runtime. */ diff --git a/tests/pkgconfig.test b/tests/pkgconfig.test new file mode 100644 index 0000000..5cb5081 --- /dev/null +++ b/tests/pkgconfig.test @@ -0,0 +1,60 @@ +# -*- tcl -*- +# Commands covered: pkgconfig +# +# This file contains a collection of tests for one or more of the Tk +# built-in commands. Sourcing this file into Tk runs the tests and +# generates output for errors. No output means no errors were found. +# +# Copyright (c) 1991-1993 The Regents of the University of California. +# Copyright (c) 1994-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. + +package require tcltest 2.2 +namespace import ::tcltest::* +eval tcltest::configure $argv +tcltest::loadTestedCommands + +test pkgconfig-1.1 {query keys} { + lsort [::tk::pkgconfig list] +} {64bit bindir,install bindir,runtime compile_debug compile_stats debug demodir,install demodir,runtime docdir,install docdir,runtime fontsystem 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 [::tk::pkgconfig list] [::tk::pkgconfig list] +} 0 +test pkgconfig-1.3 {query value multiple times} { + string compare \ + [::tk::pkgconfig get bindir,install] \ + [::tk::pkgconfig get bindir,install] +} 0 + + +test pkgconfig-2.0 {error: missing subcommand} { + catch {::tk::pkgconfig} msg + set msg +} {wrong # args: should be "::tk::pkgconfig subcommand ?arg?"} +test pkgconfig-2.1 {error: illegal subcommand} { + catch {::tk::pkgconfig foo} msg + set msg +} {bad subcommand "foo": must be get or list} +test pkgconfig-2.2 {error: list with arguments} { + catch {::tk::pkgconfig list foo} msg + set msg +} {wrong # args: should be "::tk::pkgconfig list"} +test pkgconfig-2.3 {error: get without arguments} { + catch {::tk::pkgconfig get} msg + set msg +} {wrong # args: should be "::tk::pkgconfig get key"} +test pkgconfig-2.4 {error: query unknown key} { + catch {::tk::pkgconfig get foo} msg + set msg +} {key not known} +test pkgconfig-2.5 {error: query with to many arguments} { + catch {::tk::pkgconfig get foo bar} msg + set msg +} {wrong # args: should be "::tk::pkgconfig subcommand ?arg?"} + +# cleanup +cleanupTests +return diff --git a/unix/Makefile.in b/unix/Makefile.in index 99f2284..e71005e 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -369,8 +369,9 @@ GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBusy.o \ tkClipboard.o \ tkCmds.o tkColor.o tkConfig.o tkConsole.o tkCursor.o tkError.o \ tkEvent.o tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o \ - tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPlace.o \ - tkSelect.o tkStyle.o tkUndo.o tkUtil.o tkVisual.o tkWindow.o + tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o \ + tkPkgConfig.o tkPlace.o tkSelect.o tkStyle.o tkUndo.o tkUtil.o \ + tkVisual.o tkWindow.o TTK_OBJS = \ ttkBlink.o ttkButton.o ttkCache.o ttkClamTheme.o ttkClassicTheme.o \ @@ -431,6 +432,7 @@ GENERIC_SRCS = \ $(GENERIC_DIR)/tkGrid.c $(GENERIC_DIR)/tkConsole.c \ $(GENERIC_DIR)/tkMain.c $(GENERIC_DIR)/tkOption.c \ $(GENERIC_DIR)/tkPack.c $(GENERIC_DIR)/tkPlace.c \ + $(GENERIC_DIR)/tkPkgConfig.c \ $(GENERIC_DIR)/tkSelect.c $(GENERIC_DIR)/tkStyle.c \ $(GENERIC_DIR)/tkUndo.c $(GENERIC_DIR)/tkUtil.c \ $(GENERIC_DIR)/tkVisual.c $(GENERIC_DIR)/tkWindow.c \ @@ -1009,6 +1011,32 @@ tkOption.o: $(GENERIC_DIR)/tkOption.c tkPack.o: $(GENERIC_DIR)/tkPack.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkPack.c +# TIP #59, embedding of configuration information into the binary library. +# +# Part of Tk's configuration information are the paths where it was installed +# and where it will look for its libraries (which can be different). We derive +# this information from the variables which can be overridden by the user. As +# every path can be configured separately we do not remember one general +# prefix/exec_prefix but all the different paths individually. + +tkPkgConfig.o: $(GENERIC_DIR)/tkPkgConfig.c + $(CC) -c $(CC_SWITCHES) \ + -DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR)\"" \ + -DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR)\"" \ + -DCFG_INSTALL_SCRDIR="\"$(SCRIPT_INSTALL_DIR)\"" \ + -DCFG_INSTALL_INCDIR="\"$(INCLUDE_INSTALL_DIR)\"" \ + -DCFG_INSTALL_DOCDIR="\"$(MAN_INSTALL_DIR)\"" \ + -DCFG_INSTALL_DEMODIR="\"$(DEMO_INSTALL_DIR)\"" \ + \ + -DCFG_RUNTIME_LIBDIR="\"$(libdir)\"" \ + -DCFG_RUNTIME_BINDIR="\"$(bindir)\"" \ + -DCFG_RUNTIME_SCRDIR="\"$(TK_LIBRARY)\"" \ + -DCFG_RUNTIME_INCDIR="\"$(includedir)\"" \ + -DCFG_RUNTIME_DOCDIR="\"$(mandir)\"" \ + -DCFG_RUNTIME_DEMODIR="\"$(DEMO_INSTALL_DIR)\"" \ + \ + $(GENERIC_DIR)/tkPkgConfig.c + tkPlace.o: $(GENERIC_DIR)/tkPlace.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkPlace.c diff --git a/unix/configure b/unix/configure index 894f7d8..e8fb0d4 100755 --- a/unix/configure +++ b/unix/configure @@ -766,6 +766,7 @@ with_tcl enable_man_symlinks enable_man_compression enable_man_suffix +with_encoding enable_threads enable_shared enable_64bit @@ -1430,6 +1431,8 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-tcl directory containing tcl configuration (tclConfig.sh) + --with-encoding encoding for configuration values (default: + iso8859-1) --with-x use the X Window System Some influential environment variables: @@ -3950,6 +3953,31 @@ $as_echo "$tcl_cv_cc_pipe" >&6; } fi #------------------------------------------------------------------------ +# Embedded configuration information, encoding to use for the values, TIP #59 +#------------------------------------------------------------------------ + + + +# Check whether --with-encoding was given. +if test "${with_encoding+set}" = set; then : + withval=$with_encoding; with_tcencoding=${withval} +fi + + + if test x"${with_tcencoding}" != x ; then + +cat >>confdefs.h <<_ACEOF +#define TCL_CFGVAL_ENCODING "${with_tcencoding}" +_ACEOF + + else + +$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h + + fi + + +#------------------------------------------------------------------------ # Threads support - this auto-enables if Tcl was compiled threaded #------------------------------------------------------------------------ diff --git a/unix/configure.ac b/unix/configure.ac index 9c9765f..59c7601 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -111,6 +111,12 @@ if test -z "$no_pipe" && test -n "$GCC"; then fi #------------------------------------------------------------------------ +# Embedded configuration information, encoding to use for the values, TIP #59 +#------------------------------------------------------------------------ + +SC_TCL_CFG_ENCODING + +#------------------------------------------------------------------------ # Threads support - this auto-enables if Tcl was compiled threaded #------------------------------------------------------------------------ diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index 4fd7726..99e87f9 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -136,6 +136,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* What encoding should be used for embedded configuration info? */ +#undef TCL_CFGVAL_ENCODING + /* Is this a 64-bit build? */ #undef TCL_CFG_DO64BIT diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 9c1116d..379af05 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -57,24 +57,13 @@ static Tcl_ThreadDataKey dataKey; /* * Package initialization: - * Nothing to do here except register the fact that we're using Xft in - * the TIP 59 configuration database. + * Nothing to do! */ -#ifndef TCL_CFGVAL_ENCODING -#define TCL_CFGVAL_ENCODING "ascii" -#endif - void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - static const Tcl_Config cfg[] = { - { "fontsystem", "xft" }, - { 0,0 } - }; - - Tcl_RegisterConfig(mainPtr->interp, "tk", cfg, TCL_CFGVAL_ENCODING); } static XftFont * |