bnoordhuis / tkgate

A graphical editor and event-driven simulator for digital circuits
https://bnoordhuis.github.io/tkgate/
Other
25 stars 10 forks source link

MacOS support #1

Open bnoordhuis opened 7 years ago

bnoordhuis commented 7 years ago

Currently blocked on ABI compatibility issues between XQuartz (X server) and the Tcl/Tk shipped by Apple:

Tcl_Interp *tcl = /* ... */;
// Segfaults...
DefaultColormapOfScreen(
    XDefaultScreenOfDisplay(
        Tk_Display(Tk_MainWindow(tcl))));

Can possibly be overcome by using a third-party Tcl distro like ActiveTcl.

bnoordhuis commented 5 years ago

So I don't forget.

configure.ac patch:

```diff diff --git a/configure.ac b/configure.ac index d9c9303..6563294 100644 --- a/configure.ac +++ b/configure.ac @@ -33,17 +33,17 @@ AC_DEFINE(TKGATE_HOMEPAGE, "https://github.com/bnoordhuis/tkgate", [TkGate web # # Tcl/Tk version we will try to use (from most favored to least favored) # -TKGATE_TCLTK_VERSIONS="8.5 8.4 8.3" +TKGATE_TCLTK_VERSIONS="8.6" # # Directories to search for include files # -TKGATE_INCDIRS="/usr/X11R6/include /usr/X11/include /pkgs/include /usr/local/include /usr/openwin/include /usr/X/include /usr/include /sw/include /opt/local/include" +TKGATE_INCDIRS="/opt/X11/include /usr/local/opt/tcl-tk/include" # # Directories to search for library files # -TKGATE_LIBDIRS="/usr/X11R6/lib /usr/X11/lib /pkgs/lib /usr/local/lib /usr/lib /sw/lib /opt/local/lib" +TKGATE_LIBDIRS="/opt/X11/lib /usr/local/opt/tcl-tk/lib" # # Libraries we may need if available. ```

test program:

```c // cc -g -Wall -Wextra // -I/opt/X11/include -I/usr/local/Cellar/tcl-tk/8.6.9/include t.c // -L/opt/X11/lib -L/usr/local/Cellar/tcl-tk/8.6.9/lib // -ltcl8.6 -ltk8.6 -lX11 #include #include #include #include int main(void) { Tcl_Interp *tcl = Tcl_CreateInterp(); if (TCL_ERROR == Tcl_Eval(tcl, "set tcl_library /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6")) errx(1, "Tcl_Eval: %s", Tcl_GetStringResult(tcl)); if (TCL_ERROR == Tcl_EvalFile(tcl, "/usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/init.tcl")) errx(1, "Tcl_EvalFile: %s", Tcl_GetStringResult(tcl)); if (TCL_ERROR == Tk_Init(tcl)) errx(1, "Tk_Init: %s", Tcl_GetStringResult(tcl)); Tk_Window w = Tk_MainWindow(tcl); Display *d = Tk_Display(w); Screen *s = XDefaultScreenOfDisplay(d); // crash: d dangles Colormap c = XDefaultColormapOfScreen(s); (void) &c; return 0; } ```
bnoordhuis commented 4 years ago

I've made some progress on this. Trying to use the tcl/tk from Apple or homebrew was a dead end. They're both using CoreGraphics, whereas tkgate is strictly X11 - i.e., completely incompatible.

Building tcl and tk from source (with the --with-x option in case of tk) and building and linking tkgate against that did work, now I just need to package it up into a simple recipe, probably a Makefile.