Fossil SCM

Enable building with the TCL stubs library and then loading the main TCL library at run-time, and only if needed.

drh 2012-10-02 23:01 trunk merge
Commit 25f7fa1157482b6d797777272cc31aa090cf3cf4
--- Makefile.in
+++ Makefile.in
@@ -41,10 +41,11 @@
4141
LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
4242
TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H
4343
INSTALLDIR = $(DESTDIR)@prefix@/bin
4444
USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
4545
FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
46
+FOSSIL_ENABLE_TCL_STUBS = @FOSSIL_ENABLE_TCL_STUBS@
4647
4748
include $(SRCDIR)/main.mk
4849
4950
distclean: clean
5051
rm -f autoconfig.h config.log Makefile
5152
--- Makefile.in
+++ Makefile.in
@@ -41,10 +41,11 @@
41 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
42 TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H
43 INSTALLDIR = $(DESTDIR)@prefix@/bin
44 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
45 FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
 
46
47 include $(SRCDIR)/main.mk
48
49 distclean: clean
50 rm -f autoconfig.h config.log Makefile
51
--- Makefile.in
+++ Makefile.in
@@ -41,10 +41,11 @@
41 LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@
42 TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H
43 INSTALLDIR = $(DESTDIR)@prefix@/bin
44 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
45 FOSSIL_ENABLE_TCL = @FOSSIL_ENABLE_TCL@
46 FOSSIL_ENABLE_TCL_STUBS = @FOSSIL_ENABLE_TCL_STUBS@
47
48 include $(SRCDIR)/main.mk
49
50 distclean: clean
51 rm -f autoconfig.h config.log Makefile
52
+37 -23
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
55
options {
66
with-openssl:path|auto|none
77
=> {Look for openssl in the given path, or auto or none}
88
with-zlib:path => {Look for zlib in the given path}
99
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
10
+ with-tcl-stubs=0 => {Enable Tcl integration via stubs mechanism}
1011
internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
1112
static=0 => {Link a static executable}
1213
lineedit=1 => {Disable line editing}
1314
fossil-debug=0 => {Build with fossil debugging enabled}
1415
json=0 => {Build with fossil JSON API enabled}
@@ -32,11 +33,11 @@
3233
if {![opt-bool internal-sqlite]} {
3334
proc find_internal_sqlite {} {
3435
3536
# On some systems (slackware), libsqlite3 requires -ldl to link. So
3637
# search for the system SQLite once with -ldl, and once without. If
37
- # the library can only be found with $extralibs set to -ldl, then
38
+ # the library can only be found with $extralibs set to -ldl, then
3839
# the code below will append -ldl to LIBS.
3940
#
4041
foreach extralibs {{} {-ldl}} {
4142
4243
# Locate the system SQLite by searching for sqlite3_open(). Then check
@@ -92,35 +93,48 @@
9293
user-error "zlib not found please install it or specify the location with --with-zlib"
9394
}
9495
9596
set tclpath [opt-val with-tcl]
9697
if {$tclpath ne ""} {
97
- # Note parse-tclconfig-sh is in autosetup/local.tcl
98
+ # Note parse-tclconfig-sh is in autosetup/local.tcl
9899
if {$tclpath eq "1"} {
99100
# Use the system Tcl. Look in some likely places.
100
- array set tclconfig [parse-tclconfig-sh /usr /usr/local /usr/share /opt/local]
101
- set msg "on your system"
102
- } else {
101
+ array set tclconfig [parse-tclconfig-sh \
102
+ /usr /usr/local /usr/share /opt/local]
103
+ set msg "on your system"
104
+ } else {
103105
array set tclconfig [parse-tclconfig-sh $tclpath]
104
- set msg "at $tclpath"
105
- }
106
- if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} {
107
- user-error "Cannot find Tcl $msg"
108
- }
109
- set cflags $tclconfig(TCL_INCLUDE_SPEC)
110
- set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
111
- cc-with [list -cflags $cflags -libs $libs] {
112
- if {![cc-check-functions Tcl_CreateInterp]} {
113
- user-error "Cannot find a usable Tcl $msg"
114
- }
115
- }
116
- set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
117
- msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
118
- define-append LIBS $libs
119
- define-append EXTRA_CFLAGS $cflags
120
- define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
121
-
106
+ set msg "at $tclpath"
107
+ }
108
+ if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} {
109
+ user-error "Cannot find Tcl $msg"
110
+ }
111
+ set tclstubs [opt-bool with-tcl-stubs]
112
+ if {$tclstubs && $tclconfig(TCL_SUPPORTS_STUBS)} {
113
+ set libs "$tclconfig(TCL_STUB_LIB_SPEC)"
114
+ define FOSSIL_ENABLE_TCL_STUBS
115
+ define USE_TCL_STUBS
116
+ } else {
117
+ set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
118
+ }
119
+ set cflags $tclconfig(TCL_INCLUDE_SPEC)
120
+ cc-with [list -cflags $cflags -libs $libs] {
121
+ if {$tclstubs} {
122
+ if {![cc-check-functions Tcl_InitStubs]} {
123
+ user-error "Cannot find a usable Tcl stubs library $msg"
124
+ }
125
+ } else {
126
+ if {![cc-check-functions Tcl_CreateInterp]} {
127
+ user-error "Cannot find a usable Tcl library $msg"
128
+ }
129
+ }
130
+ }
131
+ set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
132
+ msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
133
+ define-append LIBS $libs
134
+ define-append EXTRA_CFLAGS $cflags
135
+ define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
122136
define FOSSIL_ENABLE_TCL
123137
}
124138
125139
# Helper for openssl checking
126140
proc check-for-openssl {msg {cflags {}}} {
127141
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
5 options {
6 with-openssl:path|auto|none
7 => {Look for openssl in the given path, or auto or none}
8 with-zlib:path => {Look for zlib in the given path}
9 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
 
10 internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
11 static=0 => {Link a static executable}
12 lineedit=1 => {Disable line editing}
13 fossil-debug=0 => {Build with fossil debugging enabled}
14 json=0 => {Build with fossil JSON API enabled}
@@ -32,11 +33,11 @@
32 if {![opt-bool internal-sqlite]} {
33 proc find_internal_sqlite {} {
34
35 # On some systems (slackware), libsqlite3 requires -ldl to link. So
36 # search for the system SQLite once with -ldl, and once without. If
37 # the library can only be found with $extralibs set to -ldl, then
38 # the code below will append -ldl to LIBS.
39 #
40 foreach extralibs {{} {-ldl}} {
41
42 # Locate the system SQLite by searching for sqlite3_open(). Then check
@@ -92,35 +93,48 @@
92 user-error "zlib not found please install it or specify the location with --with-zlib"
93 }
94
95 set tclpath [opt-val with-tcl]
96 if {$tclpath ne ""} {
97 # Note parse-tclconfig-sh is in autosetup/local.tcl
98 if {$tclpath eq "1"} {
99 # Use the system Tcl. Look in some likely places.
100 array set tclconfig [parse-tclconfig-sh /usr /usr/local /usr/share /opt/local]
101 set msg "on your system"
102 } else {
 
103 array set tclconfig [parse-tclconfig-sh $tclpath]
104 set msg "at $tclpath"
105 }
106 if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} {
107 user-error "Cannot find Tcl $msg"
108 }
109 set cflags $tclconfig(TCL_INCLUDE_SPEC)
110 set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
111 cc-with [list -cflags $cflags -libs $libs] {
112 if {![cc-check-functions Tcl_CreateInterp]} {
113 user-error "Cannot find a usable Tcl $msg"
114 }
115 }
116 set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
117 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
118 define-append LIBS $libs
119 define-append EXTRA_CFLAGS $cflags
120 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
121
 
 
 
 
 
 
 
 
 
 
 
 
122 define FOSSIL_ENABLE_TCL
123 }
124
125 # Helper for openssl checking
126 proc check-for-openssl {msg {cflags {}}} {
127
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
5 options {
6 with-openssl:path|auto|none
7 => {Look for openssl in the given path, or auto or none}
8 with-zlib:path => {Look for zlib in the given path}
9 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
10 with-tcl-stubs=0 => {Enable Tcl integration via stubs mechanism}
11 internal-sqlite=1 => {Don't use the internal sqlite, use the system one}
12 static=0 => {Link a static executable}
13 lineedit=1 => {Disable line editing}
14 fossil-debug=0 => {Build with fossil debugging enabled}
15 json=0 => {Build with fossil JSON API enabled}
@@ -32,11 +33,11 @@
33 if {![opt-bool internal-sqlite]} {
34 proc find_internal_sqlite {} {
35
36 # On some systems (slackware), libsqlite3 requires -ldl to link. So
37 # search for the system SQLite once with -ldl, and once without. If
38 # the library can only be found with $extralibs set to -ldl, then
39 # the code below will append -ldl to LIBS.
40 #
41 foreach extralibs {{} {-ldl}} {
42
43 # Locate the system SQLite by searching for sqlite3_open(). Then check
@@ -92,35 +93,48 @@
93 user-error "zlib not found please install it or specify the location with --with-zlib"
94 }
95
96 set tclpath [opt-val with-tcl]
97 if {$tclpath ne ""} {
98 # Note parse-tclconfig-sh is in autosetup/local.tcl
99 if {$tclpath eq "1"} {
100 # Use the system Tcl. Look in some likely places.
101 array set tclconfig [parse-tclconfig-sh \
102 /usr /usr/local /usr/share /opt/local]
103 set msg "on your system"
104 } else {
105 array set tclconfig [parse-tclconfig-sh $tclpath]
106 set msg "at $tclpath"
107 }
108 if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} {
109 user-error "Cannot find Tcl $msg"
110 }
111 set tclstubs [opt-bool with-tcl-stubs]
112 if {$tclstubs && $tclconfig(TCL_SUPPORTS_STUBS)} {
113 set libs "$tclconfig(TCL_STUB_LIB_SPEC)"
114 define FOSSIL_ENABLE_TCL_STUBS
115 define USE_TCL_STUBS
116 } else {
117 set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)"
118 }
119 set cflags $tclconfig(TCL_INCLUDE_SPEC)
120 cc-with [list -cflags $cflags -libs $libs] {
121 if {$tclstubs} {
122 if {![cc-check-functions Tcl_InitStubs]} {
123 user-error "Cannot find a usable Tcl stubs library $msg"
124 }
125 } else {
126 if {![cc-check-functions Tcl_CreateInterp]} {
127 user-error "Cannot find a usable Tcl library $msg"
128 }
129 }
130 }
131 set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
132 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
133 define-append LIBS $libs
134 define-append EXTRA_CFLAGS $cflags
135 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
136 define FOSSIL_ENABLE_TCL
137 }
138
139 # Helper for openssl checking
140 proc check-for-openssl {msg {cflags {}}} {
141
+3
--- src/main.c
+++ src/main.c
@@ -90,10 +90,13 @@
9090
** "th_tcl.c".
9191
*/
9292
struct TclContext {
9393
int argc;
9494
char **argv;
95
+ void *library;
96
+ void *xFindExecutable; /* see tcl_FindExecutableProc in th_tcl.c */
97
+ void *xCreateInterp; /* see tcl_CreateInterpProc in th_tcl.c */
9598
Tcl_Interp *interp;
9699
};
97100
#endif
98101
99102
/*
100103
--- src/main.c
+++ src/main.c
@@ -90,10 +90,13 @@
90 ** "th_tcl.c".
91 */
92 struct TclContext {
93 int argc;
94 char **argv;
 
 
 
95 Tcl_Interp *interp;
96 };
97 #endif
98
99 /*
100
--- src/main.c
+++ src/main.c
@@ -90,10 +90,13 @@
90 ** "th_tcl.c".
91 */
92 struct TclContext {
93 int argc;
94 char **argv;
95 void *library;
96 void *xFindExecutable; /* see tcl_FindExecutableProc in th_tcl.c */
97 void *xCreateInterp; /* see tcl_CreateInterpProc in th_tcl.c */
98 Tcl_Interp *interp;
99 };
100 #endif
101
102 /*
103
+22 -2
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -375,10 +375,14 @@
375375
# FOSSIL_ENABLE_SSL = 1
376376
377377
#### Enable scripting support via Tcl/Tk
378378
#
379379
# FOSSIL_ENABLE_TCL = 1
380
+
381
+#### Load Tcl using the stubs mechanism
382
+#
383
+# FOSSIL_ENABLE_TCL_STUBS = 1
380384
381385
#### Use the Tcl source directory instead of the install directory?
382386
# This is useful when Tcl has been compiled statically with MinGW.
383387
#
384388
FOSSIL_TCL_SOURCE = 1
@@ -424,11 +428,15 @@
424428
TCLINCDIR = $(TCLDIR)/include
425429
TCLLIBDIR = $(TCLDIR)/lib
426430
427431
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
428432
#
433
+ifdef FOSSIL_ENABLE_TCL_STUBS
434
+LIBTCL = -ltclstub86
435
+else
429436
LIBTCL = -ltcl86
437
+endif
430438
431439
#### C Compile and options for use in building executables that
432440
# will run on the target platform. This is usually the same
433441
# as BCC, unless you are cross-compiling. This C compiler builds
434442
# the finished binary for fossil. The BCC compiler above is used
@@ -462,14 +470,22 @@
462470
ifdef FOSSIL_ENABLE_SSL
463471
TCC += -DFOSSIL_ENABLE_SSL=1
464472
RCC += -DFOSSIL_ENABLE_SSL=1
465473
endif
466474
467
-# With Tcl support (statically linked)
475
+# With Tcl support
468476
ifdef FOSSIL_ENABLE_TCL
469
-TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
477
+TCC += -DFOSSIL_ENABLE_TCL=1
470478
RCC += -DFOSSIL_ENABLE_TCL=1
479
+# Either statically linked or via stubs
480
+ifdef FOSSIL_ENABLE_TCL_STUBS
481
+TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
482
+RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
483
+else
484
+TCC += -DSTATIC_BUILD
485
+RCC += -DSTATIC_BUILD
486
+endif
471487
endif
472488
473489
# With JSON support
474490
ifdef FOSSIL_ENABLE_JSON
475491
TCC += -DFOSSIL_ENABLE_JSON=1
@@ -499,11 +515,15 @@
499515
500516
#### These libraries MUST appear in the same order as they do for Tcl
501517
# or linking with it will not work (exact reason unknown).
502518
#
503519
ifdef FOSSIL_ENABLE_TCL
520
+ifdef FOSSIL_ENABLE_TCL_STUBS
521
+LIB += -lkernel32 -lws2_32
522
+else
504523
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
524
+endif
505525
else
506526
LIB += -lkernel32 -lws2_32
507527
endif
508528
509529
#### Tcl shell for use in running the fossil test suite. This is only
510530
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -375,10 +375,14 @@
375 # FOSSIL_ENABLE_SSL = 1
376
377 #### Enable scripting support via Tcl/Tk
378 #
379 # FOSSIL_ENABLE_TCL = 1
 
 
 
 
380
381 #### Use the Tcl source directory instead of the install directory?
382 # This is useful when Tcl has been compiled statically with MinGW.
383 #
384 FOSSIL_TCL_SOURCE = 1
@@ -424,11 +428,15 @@
424 TCLINCDIR = $(TCLDIR)/include
425 TCLLIBDIR = $(TCLDIR)/lib
426
427 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
428 #
 
 
 
429 LIBTCL = -ltcl86
 
430
431 #### C Compile and options for use in building executables that
432 # will run on the target platform. This is usually the same
433 # as BCC, unless you are cross-compiling. This C compiler builds
434 # the finished binary for fossil. The BCC compiler above is used
@@ -462,14 +470,22 @@
462 ifdef FOSSIL_ENABLE_SSL
463 TCC += -DFOSSIL_ENABLE_SSL=1
464 RCC += -DFOSSIL_ENABLE_SSL=1
465 endif
466
467 # With Tcl support (statically linked)
468 ifdef FOSSIL_ENABLE_TCL
469 TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
470 RCC += -DFOSSIL_ENABLE_TCL=1
 
 
 
 
 
 
 
 
471 endif
472
473 # With JSON support
474 ifdef FOSSIL_ENABLE_JSON
475 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -499,11 +515,15 @@
499
500 #### These libraries MUST appear in the same order as they do for Tcl
501 # or linking with it will not work (exact reason unknown).
502 #
503 ifdef FOSSIL_ENABLE_TCL
 
 
 
504 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 
505 else
506 LIB += -lkernel32 -lws2_32
507 endif
508
509 #### Tcl shell for use in running the fossil test suite. This is only
510
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -375,10 +375,14 @@
375 # FOSSIL_ENABLE_SSL = 1
376
377 #### Enable scripting support via Tcl/Tk
378 #
379 # FOSSIL_ENABLE_TCL = 1
380
381 #### Load Tcl using the stubs mechanism
382 #
383 # FOSSIL_ENABLE_TCL_STUBS = 1
384
385 #### Use the Tcl source directory instead of the install directory?
386 # This is useful when Tcl has been compiled statically with MinGW.
387 #
388 FOSSIL_TCL_SOURCE = 1
@@ -424,11 +428,15 @@
428 TCLINCDIR = $(TCLDIR)/include
429 TCLLIBDIR = $(TCLDIR)/lib
430
431 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
432 #
433 ifdef FOSSIL_ENABLE_TCL_STUBS
434 LIBTCL = -ltclstub86
435 else
436 LIBTCL = -ltcl86
437 endif
438
439 #### C Compile and options for use in building executables that
440 # will run on the target platform. This is usually the same
441 # as BCC, unless you are cross-compiling. This C compiler builds
442 # the finished binary for fossil. The BCC compiler above is used
@@ -462,14 +470,22 @@
470 ifdef FOSSIL_ENABLE_SSL
471 TCC += -DFOSSIL_ENABLE_SSL=1
472 RCC += -DFOSSIL_ENABLE_SSL=1
473 endif
474
475 # With Tcl support
476 ifdef FOSSIL_ENABLE_TCL
477 TCC += -DFOSSIL_ENABLE_TCL=1
478 RCC += -DFOSSIL_ENABLE_TCL=1
479 # Either statically linked or via stubs
480 ifdef FOSSIL_ENABLE_TCL_STUBS
481 TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
482 RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
483 else
484 TCC += -DSTATIC_BUILD
485 RCC += -DSTATIC_BUILD
486 endif
487 endif
488
489 # With JSON support
490 ifdef FOSSIL_ENABLE_JSON
491 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -499,11 +515,15 @@
515
516 #### These libraries MUST appear in the same order as they do for Tcl
517 # or linking with it will not work (exact reason unknown).
518 #
519 ifdef FOSSIL_ENABLE_TCL
520 ifdef FOSSIL_ENABLE_TCL_STUBS
521 LIB += -lkernel32 -lws2_32
522 else
523 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
524 endif
525 else
526 LIB += -lkernel32 -lws2_32
527 endif
528
529 #### Tcl shell for use in running the fossil test suite. This is only
530
+153 -8
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -32,11 +32,11 @@
3232
((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6))
3333
/*
3434
** Workaround NRE-specific issue in Tcl_EvalObjCmd (SF bug #3399564) by using
3535
** Tcl_EvalObjv instead of invoking the objProc directly.
3636
*/
37
-#define USE_TCL_EVALOBJV 1
37
+# define USE_TCL_EVALOBJV 1
3838
#endif
3939
4040
/*
4141
** These macros are designed to reduce the redundant code required to marshal
4242
** arguments from TH1 to Tcl.
@@ -65,10 +65,76 @@
6565
** context.
6666
*/
6767
#define GET_CTX_TCL_INTERP(ctx) \
6868
((struct TclContext *)(ctx))->interp
6969
70
+/*
71
+** Define the Tcl shared library name, some exported function names, and some
72
+** cross-platform macros for use with the Tcl stubs mechanism, when enabled.
73
+ */
74
+#if defined(USE_TCL_STUBS)
75
+# if defined(_WIN32)
76
+# define WIN32_LEAN_AND_MEAN
77
+# include <windows.h>
78
+# ifndef TCL_LIBRARY_NAME
79
+# define TCL_LIBRARY_NAME "tcl86.dll\0"
80
+# endif
81
+# ifndef TCL_MINOR_OFFSET
82
+# define TCL_MINOR_OFFSET (4)
83
+# endif
84
+# ifndef dlopen
85
+# define dlopen(a,b) (void *)LoadLibrary((a));
86
+# endif
87
+# ifndef dlsym
88
+# define dlsym(a,b) GetProcAddress((HANDLE)(a),(b));
89
+# endif
90
+# ifndef dlclose
91
+# define dlclose(a) FreeLibrary((HANDLE)(a));
92
+# endif
93
+# else
94
+# include <dlfcn.h>
95
+# if defined(__CYGWIN__)
96
+# ifndef TCL_LIBRARY_NAME
97
+# define TCL_LIBRARY_NAME "libtcl8.6.dll\0"
98
+# endif
99
+# ifndef TCL_MINOR_OFFSET
100
+# define TCL_MINOR_OFFSET (8)
101
+# endif
102
+# elif defined(__APPLE__)
103
+# ifndef TCL_LIBRARY_NAME
104
+# define TCL_LIBRARY_NAME "libtcl8.6.dylib\0"
105
+# endif
106
+# ifndef TCL_MINOR_OFFSET
107
+# define TCL_MINOR_OFFSET (8)
108
+# endif
109
+# else
110
+# ifndef TCL_LIBRARY_NAME
111
+# define TCL_LIBRARY_NAME "libtcl8.6.so\0"
112
+# endif
113
+# ifndef TCL_MINOR_OFFSET
114
+# define TCL_MINOR_OFFSET (8)
115
+# endif
116
+# endif /* defined(__CYGWIN__) */
117
+# endif /* defined(_WIN32) */
118
+# ifndef TCL_FINDEXECUTABLE_NAME
119
+# define TCL_FINDEXECUTABLE_NAME "_Tcl_FindExecutable"
120
+# endif
121
+# ifndef TCL_CREATEINTERP_NAME
122
+# define TCL_CREATEINTERP_NAME "_Tcl_CreateInterp"
123
+# endif
124
+#endif /* defined(USE_TCL_STUBS) */
125
+
126
+/*
127
+** The function pointer types for Tcl_FindExecutable and Tcl_CreateInterp are
128
+** needed when the Tcl library is being loaded dynamically by a stubs-enabled
129
+** application (i.e. the inverse of using a stubs-enabled package). These are
130
+** the only Tcl API functions that MUST be called prior to being able to call
131
+** Tcl_InitStubs (i.e. because it requires a Tcl interpreter).
132
+ */
133
+typedef void (tcl_FindExecutableProc) (CONST char * argv0);
134
+typedef Tcl_Interp *(tcl_CreateInterpProc) (void);
135
+
70136
/*
71137
** Creates and initializes a Tcl interpreter for use with the specified TH1
72138
** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
73139
** by the caller. This must be declared here because quite a few functions in
74140
** this file need to use it before it can be defined.
@@ -102,10 +168,13 @@
102168
** copied from and should be kept in sync with the one in "main.c".
103169
*/
104170
struct TclContext {
105171
int argc;
106172
char **argv;
173
+ void *library;
174
+ tcl_FindExecutableProc *xFindExecutable;
175
+ tcl_CreateInterpProc *xCreateInterp;
107176
Tcl_Interp *interp;
108177
};
109178
110179
/*
111180
** Syntax:
@@ -224,18 +293,18 @@
224293
int argc,
225294
const char **argv,
226295
int *argl
227296
){
228297
Tcl_Interp *tclInterp;
229
-#ifndef USE_TCL_EVALOBJV
298
+#if !defined(USE_TCL_EVALOBJV)
230299
Tcl_Command command;
231300
Tcl_CmdInfo cmdInfo;
232301
#endif
233302
int rc;
234303
int nResult;
235304
const char *zResult;
236
-#ifndef USE_TCL_EVALOBJV
305
+#if !defined(USE_TCL_EVALOBJV)
237306
Tcl_Obj *objPtr;
238307
#endif
239308
USE_ARGV_TO_OBJV();
240309
241310
if ( createTclInterp(interp, ctx)!=TH_OK ){
@@ -248,11 +317,11 @@
248317
if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){
249318
Th_ErrorMessage(interp, "invalid Tcl interpreter", (const char *)"", 0);
250319
return TH_ERROR;
251320
}
252321
Tcl_Preserve((ClientData)tclInterp);
253
-#ifndef USE_TCL_EVALOBJV
322
+#if !defined(USE_TCL_EVALOBJV)
254323
objPtr = Tcl_NewStringObj(argv[1], argl[1]);
255324
Tcl_IncrRefCount(objPtr);
256325
command = Tcl_GetCommandFromObj(tclInterp, objPtr);
257326
if( !command || Tcl_GetCommandInfoFromToken(command,&cmdInfo)==0 ){
258327
Th_ErrorMessage(interp, "Tcl command not found:", argv[1], argl[1]);
@@ -267,11 +336,11 @@
267336
return TH_ERROR;
268337
}
269338
Tcl_DecrRefCount(objPtr);
270339
#endif
271340
COPY_ARGV_TO_OBJV();
272
-#ifdef USE_TCL_EVALOBJV
341
+#if defined(USE_TCL_EVALOBJV)
273342
rc = Tcl_EvalObjv(tclInterp, objc, objv, 0);
274343
#else
275344
Tcl_ResetResult(tclInterp);
276345
rc = cmdInfo.objProc(cmdInfo.objClientData, tclInterp, objc, objv);
277346
#endif
@@ -375,10 +444,77 @@
375444
/* Remove the Tcl integration commands. */
376445
for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){
377446
Th_RenameCommand(th1Interp, aCommand[i].zName, -1, NULL, 0);
378447
}
379448
}
449
+
450
+/*
451
+** When Tcl stubs support is enabled, attempts to dynamically load the Tcl
452
+** shared library and fetch the function pointers necessary to create an
453
+** interpreter and initialize the stubs mechanism; otherwise, simply setup
454
+** the function pointers provided by the caller with the statically linked
455
+** functions.
456
+ */
457
+static int loadTcl(
458
+ Th_Interp *interp,
459
+ void **pLibrary,
460
+ tcl_FindExecutableProc **pxFindExecutable,
461
+ tcl_CreateInterpProc **pxCreateInterp
462
+){
463
+#if defined(USE_TCL_STUBS)
464
+ char fileName[] = TCL_LIBRARY_NAME;
465
+#endif
466
+ if( !pLibrary || !pxFindExecutable || !pxCreateInterp ){
467
+ Th_ErrorMessage(interp,
468
+ "Invalid Tcl loader argument(s)", (const char *)"", 0);
469
+ return TH_ERROR;
470
+ }
471
+#if defined(USE_TCL_STUBS)
472
+ do {
473
+ void *library = dlopen(fileName, RTLD_NOW | RTLD_GLOBAL);
474
+ if( library ){
475
+ tcl_FindExecutableProc *xFindExecutable;
476
+ tcl_CreateInterpProc *xCreateInterp;
477
+ const char *procName = TCL_FINDEXECUTABLE_NAME;
478
+ xFindExecutable = (tcl_FindExecutableProc *)dlsym(library, procName + 1);
479
+ if( !xFindExecutable ){
480
+ xFindExecutable = (tcl_FindExecutableProc *)dlsym(library, procName);
481
+ }
482
+ if( !xFindExecutable ){
483
+ Th_ErrorMessage(interp,
484
+ "Could not locate Tcl_FindExecutable", (const char *)"", 0);
485
+ dlclose(library);
486
+ return TH_ERROR;
487
+ }
488
+ procName = TCL_CREATEINTERP_NAME;
489
+ xCreateInterp = (tcl_CreateInterpProc *)dlsym(library, procName + 1);
490
+ if( !xCreateInterp ){
491
+ xCreateInterp = (tcl_CreateInterpProc *)dlsym(library, procName);
492
+ }
493
+ if( !xCreateInterp ){
494
+ Th_ErrorMessage(interp,
495
+ "Could not locate Tcl_CreateInterp", (const char *)"", 0);
496
+ dlclose(library);
497
+ return TH_ERROR;
498
+ }
499
+ *pLibrary = library;
500
+ *pxFindExecutable = xFindExecutable;
501
+ *pxCreateInterp = xCreateInterp;
502
+ return TH_OK;
503
+ }
504
+ } while( --fileName[TCL_MINOR_OFFSET]>'3' ); /* Tcl 8.4+ */
505
+ Th_ErrorMessage(interp,
506
+ "Could not load Tcl shared library \"" TCL_LIBRARY_NAME "\"",
507
+ (const char *)"", 0);
508
+ return TH_ERROR;
509
+#else
510
+ *pLibrary = 0;
511
+ *pxFindExecutable = Tcl_FindExecutable;
512
+ *pxCreateInterp = Tcl_CreateInterp;
513
+ return TH_OK;
514
+#endif
515
+}
380516
381517
/*
382518
** Sets the "argv0", "argc", and "argv" script variables in the Tcl interpreter
383519
** based on the supplied command line arguments.
384520
*/
@@ -454,23 +590,32 @@
454590
"Invalid Tcl context", (const char *)"", 0);
455591
return TH_ERROR;
456592
}
457593
if ( tclContext->interp ){
458594
return TH_OK;
595
+ }
596
+ if( loadTcl(interp, &tclContext->library, &tclContext->xFindExecutable,
597
+ &tclContext->xCreateInterp)!=TH_OK ){
598
+ return TH_ERROR;
459599
}
460600
argc = tclContext->argc;
461601
argv = tclContext->argv;
462602
if( argc>0 && argv ){
463603
argv0 = argv[0];
464604
}
465
- Tcl_FindExecutable(argv0);
466
- tclInterp = tclContext->interp = Tcl_CreateInterp();
467
- if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){
605
+ tclContext->xFindExecutable(argv0);
606
+ tclInterp = tclContext->xCreateInterp();
607
+ if( !tclInterp ||
608
+#if defined(USE_TCL_STUBS)
609
+ !Tcl_InitStubs(tclInterp, "8.4", 0) ||
610
+#endif
611
+ Tcl_InterpDeleted(tclInterp) ){
468612
Th_ErrorMessage(interp,
469613
"Could not create Tcl interpreter", (const char *)"", 0);
470614
return TH_ERROR;
471615
}
616
+ tclContext->interp = tclInterp;
472617
if( Tcl_Init(tclInterp)!=TCL_OK ){
473618
Th_ErrorMessage(interp,
474619
"Tcl initialization error:", Tcl_GetStringResult(tclInterp), -1);
475620
Tcl_DeleteInterp(tclInterp);
476621
tclContext->interp = tclInterp = 0;
477622
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -32,11 +32,11 @@
32 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6))
33 /*
34 ** Workaround NRE-specific issue in Tcl_EvalObjCmd (SF bug #3399564) by using
35 ** Tcl_EvalObjv instead of invoking the objProc directly.
36 */
37 #define USE_TCL_EVALOBJV 1
38 #endif
39
40 /*
41 ** These macros are designed to reduce the redundant code required to marshal
42 ** arguments from TH1 to Tcl.
@@ -65,10 +65,76 @@
65 ** context.
66 */
67 #define GET_CTX_TCL_INTERP(ctx) \
68 ((struct TclContext *)(ctx))->interp
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70 /*
71 ** Creates and initializes a Tcl interpreter for use with the specified TH1
72 ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
73 ** by the caller. This must be declared here because quite a few functions in
74 ** this file need to use it before it can be defined.
@@ -102,10 +168,13 @@
102 ** copied from and should be kept in sync with the one in "main.c".
103 */
104 struct TclContext {
105 int argc;
106 char **argv;
 
 
 
107 Tcl_Interp *interp;
108 };
109
110 /*
111 ** Syntax:
@@ -224,18 +293,18 @@
224 int argc,
225 const char **argv,
226 int *argl
227 ){
228 Tcl_Interp *tclInterp;
229 #ifndef USE_TCL_EVALOBJV
230 Tcl_Command command;
231 Tcl_CmdInfo cmdInfo;
232 #endif
233 int rc;
234 int nResult;
235 const char *zResult;
236 #ifndef USE_TCL_EVALOBJV
237 Tcl_Obj *objPtr;
238 #endif
239 USE_ARGV_TO_OBJV();
240
241 if ( createTclInterp(interp, ctx)!=TH_OK ){
@@ -248,11 +317,11 @@
248 if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){
249 Th_ErrorMessage(interp, "invalid Tcl interpreter", (const char *)"", 0);
250 return TH_ERROR;
251 }
252 Tcl_Preserve((ClientData)tclInterp);
253 #ifndef USE_TCL_EVALOBJV
254 objPtr = Tcl_NewStringObj(argv[1], argl[1]);
255 Tcl_IncrRefCount(objPtr);
256 command = Tcl_GetCommandFromObj(tclInterp, objPtr);
257 if( !command || Tcl_GetCommandInfoFromToken(command,&cmdInfo)==0 ){
258 Th_ErrorMessage(interp, "Tcl command not found:", argv[1], argl[1]);
@@ -267,11 +336,11 @@
267 return TH_ERROR;
268 }
269 Tcl_DecrRefCount(objPtr);
270 #endif
271 COPY_ARGV_TO_OBJV();
272 #ifdef USE_TCL_EVALOBJV
273 rc = Tcl_EvalObjv(tclInterp, objc, objv, 0);
274 #else
275 Tcl_ResetResult(tclInterp);
276 rc = cmdInfo.objProc(cmdInfo.objClientData, tclInterp, objc, objv);
277 #endif
@@ -375,10 +444,77 @@
375 /* Remove the Tcl integration commands. */
376 for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){
377 Th_RenameCommand(th1Interp, aCommand[i].zName, -1, NULL, 0);
378 }
379 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
381 /*
382 ** Sets the "argv0", "argc", and "argv" script variables in the Tcl interpreter
383 ** based on the supplied command line arguments.
384 */
@@ -454,23 +590,32 @@
454 "Invalid Tcl context", (const char *)"", 0);
455 return TH_ERROR;
456 }
457 if ( tclContext->interp ){
458 return TH_OK;
 
 
 
 
459 }
460 argc = tclContext->argc;
461 argv = tclContext->argv;
462 if( argc>0 && argv ){
463 argv0 = argv[0];
464 }
465 Tcl_FindExecutable(argv0);
466 tclInterp = tclContext->interp = Tcl_CreateInterp();
467 if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){
 
 
 
 
468 Th_ErrorMessage(interp,
469 "Could not create Tcl interpreter", (const char *)"", 0);
470 return TH_ERROR;
471 }
 
