Building TkGate on OS X


TkGate is a pretty nice little graphical digital circuit simulator.  The TkGate documentation is pretty good, and the program runs a simple tutorial when you start it.

But it's tricky to build on OS X.  I recommend just using my binary build of 1.8.7, which includes Tcl/Tk 8.4.  To install my binary copy:
  1. Get out your OS X install CD, and install the "X11 Tools".  TkGate is built on top of X11, the UNIX display interface.
  2. Download this binary TkGate for OS X tar file, and put it in your home directory.  It's for x86 CPUs.
  3. Open a terminal, and type:
    cd /
    sudo tar xvf ~/tkgate_OS_X_installed.tgz
  4. To run TkGate, open a terminal and type:
    tkgate
This should show the TkGate GUI.  I've included the "gsim" simulator, and everything should work out of the box.

Building from Source

You may have to compile TkGate yourself if the above binary copy doesn't work (for example, you're on a PowerPC mac, want a newer version, or something about my shared libraries doesn't like your shared libraries).  Here's how to do it:
  1. Get out your OS X install CD again, and install the command-line developer tools (gcc, make, etc) as well as the X11 tools.
  2. Download tcl and tk source code from here.  I used 8.4.19, which seems to work with TkGate 1.8.7.
  3. Build both tcl and tk from a Terminal.  The "macosx" build directory makes a Framework version of Tcl and Tk, which I couldn't get working with TkGate (plus you need to export CFLAGS="-arch i386" to even get it to build), so here I'm just using the UNIX versions, which seem to work fine in X11:
    tar xvf tcl8.4.19-src.tar.gz
    cd tcl8.4.19/unix
    ./configure --disable-shared
    make
    sudo make install
    cd ../..

    tar xvf tk8.4.19-src.tar.gz
    cd tk8.4.19/unix
    ./configure --disable-shared
    make
    sudo make install
    cd ../..
  4. If the "make" for Tk fails, missing "-lX11", you just need to add the path "-L/usr/X11/lib" to the link line.
  5. You're going to need bison, yacc, and flex, which come with the command line developer tools, as well as the ancient Makefile generator programs "xmkmf" and "imake".  In a perfect world, you can download imake-1.0.3 from xorg, and configure, make, sudo install exactly as above.
    tar xvf imake-1.0.3.tar.gz
    cd imake-1.0.3
    ./configure
    make
    sudo make install
    cd ..
  6. Download the TkGate source code here.  Install with the usual:
    tar xvf tkgate-1.8.7.tgz
    cd tkgate-1.8.7
    make
    sudo make install
    cd ..
  7. If this doesn't work, DON'T PANIC!  Read the error message, and try to fix it.  I had to add "-L/usr/X11/lib" and "-framework CoreFoundation" to the link line.
  8. Try running "./tkgate".  If you get a circuit onscreen, you're done!  If you get the "no event type or button # or keysym" error from tcl, you can just comment out (with "#") the entire "bind" for MouseWheel events.  This happens at lines 178 through 198 of "/usr/local/lib/tcl8.4/listbox.tcl", and lines 453 through 474 of "/usr/local/lib/tcl8.4/text.tcl".  Your mousewheel won't scroll in listboxes or text boxes, but who cares!  At least it works!

O. Lawlor, lawlor@alaska.edu
Up to: Class Site, CS, UAF