SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files

This describes how to compile Tcl/Tk version 8.3.2 for gcc/mingw32 (i.e. on Windows in the GNU/Cygwin environment) and which patches have been made against the original Tk 8.3.2 library.

TCL Build

mkdir tcl8.3.2/win/bld

ln -s ../tools/tcl.hpj.in tcl8.3.2/win

Edit configure script:
CC=gcc
CFLAGS=-mno-cygwin

sh ../configure --enable-gcc --host=i386-mingw

Edit generated Makefile in bld:
prefix=/usr
exec_prefix=/usr
AR=ar
RANLIB=ranlib
RC=windres
MKDIR=mkdir ## remove -p

Patch __try{}__except() in Tcl sources:

diff -r orig/tcl8.3.2/win/tclWin32Dll.c tcl8.3.2/win/tclWin32Dll.c 347a348
> #ifndef __MINGW32__
353a355,357
> #else
> return 1;
> #endif
diff -r orig/tcl8.3.2/win/tclWinFCmd.c tcl8.3.2/win/tclWinFCmd.c 184a185
> #ifndef __MINGW32__
185a187
> #endif
188a191
> #ifndef __MINGW32__
189a193
> #endif
463a468
> #ifndef __MINGW32__
464a470
> #endif
467a474
> #ifndef __MINGW32__
468a476
> #endif

make install

TK build

mkdir tk8.3.2/win/bld

Edit configure script:
CC=gcc
CFLAGS=-mno-cygwin

sh ../configure --enable-gcc --host=i386-mingw --with-tcl=../../../tcl8.3.2/win/bld

Edit generated Makefile in bld:
prefix=/usr
AR=ar
RANLIB=ranlib
RC=windres
MKDIR=mkdir ## remove -p

replace win/rc/tk.ico with nxtvepg.ico

patch WM_QUERYENDSESSION, WM_ENDSESSION in win/tkWinWm.c:

313a314,321
> static Tcl_CloseProc *mainWinDestructionHandler = NULL; >
> /* hack to catch app destruction */
> void Tk_RegisterMainDestructionHandler( Tcl_CloseProc * handler ) > {
> mainWinDestructionHandler = handler; > } >


4307a4316,4325
>
>         /* TZ++ Jan/2001: this is a hack to catch shutdown messages */
>       case WM_QUERYENDSESSION:
>       case WM_ENDSESSION:
>             if (mainWinDestructionHandler != NULL) {
>                 mainWinDestructionHandler((ClientData)message);
>             }
>             result = TRUE;
>             goto done;
>         /* end TZ */

patch shutdown message:

diff tkInt.decls
819a820,825
> # patched in by tzo for shutdown handling >
> declare 34 win {
> void Tk_RegisterMainDestructionHandler( Tcl_CloseProc * handler ) > }
>
diff orig/tk8.3.2/generic/tkIntPlatDecls.h tk8.3.2/generic/tkIntPlatDecls.h 144a145,149
>
> /* 34 */
> /* patched in by tzo for shutdown handling */ > EXTERN void Tk_RegisterMainDestructionHandler ANSIARGS_((Tcl_CloseProc * handler)); >
345a351
> void (*tkRegisterMainDestructionHandler) ANSIARGS_(( Tcl_CloseProc * handler )); /* 34 */ 597a604,606
> #endif
> #ifndef Tk_RegisterMainDestructionHandler > (tkIntPlatStubsPtr->tkRegisterMainDestructionHandler) /* 34 */ diff orig/tk8.3.2/generic/tkStubInit.c tk8.3.2/generic/tkStubInit.c 399a400
> Tk_RegisterMainDestructionHandler, /* 34 */ diff orig/tk8.3.2/win/tkWinX.c tk8.3.2/win/tkWinX.c 59a60,75
> * Tk_RegisterMainDestructionHandler
> *
> * Patched in by tzo: set a handler for shutdown messages > *
> *---------------------------------------------------------------------- > */
> static Tcl_CloseProc * tkMainDestructionHandler = NULL; >
> void
> Tk_RegisterMainDestructionHandler( Tcl_CloseProc * handler ) > {
> tkMainDestructionHandler = handler; > } >


> /*
> *---------------------------------------------------------------------- 553a570,576
>
>         case WM_QUERYENDSESSION:
>         case WM_ENDSESSION:
>             if (tkMainDestructionHandler != NULL)
>             {
>                 tkMainDestructionHandler(NULL);
>             }

patch tk_messageBox:

diff orig/tk8.3.2/generic/tkWindow.c tk8.3.2/generic/tkWindow.c 125c125,126
< #ifdef __WIN32__
---
> #ifdef USE_WIN32_MSGBOX /*__WIN32__ // disabled by TZ (again) 2002-04-30 */ > /* TZ: there are weird problems with the Windows messagebox - use Tk box instead */

make install

Generate .a files from DLL

When the Tcl/Tk libraries are compiled from source, both DLLs and linker libraries are generated. The latter are required because when building executables ld cannot link directly against DLLs. To avoid having to include both DLL and linker libraries with nxtvepg releases, only .def files are included with which .a libraries can be generated from the DLLs with help of dlltool.

Generating .def from .a: (to be done before releases)

/usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-nm libtcl83.a |

grep '^........ [T] _' | sed 's/[^_]*_//' > libtcl83.def
/usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-nm libtk83.a | grep '^........ [T] _' | sed 's/[^_]*_//' > libtk83.def

Generating .a from .dll with help of .def: (for end user)

/usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-dlltool --as=/usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-as --def libtcl83.def --dllname tcl83.dll -v --output-lib libtcl83.a /usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-dlltool --as=/usr/local/i386-pc-cygwin32/bin/i386-pc-cygwin32-as --def libtk83.def --dllname tk83.dll -v --output-lib libtk83.a


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.