472 if( Tcl_Init(tclInterp)!=TCL_OK ){
473 Th_ErrorMessage(interp,
474 "Tcl initialization error:", Tcl_GetStringResult(tclInterp), -1);
475 Tcl_DeleteInterp(tclInterp);
476 tclContext->interp = tclInterp = 0;
477
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -32,11 +32,11 @@
32 ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6))
33 /*
34 ** Workaround NRE-specific issue in Tcl_EvalObjCmd (SF bug #3399564) by using
35 ** Tcl_EvalObjv instead of invoking the objProc directly.
36 */
37 # define USE_TCL_EVALOBJV 1
38 #endif
39
40 /*
41 ** These macros are designed to reduce the redundant code required to marshal
42 ** arguments from TH1 to Tcl.
@@ -65,10 +65,76 @@
65 ** context.
66 */
67 #define GET_CTX_TCL_INTERP(ctx) \
68 ((struct TclContext *)(ctx))->interp
69
70 /*
71 ** Define the Tcl shared library name, some exported function names, and some
72 ** cross-platform macros for use with the Tcl stubs mechanism, when enabled.
73 */
74 #if defined(USE_TCL_STUBS)
75 # if defined(_WIN32)
76 # define WIN32_LEAN_AND_MEAN
77 # include <windows.h>
78 # ifndef TCL_LIBRARY_NAME
79 # define TCL_LIBRARY_NAME "tcl86.dll\0"
80 # endif
81 # ifndef TCL_MINOR_OFFSET
82 # define TCL_MINOR_OFFSET (4)
83 # endif
84 # ifndef dlopen
85 # define dlopen(a,b) (void *)LoadLibrary((a));
86 # endif
87 # ifndef dlsym
88 # define dlsym(a,b) GetProcAddress((HANDLE)(a),(b));
89 # endif
90 # ifndef dlclose
91 # define dlclose(a) FreeLibrary((HANDLE)(a));
92 # endif
93 # else
94 # include <dlfcn.h>
95 # if defined(__CYGWIN__)
96 # ifndef TCL_LIBRARY_NAME
97 # define TCL_LIBRARY_NAME "libtcl8.6.dll\0"
98 # endif
99 # ifndef TCL_MINOR_OFFSET
100 # define TCL_MINOR_OFFSET (8)
101 # endif
102 # elif defined(__APPLE__)
103 # ifndef TCL_LIBRARY_NAME
104 # define TCL_LIBRARY_NAME "libtcl8.6.dylib\0"
105 # endif
106 # ifndef TCL_MINOR_OFFSET
107 # define TCL_MINOR_OFFSET (8)
108 # endif
109 # else
110 # ifndef TCL_LIBRARY_NAME
111 # define TCL_LIBRARY_NAME "libtcl8.6.so\0"
112 # endif
113 # ifndef TCL_MINOR_OFFSET
114 # define TCL_MINOR_OFFSET (8)
115 # endif
116 # endif /* defined(__CYGWIN__) */
117 # endif /* defined(_WIN32) */
118 # ifndef TCL_FINDEXECUTABLE_NAME
119 # define TCL_FINDEXECUTABLE_NAME "_Tcl_FindExecutable"
120 # endif
121 # ifndef TCL_CREATEINTERP_NAME
122 # define TCL_CREATEINTERP_NAME "_Tcl_CreateInterp"
123 # endif
124 #endif /* defined(USE_TCL_STUBS) */
125
126 /*
127 ** The function pointer types for Tcl_FindExecutable and Tcl_CreateInterp are
128 ** needed when the Tcl library is being loaded dynamically by a stubs-enabled
129 ** application (i.e. the inverse of using a stubs-enabled package). These are
130 ** the only Tcl API functions that MUST be called prior to being able to call
131 ** Tcl_InitStubs (i.e. because it requires a Tcl interpreter).
132 */
133 typedef void (tcl_FindExecutableProc) (CONST char * argv0);
134 typedef Tcl_Interp *(tcl_CreateInterpProc) (void);
135
136 /*
137 ** Creates and initializes a Tcl interpreter for use with the specified TH1
138 ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
139 ** by the caller. This must be declared here because quite a few functions in
140 ** this file need to use it before it can be defined.
@@ -102,10 +168,13 @@
168 ** copied from and should be kept in sync with the one in "main.c".
169 */
170 struct TclContext {
171 int argc;
172 char **argv;
173 void *library;
174 tcl_FindExecutableProc *xFindExecutable;
175 tcl_CreateInterpProc *xCreateInterp;
176 Tcl_Interp *interp;
177 };
178
179 /*
180 ** Syntax:
@@ -224,18 +293,18 @@
293 int argc,
294 const char **argv,
295 int *argl
296 ){
297 Tcl_Interp *tclInterp;
298 #if !defined(USE_TCL_EVALOBJV)
299 Tcl_Command command;
300 Tcl_CmdInfo cmdInfo;
301 #endif
302 int rc;
303 int nResult;
304 const char *zResult;
305 #if !defined(USE_TCL_EVALOBJV)
306 Tcl_Obj *objPtr;
307 #endif
308 USE_ARGV_TO_OBJV();
309
310 if ( createTclInterp(interp, ctx)!=TH_OK ){
@@ -248,11 +317,11 @@
317 if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){
318 Th_ErrorMessage(interp, "invalid Tcl interpreter", (const char *)"", 0);
319 return TH_ERROR;
320 }
321 Tcl_Preserve((ClientData)tclInterp);
322 #if !defined(USE_TCL_EVALOBJV)
323 objPtr = Tcl_NewStringObj(argv[1], argl[1]);
324 Tcl_IncrRefCount(objPtr);
325 command = Tcl_GetCommandFromObj(tclInterp, objPtr);
326 if( !command || Tcl_GetCommandInfoFromToken(command,&cmdInfo)==0 ){
327 Th_ErrorMessage(interp, "Tcl command not found:", argv[1], argl[1]);
@@ -267,11 +336,11 @@
336 return TH_ERROR;
337 }
338 Tcl_DecrRefCount(objPtr);
339 #endif
340 COPY_ARGV_TO_OBJV();
341 #if defined(USE_TCL_EVALOBJV)
342 rc = Tcl_EvalObjv(tclInterp, objc, objv, 0);
343 #else
344 Tcl_ResetResult(tclInterp);
345 rc = cmdInfo.objProc(cmdInfo.objClientData, tclInterp, objc, objv);
346 #endif
@@ -375,10 +444,77 @@
444 /* Remove the Tcl integration commands. */
445 for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){
446 Th_RenameCommand(th1Interp, aCommand[i].zName, -1, NULL, 0);
447 }
448 }
449
450 /*
451 ** When Tcl stubs support is enabled, attempts to dynamically load the Tcl
452 ** shared library and fetch the function pointers necessary to create an
453 ** interpreter and initialize the stubs mechanism; otherwise, simply setup
454 ** the function pointers provided by the caller with the statically linked
455 ** functions.
456 */
457 static int loadTcl(
458 Th_Interp *interp,
459 void **pLibrary,
460 tcl_FindExecutableProc **pxFindExecutable,
461 tcl_CreateInterpProc **pxCreateInterp
462 ){
463 #if defined(USE_TCL_STUBS)
464 char fileName[] = TCL_LIBRARY_NAME;
465 #endif
466 if( !pLibrary || !pxFindExecutable || !pxCreateInterp ){
467 Th_ErrorMessage(interp,
468 "Invalid Tcl loader argument(s)", (const char *)"", 0);
469 return TH_ERROR;
470 }
471 #if defined(USE_TCL_STUBS)
472 do {
473 void *library = dlopen(fileName, RTLD_NOW | RTLD_GLOBAL);
474 if( library ){
475 tcl_FindExecutableProc *xFindExecutable;
476 tcl_CreateInterpProc *xCreateInterp;
477 const char *procName = TCL_FINDEXECUTABLE_NAME;
478 xFindExecutable = (tcl_FindExecutableProc *)dlsym(library, procName + 1);
479 if( !xFindExecutable ){
480 xFindExecutable = (tcl_FindExecutableProc *)dlsym(library, procName);
481 }
482 if( !xFindExecutable ){
483 Th_ErrorMessage(interp,
484 "Could not locate Tcl_FindExecutable", (const char *)"", 0);
485 dlclose(library);
486 return TH_ERROR;
487 }
488 procName = TCL_CREATEINTERP_NAME;
489 xCreateInterp = (tcl_CreateInterpProc *)dlsym(library, procName + 1);
490 if( !xCreateInterp ){
491 xCreateInterp = (tcl_CreateInterpProc *)dlsym(library, procName);
492 }
493 if( !xCreateInterp ){
494 Th_ErrorMessage(interp,
495 "Could not locate Tcl_CreateInterp", (const char *)"", 0);
496 dlclose(library);
497 return TH_ERROR;
498 }
499 *pLibrary = library;
500 *pxFindExecutable = xFindExecutable;
501 *pxCreateInterp = xCreateInterp;
502 return TH_OK;
503 }
504 } while( --fileName[TCL_MINOR_OFFSET]>'3' ); /* Tcl 8.4+ */
505 Th_ErrorMessage(interp,
506 "Could not load Tcl shared library \"" TCL_LIBRARY_NAME "\"",
507 (const char *)"", 0);
508 return TH_ERROR;
509 #else
510 *pLibrary = 0;
511 *pxFindExecutable = Tcl_FindExecutable;
512 *pxCreateInterp = Tcl_CreateInterp;
513 return TH_OK;
514 #endif
515 }
516
517 /*
518 ** Sets the "argv0", "argc", and "argv" script variables in the Tcl interpreter
519 ** based on the supplied command line arguments.
520 */
@@ -454,23 +590,32 @@
590 "Invalid Tcl context", (const char *)"", 0);
591 return TH_ERROR;
592 }
593 if ( tclContext->interp ){
594 return TH_OK;
595 }
596 if( loadTcl(interp, &tclContext->library, &tclContext->xFindExecutable,
597 &tclContext->xCreateInterp)!=TH_OK ){
598 return TH_ERROR;
599 }
600 argc = tclContext->argc;
601 argv = tclContext->argv;
602 if( argc>0 && argv ){
603 argv0 = argv[0];
604 }
605 tclContext->xFindExecutable(argv0);
606 tclInterp = tclContext->xCreateInterp();
607 if( !tclInterp ||
608 #if defined(USE_TCL_STUBS)
609 !Tcl_InitStubs(tclInterp, "8.4", 0) ||
610 #endif
611 Tcl_InterpDeleted(tclInterp) ){
612 Th_ErrorMessage(interp,
613 "Could not create Tcl interpreter", (const char *)"", 0);
614 return TH_ERROR;
615 }
616 tclContext->interp = tclInterp;
617 if( Tcl_Init(tclInterp)!=TCL_OK ){
618 Th_ErrorMessage(interp,
619 "Tcl initialization error:", Tcl_GetStringResult(tclInterp), -1);
620 Tcl_DeleteInterp(tclInterp);
621 tclContext->interp = tclInterp = 0;
622
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -47,10 +47,14 @@
4747
# FOSSIL_ENABLE_SSL = 1
4848
4949
#### Enable scripting support via Tcl/Tk
5050
#
5151
# FOSSIL_ENABLE_TCL = 1
52
+
53
+#### Load Tcl using the stubs mechanism
54
+#
55
+# FOSSIL_ENABLE_TCL_STUBS = 1
5256
5357
#### Use the Tcl source directory instead of the install directory?
5458
# This is useful when Tcl has been compiled statically with MinGW.
5559
#
5660
FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
96100
TCLINCDIR = $(TCLDIR)/include
97101
TCLLIBDIR = $(TCLDIR)/lib
98102
99103
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
100104
#
105
+ifdef FOSSIL_ENABLE_TCL_STUBS
106
+LIBTCL = -ltclstub86
107
+else
101108
LIBTCL = -ltcl86
109
+endif
102110
103111
#### C Compile and options for use in building executables that
104112
# will run on the target platform. This is usually the same
105113
# as BCC, unless you are cross-compiling. This C compiler builds
106114
# the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
134142
ifdef FOSSIL_ENABLE_SSL
135143
TCC += -DFOSSIL_ENABLE_SSL=1
136144
RCC += -DFOSSIL_ENABLE_SSL=1
137145
endif
138146
139
-# With Tcl support (statically linked)
147
+# With Tcl support
140148
ifdef FOSSIL_ENABLE_TCL
141
-TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
149
+TCC += -DFOSSIL_ENABLE_TCL=1
142150
RCC += -DFOSSIL_ENABLE_TCL=1
151
+# Either statically linked or via stubs
152
+ifdef FOSSIL_ENABLE_TCL_STUBS
153
+TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
154
+RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
155
+else
156
+TCC += -DSTATIC_BUILD
157
+RCC += -DSTATIC_BUILD
158
+endif
143159
endif
144160
145161
# With JSON support
146162
ifdef FOSSIL_ENABLE_JSON
147163
TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
171187
172188
#### These libraries MUST appear in the same order as they do for Tcl
173189
# or linking with it will not work (exact reason unknown).
174190
#
175191
ifdef FOSSIL_ENABLE_TCL
192
+ifdef FOSSIL_ENABLE_TCL_STUBS
193
+LIB += -lkernel32 -lws2_32
194
+else
176195
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
196
+endif
177197
else
178198
LIB += -lkernel32 -lws2_32
179199
endif
180200
181201
#### Tcl shell for use in running the fossil test suite. This is only
182202
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -47,10 +47,14 @@
47 # FOSSIL_ENABLE_SSL = 1
48
49 #### Enable scripting support via Tcl/Tk
50 #
51 # FOSSIL_ENABLE_TCL = 1
 
 
 
 
52
53 #### Use the Tcl source directory instead of the install directory?
54 # This is useful when Tcl has been compiled statically with MinGW.
55 #
56 FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
96 TCLINCDIR = $(TCLDIR)/include
97 TCLLIBDIR = $(TCLDIR)/lib
98
99 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
100 #
 
 
 
101 LIBTCL = -ltcl86
 
102
103 #### C Compile and options for use in building executables that
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
134 ifdef FOSSIL_ENABLE_SSL
135 TCC += -DFOSSIL_ENABLE_SSL=1
136 RCC += -DFOSSIL_ENABLE_SSL=1
137 endif
138
139 # With Tcl support (statically linked)
140 ifdef FOSSIL_ENABLE_TCL
141 TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
142 RCC += -DFOSSIL_ENABLE_TCL=1
 
 
 
 
 
 
 
 
143 endif
144
145 # With JSON support
146 ifdef FOSSIL_ENABLE_JSON
147 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
171
172 #### These libraries MUST appear in the same order as they do for Tcl
173 # or linking with it will not work (exact reason unknown).
174 #
175 ifdef FOSSIL_ENABLE_TCL
 
 
 
176 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 
177 else
178 LIB += -lkernel32 -lws2_32
179 endif
180
181 #### Tcl shell for use in running the fossil test suite. This is only
182
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -47,10 +47,14 @@
47 # FOSSIL_ENABLE_SSL = 1
48
49 #### Enable scripting support via Tcl/Tk
50 #
51 # FOSSIL_ENABLE_TCL = 1
52
53 #### Load Tcl using the stubs mechanism
54 #
55 # FOSSIL_ENABLE_TCL_STUBS = 1
56
57 #### Use the Tcl source directory instead of the install directory?
58 # This is useful when Tcl has been compiled statically with MinGW.
59 #
60 FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
100 TCLINCDIR = $(TCLDIR)/include
101 TCLLIBDIR = $(TCLDIR)/lib
102
103 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
104 #
105 ifdef FOSSIL_ENABLE_TCL_STUBS
106 LIBTCL = -ltclstub86
107 else
108 LIBTCL = -ltcl86
109 endif
110
111 #### C Compile and options for use in building executables that
112 # will run on the target platform. This is usually the same
113 # as BCC, unless you are cross-compiling. This C compiler builds
114 # the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
142 ifdef FOSSIL_ENABLE_SSL
143 TCC += -DFOSSIL_ENABLE_SSL=1
144 RCC += -DFOSSIL_ENABLE_SSL=1
145 endif
146
147 # With Tcl support
148 ifdef FOSSIL_ENABLE_TCL
149 TCC += -DFOSSIL_ENABLE_TCL=1
150 RCC += -DFOSSIL_ENABLE_TCL=1
151 # Either statically linked or via stubs
152 ifdef FOSSIL_ENABLE_TCL_STUBS
153 TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
154 RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
155 else
156 TCC += -DSTATIC_BUILD
157 RCC += -DSTATIC_BUILD
158 endif
159 endif
160
161 # With JSON support
162 ifdef FOSSIL_ENABLE_JSON
163 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
187
188 #### These libraries MUST appear in the same order as they do for Tcl
189 # or linking with it will not work (exact reason unknown).
190 #
191 ifdef FOSSIL_ENABLE_TCL
192 ifdef FOSSIL_ENABLE_TCL_STUBS
193 LIB += -lkernel32 -lws2_32
194 else
195 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
196 endif
197 else
198 LIB += -lkernel32 -lws2_32
199 endif
200
201 #### Tcl shell for use in running the fossil test suite. This is only
202
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -46,11 +46,15 @@
4646
#
4747
FOSSIL_ENABLE_SSL = 1
4848
4949
#### Enable scripting support via Tcl/Tk
5050
#
51
-# FOSSIL_ENABLE_TCL = 1
51
+FOSSIL_ENABLE_TCL = 1
52
+
53
+#### Load Tcl using the stubs mechanism
54
+#
55
+FOSSIL_ENABLE_TCL_STUBS = 1
5256
5357
#### Use the Tcl source directory instead of the install directory?
5458
# This is useful when Tcl has been compiled statically with MinGW.
5559
#
5660
FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
96100
TCLINCDIR = $(TCLDIR)/include
97101
TCLLIBDIR = $(TCLDIR)/lib
98102
99103
#### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
100104
#
105
+ifdef FOSSIL_ENABLE_TCL_STUBS
106
+LIBTCL = -ltclstub86
107
+else
101108
LIBTCL = -ltcl86
109
+endif
102110
103111
#### C Compile and options for use in building executables that
104112
# will run on the target platform. This is usually the same
105113
# as BCC, unless you are cross-compiling. This C compiler builds
106114
# the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
134142
ifdef FOSSIL_ENABLE_SSL
135143
TCC += -DFOSSIL_ENABLE_SSL=1
136144
RCC += -DFOSSIL_ENABLE_SSL=1
137145
endif
138146
139
-# With Tcl support (statically linked)
147
+# With Tcl support
140148
ifdef FOSSIL_ENABLE_TCL
141
-TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
149
+TCC += -DFOSSIL_ENABLE_TCL=1
142150
RCC += -DFOSSIL_ENABLE_TCL=1
151
+# Either statically linked or via stubs
152
+ifdef FOSSIL_ENABLE_TCL_STUBS
153
+TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
154
+RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
155
+else
156
+TCC += -DSTATIC_BUILD
157
+RCC += -DSTATIC_BUILD
158
+endif
143159
endif
144160
145161
# With JSON support
146162
ifdef FOSSIL_ENABLE_JSON
147163
TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
171187
172188
#### These libraries MUST appear in the same order as they do for Tcl
173189
# or linking with it will not work (exact reason unknown).
174190
#
175191
ifdef FOSSIL_ENABLE_TCL
192
+ifdef FOSSIL_ENABLE_TCL_STUBS
193
+LIB += -lkernel32 -lws2_32
194
+else
176195
LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
196
+endif
177197
else
178198
LIB += -lkernel32 -lws2_32
179199
endif
180200
181201
#### Tcl shell for use in running the fossil test suite. This is only
182202
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -46,11 +46,15 @@
46 #
47 FOSSIL_ENABLE_SSL = 1
48
49 #### Enable scripting support via Tcl/Tk
50 #
51 # FOSSIL_ENABLE_TCL = 1
 
 
 
 
52
53 #### Use the Tcl source directory instead of the install directory?
54 # This is useful when Tcl has been compiled statically with MinGW.
55 #
56 FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
96 TCLINCDIR = $(TCLDIR)/include
97 TCLLIBDIR = $(TCLDIR)/lib
98
99 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
100 #
 
 
 
101 LIBTCL = -ltcl86
 
102
103 #### C Compile and options for use in building executables that
104 # will run on the target platform. This is usually the same
105 # as BCC, unless you are cross-compiling. This C compiler builds
106 # the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
134 ifdef FOSSIL_ENABLE_SSL
135 TCC += -DFOSSIL_ENABLE_SSL=1
136 RCC += -DFOSSIL_ENABLE_SSL=1
137 endif
138
139 # With Tcl support (statically linked)
140 ifdef FOSSIL_ENABLE_TCL
141 TCC += -DFOSSIL_ENABLE_TCL=1 -DSTATIC_BUILD
142 RCC += -DFOSSIL_ENABLE_TCL=1
 
 
 
 
 
 
 
 
143 endif
144
145 # With JSON support
146 ifdef FOSSIL_ENABLE_JSON
147 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
171
172 #### These libraries MUST appear in the same order as they do for Tcl
173 # or linking with it will not work (exact reason unknown).
174 #
175 ifdef FOSSIL_ENABLE_TCL
 
 
 
176 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 
177 else
178 LIB += -lkernel32 -lws2_32
179 endif
180
181 #### Tcl shell for use in running the fossil test suite. This is only
182
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -46,11 +46,15 @@
46 #
47 FOSSIL_ENABLE_SSL = 1
48
49 #### Enable scripting support via Tcl/Tk
50 #
51 FOSSIL_ENABLE_TCL = 1
52
53 #### Load Tcl using the stubs mechanism
54 #
55 FOSSIL_ENABLE_TCL_STUBS = 1
56
57 #### Use the Tcl source directory instead of the install directory?
58 # This is useful when Tcl has been compiled statically with MinGW.
59 #
60 FOSSIL_TCL_SOURCE = 1
@@ -96,11 +100,15 @@
100 TCLINCDIR = $(TCLDIR)/include
101 TCLLIBDIR = $(TCLDIR)/lib
102
103 #### Tcl: Which Tcl library do we want to use (8.4, 8.5, 8.6, etc)?
104 #
105 ifdef FOSSIL_ENABLE_TCL_STUBS
106 LIBTCL = -ltclstub86
107 else
108 LIBTCL = -ltcl86
109 endif
110
111 #### C Compile and options for use in building executables that
112 # will run on the target platform. This is usually the same
113 # as BCC, unless you are cross-compiling. This C compiler builds
114 # the finished binary for fossil. The BCC compiler above is used
@@ -134,14 +142,22 @@
142 ifdef FOSSIL_ENABLE_SSL
143 TCC += -DFOSSIL_ENABLE_SSL=1
144 RCC += -DFOSSIL_ENABLE_SSL=1
145 endif
146
147 # With Tcl support
148 ifdef FOSSIL_ENABLE_TCL
149 TCC += -DFOSSIL_ENABLE_TCL=1
150 RCC += -DFOSSIL_ENABLE_TCL=1
151 # Either statically linked or via stubs
152 ifdef FOSSIL_ENABLE_TCL_STUBS
153 TCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
154 RCC += -DFOSSIL_ENABLE_TCL_STUBS=1 -DUSE_TCL_STUBS
155 else
156 TCC += -DSTATIC_BUILD
157 RCC += -DSTATIC_BUILD
158 endif
159 endif
160
161 # With JSON support
162 ifdef FOSSIL_ENABLE_JSON
163 TCC += -DFOSSIL_ENABLE_JSON=1
@@ -171,11 +187,15 @@
187
188 #### These libraries MUST appear in the same order as they do for Tcl
189 # or linking with it will not work (exact reason unknown).
190 #
191 ifdef FOSSIL_ENABLE_TCL
192 ifdef FOSSIL_ENABLE_TCL_STUBS
193 LIB += -lkernel32 -lws2_32
194 else
195 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
196 endif
197 else
198 LIB += -lkernel32 -lws2_32
199 endif
200
201 #### Tcl shell for use in running the fossil test suite. This is only
202
--- win/fossil.rc
+++ win/fossil.rc
@@ -90,10 +90,15 @@
9090
#ifdef FOSSIL_ENABLE_SSL
9191
VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
9292
#endif
9393
#ifdef FOSSIL_ENABLE_TCL
9494
VALUE "TclEnabled", "Yes, Tcl " TCL_PATCH_LEVEL "\0"
95
+#ifdef FOSSIL_ENABLE_TCL_STUBS
96
+ VALUE "TclStubsEnabled", "Yes\0"
97
+#else
98
+ VALUE "TclStubsEnabled", "No\0"
99
+#endif
95100
#endif
96101
#ifdef FOSSIL_ENABLE_JSON
97102
VALUE "JsonEnabled", "Yes, cson\0"
98103
#endif
99104
END
100105
--- win/fossil.rc
+++ win/fossil.rc
@@ -90,10 +90,15 @@
90 #ifdef FOSSIL_ENABLE_SSL
91 VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
92 #endif
93 #ifdef FOSSIL_ENABLE_TCL
94 VALUE "TclEnabled", "Yes, Tcl " TCL_PATCH_LEVEL "\0"
 
 
 
 
 
95 #endif
96 #ifdef FOSSIL_ENABLE_JSON
97 VALUE "JsonEnabled", "Yes, cson\0"
98 #endif
99 END
100
--- win/fossil.rc
+++ win/fossil.rc
@@ -90,10 +90,15 @@
90 #ifdef FOSSIL_ENABLE_SSL
91 VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
92 #endif
93 #ifdef FOSSIL_ENABLE_TCL
94 VALUE "TclEnabled", "Yes, Tcl " TCL_PATCH_LEVEL "\0"
95 #ifdef FOSSIL_ENABLE_TCL_STUBS
96 VALUE "TclStubsEnabled", "Yes\0"
97 #else
98 VALUE "TclStubsEnabled", "No\0"
99 #endif
100 #endif
101 #ifdef FOSSIL_ENABLE_JSON
102 VALUE "JsonEnabled", "Yes, cson\0"
103 #endif
104 END
105

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button