From 410df960f97be5d1c56122049928c9d54e005441 Mon Sep 17 00:00:00 2001 From: "Stephen R. Whiteley" Date: Wed, 9 Aug 2017 16:46:11 -0700 Subject: [PATCH] Moved tcltk_if from main to parser, new file tcltk_open.cc in main. Tweaks and minor bug fixes. New config subst. variable for -ldl. --- wrspice/bin/Makefile.in | 46 +++++--- wrspice/include/Makefile | 2 + wrspice/src/fte/Makefile.in | 5 +- wrspice/src/misc/Makefile.in | 5 +- xic/bin/Makefile.in | 68 ++++++++---- xic/bin/xic.cc | 2 +- xic/include/Makefile | 2 + xic/include/main.h | 4 + xic/include/python_if.h | 3 +- xic/include/tcltk_if.h | 12 +-- xic/src/main/Makefile.in | 2 +- xic/src/main/tcltk_open.cc | 155 +++++++++++++++++++++++++++ xic/src/oa/Makefile.in | 29 ++--- xic/src/parser/Makefile.in | 2 +- xic/src/parser/python_if.cc | 6 +- xic/src/{main => parser}/tcltk_if.cc | 123 ++------------------- xic/src/wrspif/Makefile.in | 5 +- xt_base/configure.in | 2 + 18 files changed, 275 insertions(+), 198 deletions(-) create mode 100644 xic/src/main/tcltk_open.cc rename xic/src/{main => parser}/tcltk_if.cc (67%) diff --git a/wrspice/bin/Makefile.in b/wrspice/bin/Makefile.in index 2703d6123..8c3e321a7 100644 --- a/wrspice/bin/Makefile.in +++ b/wrspice/bin/Makefile.in @@ -165,34 +165,46 @@ $(VLOG): $(SECURE): cd $(@D); $(MAKE) +$(BASE)/lib/ginterf.a: + cd $(BASED)/ginterf; $(MAKE) + +$(BASE)/lib/gtkinterf.a: + cd $(BASED)/gtkinterf; $(MAKE) + +$(BASE)/lib/miscutil.a: + cd $(BASED)/miscutil; $(MAKE) + if [ x$(NTREGEX) != x ]; then \ + cd $(BASE)/miscutil/libregex; $(MAKE); \ + fi + $(MOZY)/lib/gtkmozy.a: - cd $(MOZY)/src/gtkmozy; $(MAKE) + if [ -d $(MOZY)/src/gtkmozy ]; then \ + cd $(MOZY)/src/gtkmozy; $(MAKE); \ + fi $(MOZY)/lib/help.a: - cd $(MOZY)/src/help; $(MAKE) + if [ -d $(MOZY)/src/help ]; then \ + cd $(MOZY)/src/help; $(MAKE); \ + fi $(MOZY)/lib/htm.a: - cd $(MOZY)/src/htm; $(MAKE) + if [ -d $(MOZY)/src/htm ]; then \ + cd $(MOZY)/src/htm; $(MAKE); \ + fi $(MOZY)/lib/httpget.a: - cd $(MOZY)/src/httpget; $(MAKE) + if [ -d $(MOZY)/src/httpget ]; then \ + cd $(MOZY)/src/httpget; $(MAKE); \ + fi $(MOZY)/lib/imsave.a: - cd $(MOZY)/src/imsave; $(MAKE) + if [ -d $(MOZY)/src/imsave ] ; then \ + cd $(MOZY)/src/imsave; $(MAKE); \ + fi $(MOZY)/lib/update_itf.a: - cd $(MOZY)/src/update_itf; $(MAKE) - -$(BASE)/lib/ginterf.a: - cd $(BASED)/ginterf; $(MAKE) - -$(BASE)/lib/gtkinterf.a: - cd $(BASED)/gtkinterf; $(MAKE) - -$(BASE)/lib/miscutil.a: - cd $(BASED)/miscutil; $(MAKE) - if [ x$(NTREGEX) != x ]; then \ - cd $(BASE)/miscutil/libregex; $(MAKE); \ + if [ -d $(MOZY)/src/upd ]; then \ + cd $(MOZY)/src/upd; $(MAKE); \ fi ####################################################################### diff --git a/wrspice/include/Makefile b/wrspice/include/Makefile index 0bf51c2fb..1970d1f44 100644 --- a/wrspice/include/Makefile +++ b/wrspice/include/Makefile @@ -2,6 +2,8 @@ LOCATION = wrspice/include ####################################################################### +dummy: + depend: reltag @echo depending in $(LOCATION) diff --git a/wrspice/src/fte/Makefile.in b/wrspice/src/fte/Makefile.in index 140a0e4f1..7aefab6fb 100644 --- a/wrspice/src/fte/Makefile.in +++ b/wrspice/src/fte/Makefile.in @@ -33,7 +33,7 @@ CCFILES = \ subexpand.cc sweep.cc trnames.cc types.cc vectors.cc CCOBJS = $(CCFILES:.cc=.o) -$(LIB_TARGET): include $(CCOBJS) +$(LIB_TARGET): $(CCOBJS) @if [ -f $(LIB_TARGET) ]; then \ rm -f $(LIB_TARGET); \ fi @@ -46,9 +46,6 @@ $(LIB_TARGET): include $(CCOBJS) paramsub.cc: $(BASE)/spnumber/paramsub.cc cp -f $(BASE)/spnumber/paramsub.cc . -include: - cd ../../include; $(MAKE) - depend: paramsub.cc @echo depending in $(LOCATION) @if [ x$(DEPEND_DONE) = x ]; then \ diff --git a/wrspice/src/misc/Makefile.in b/wrspice/src/misc/Makefile.in index 88d4af96a..0034e6705 100644 --- a/wrspice/src/misc/Makefile.in +++ b/wrspice/src/misc/Makefile.in @@ -26,7 +26,7 @@ CCFILES = \ $(NFILES) texthelp.cc time.cc ttyio.cc vardb.cc verilog.cc wlist.cc CCOBJS = $(CCFILES:.cc=.o) -$(LIB_TARGET): include $(CCOBJS) +$(LIB_TARGET): $(CCOBJS) @if [ -f $(LIB_TARGET) ]; then \ rm -f $(LIB_TARGET); \ fi @@ -43,9 +43,6 @@ hash.cc: $(BASE)/spnumber/hash.cc spnumber.cc: $(BASE)/spnumber/spnumber.cc spparse.cc: $(BASE)/spnumber/spparse.cc -include: - cd ../../include; $(MAKE) - depend: $(NFILES) @echo depending in $(LOCATION) @if [ x$(DEPEND_DONE) = x ]; then \ diff --git a/xic/bin/Makefile.in b/xic/bin/Makefile.in index e68702929..085402e55 100644 --- a/xic/bin/Makefile.in +++ b/xic/bin/Makefile.in @@ -16,6 +16,7 @@ CFLAGS = @CFLAGSG@ @DYNAMIC_LIBS@ @NEEDINT64@ @UFLAGS@ LFLAGS = @LFLAGS@ @TOOLKITLFLAGS@ @UFLAGS@ LSHFLAG = @LSHFLAG@ LIBS = @LIBS@ @TOOLKITLIBS@ @EXTRALIBS@ +LIBDL = @LIBDL@ STDCLIB = @STDCLIB@ OSNAME = @OSNAME@ ARCH = @ARCH@ @@ -125,11 +126,22 @@ plugins:: # sa-filetool will always rebuild fietool.o, to set a three-month lifetime # for the binary. -sa-filetool: sa-filetool.o ../src/cd/cd.a ../src/fileio/fileio.a \ - ../src/geom/geom.a ../src/parser/parser.a $(BASE)/lib/miscutil.a - $(LINKCC) -o sa-filetool sa-filetool.o ../src/cd/cd.a \ - ../src/fileio/fileio.a ../src/geom/geom.a ../src/parser/parser.a \ - ../src/fileio/fileio.a $(BASE)/lib/miscutil.a -lm -lz $(STDCLIB) +FT_LIBS = \ + ../src/geom/geom.a \ + ../src/fileio/fileio.a \ + ../src/cd/cd.a \ + ../src/parser/parser.a \ + ../src/geom/geom.a \ + ../src/fileio/fileio.a \ + ../src/wrspif/wrspif.a \ + $(BASE)/lib/miscutil.a \ + $(BASE)/lib/malloc.a \ + $(MOZY)/lib/httpget.a \ + $(MOZY)/lib/update_itf.a + +sa-filetool: sa-filetool.o $(FT_LIBS) + $(LINKCC) -o sa-filetool sa-filetool.o $(FT_LIBS) \ + -lm -lz $(LIBDL) $(STDCLIB) rm -f sa-filetool.o wrencode: cryptmain.cc ../src/parser/parser.a $(BASE)/lib/miscutil.a @@ -158,34 +170,46 @@ $(SUBDIR_LIBS) $(OA_SUBDIR):: $(SECURE): cd $(@D); $(MAKE) +$(BASE)/lib/ginterf.a: + cd $(BASED)/ginterf; $(MAKE) + +$(BASE)/lib/gtkinterf.a: + cd $(BASED)/gtkinterf; $(MAKE) + +$(BASE)/lib/miscutil.a: + cd $(BASED)/miscutil; $(MAKE) + if [ x$(NTREGEX) != x ]; then \ + cd $(BASE)/miscutil/libregex; $(MAKE); \ + fi + $(MOZY)/lib/gtkmozy.a: - cd $(MOZY)/src/gtkmozy; $(MAKE) + if [ -d $(MOZY)/src/gtkmozy ]; then \ + cd $(MOZY)/src/gtkmozy; $(MAKE); \ + fi $(MOZY)/lib/help.a: - cd $(MOZY)/src/help; $(MAKE) + if [ -d $(MOZY)/src/help ]; then \ + cd $(MOZY)/src/help; $(MAKE); \ + fi $(MOZY)/lib/htm.a: - cd $(MOZY)/src/htm; $(MAKE) + if [ -d $(MOZY)/src/htm ]; then \ + cd $(MOZY)/src/htm; $(MAKE); \ + fi $(MOZY)/lib/httpget.a: - cd $(MOZY)/src/httpget; $(MAKE) + if [ -d $(MOZY)/src/httpget ]; then \ + cd $(MOZY)/src/httpget; $(MAKE); \ + fi $(MOZY)/lib/imsave.a: - cd $(MOZY)/src/imsave; $(MAKE) + if [ -d $(MOZY)/src/imsave ] ; then \ + cd $(MOZY)/src/imsave; $(MAKE); \ + fi $(MOZY)/lib/update_itf.a: - cd $(MOZY)/src/update_itf; $(MAKE) - -$(BASE)/lib/ginterf.a: - cd $(BASED)/ginterf; $(MAKE) - -$(BASE)/lib/gtkinterf.a: - cd $(BASED)/gtkinterf; $(MAKE) - -$(BASE)/lib/miscutil.a: - cd $(BASED)/miscutil; $(MAKE) - if [ x$(NTREGEX) != x ]; then \ - cd $(BASE)/miscutil/libregex; $(MAKE); \ + if [ -d $(MOZY)/src/upd ]; then \ + cd $(MOZY)/src/upd; $(MAKE); \ fi ####################################################################### diff --git a/xic/bin/xic.cc b/xic/bin/xic.cc index 33ec72e42..7895c1f28 100644 --- a/xic/bin/xic.cc +++ b/xic/bin/xic.cc @@ -647,7 +647,7 @@ main(int argc, char **argv) _py_ = XM()->openPY(); // Start Tcl/Tk interface. - _tk_ = new cTclIf; + _tk_ = XM()->openTclTk(); if (dspPkgIf()->Initialize(gx)) { XM()->Auth()->closeValidation(); diff --git a/xic/include/Makefile b/xic/include/Makefile index b592ed257..01a5fd7ae 100644 --- a/xic/include/Makefile +++ b/xic/include/Makefile @@ -2,6 +2,8 @@ LOCATION = xic/include ####################################################################### +dummy: + depend: reltag @echo depending in $(LOCATION) diff --git a/xic/include/main.h b/xic/include/main.h index 0be5808a1..339d239a4 100644 --- a/xic/include/main.h +++ b/xic/include/main.h @@ -79,6 +79,7 @@ struct sLcb; struct updif_t; struct cfilter_t; class cPyIf; +class cTclIf; namespace main_txtcmds { struct bcel_t; @@ -469,6 +470,9 @@ class cMain : public GRappCalls // subwin.cc void SubWindowExec(CmdDesc*); + // tcltk_open.cc + cTclIf *openTclTk(); + // user_menu.cc MenuBox *createUserMenu(); diff --git a/xic/include/python_if.h b/xic/include/python_if.h index 38d53196d..2ac8aca0d 100644 --- a/xic/include/python_if.h +++ b/xic/include/python_if.h @@ -67,7 +67,7 @@ class cPyIf virtual ~cPyIf() { } // Capability flag. - bool hasPy() { return (pyPtr != 0); } + bool hasPy() { return (pyAvail); } // Wrapper for native script functions. This is never called unless // the pyPtr is good. @@ -86,6 +86,7 @@ class cPyIf private: cPy_base *pyPtr; + bool pyAvail; static SymTab *py_functions; static cPyIf *instancePtr; diff --git a/xic/include/tcltk_if.h b/xic/include/tcltk_if.h index 4f4241543..72cab68ae 100644 --- a/xic/include/tcltk_if.h +++ b/xic/include/tcltk_if.h @@ -66,12 +66,12 @@ class cTclIf public: friend inline cTclIf *TclIf() { return (cTclIf::ptr()); } - cTclIf(); + cTclIf(cTcl_base*); virtual ~cTclIf() { } // Capability flags. - bool hasTcl() { return (has_tcl); } - bool hasTk() { return (has_tk); } + bool hasTcl() { return (tclAvail); } + bool hasTk() { return (tkAvail); } // Wrapper for native script functions. This is never called unless // the tclPtr is good. @@ -89,11 +89,9 @@ class cTclIf int, Tcl_Obj* const*)); private: - static void bang_tcl(const char*); - cTcl_base *tclPtr; - bool has_tcl; - bool has_tk; + bool tclAvail; + bool tkAvail; static SymTab *tcl_functions; static cTclIf *instancePtr; diff --git a/xic/src/main/Makefile.in b/xic/src/main/Makefile.in index 8def336df..20a860610 100644 --- a/xic/src/main/Makefile.in +++ b/xic/src/main/Makefile.in @@ -33,7 +33,7 @@ CCFILES = \ main_variables.cc measure.cc memory.cc menu.cc misc_menu.cc \ modeswitch.cc oa_if.cc onexit.cc open.cc pcell.cc pcell_params.cc \ promptline.cc promptline_setif.cc prpty.cc pushpop.cc py_open.cc \ - save.cc scedif.cc select.cc signals.cc subwin.cc tcltk_if.cc \ + save.cc scedif.cc select.cc signals.cc subwin.cc tcltk_open.cc \ user_menu.cc view_menu.cc CCOBJS = $(CCFILES:.cc=.o) diff --git a/xic/src/main/tcltk_open.cc b/xic/src/main/tcltk_open.cc new file mode 100644 index 000000000..f56a7eb50 --- /dev/null +++ b/xic/src/main/tcltk_open.cc @@ -0,0 +1,155 @@ + +/*========================================================================* + * * + * Distributed by Whiteley Research Inc., Sunnyvale, California, USA * + * http://wrcad.com * + * Copyright (C) 2017 Whiteley Research Inc., all rights reserved. * + * Author: Stephen R. Whiteley, except as indicated. * + * * + * As fully as possible recognizing licensing terms and conditions * + * imposed by earlier work from which this work was derived, if any, * + * this work is released under the Apache License, Version 2.0 (the * + * "License"). You may not use this file except in compliance with * + * the License, and compliance with inherited licenses which are * + * specified in a sub-header below this one if applicable. A copy * + * of the License is provided with this distribution, or you may * + * obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * See the License for the specific language governing permissions * + * and limitations under the License. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON- * + * INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED * + * OR STEPHEN R. WHITELEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * + * USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + *========================================================================* + * XicTools Integrated Circuit Design System * + * * + * Xic Integrated Circuit Layout and Schematic Editor * + * * + *========================================================================* + $Id:$ + *========================================================================*/ + +#include "config.h" +#include "main.h" +#include "promptline.h" +#include "errorlog.h" +//XXX#include "dsp_inlines.h" +#include "tcltk_if.h" +#include "tcl_base.h" +#include "reltag.h" + +#ifdef HAVE_TCL +#include +#endif + + +#ifdef HAVE_TCL +namespace { + // Dynamically open our helper lib, and return a pointer to the + // interface if successful. + // + cTcl_base *find_tcl(bool with_tk, char **lname) + { + bool verbose = (getenv("XIC_PLUGIN_DBG") != 0); + sLstr lstr; + const char *tclso_path = getenv("XIC_TCLSO_PATH"); + if (tclso_path) { + // User told us where to look. + lstr.add(tclso_path); + } + else { + // Look in the plugins directory. + lstr.add(XM()->ProgramRoot()); + lstr.add("/plugins/"); + lstr.add(with_tk ? "tcltk." : "tcl."); +#ifdef __APPLE__ + lstr.add("dylib"); +#else + lstr.add("so"); +#endif + } + + void *handle = dlopen(lstr.string(), RTLD_LAZY | RTLD_GLOBAL); + if (!handle) { + if (verbose) + printf("dlopen failed: %s\n", dlerror()); + return (0); + } + + cTcl_base*(*tclptr)() = (cTcl_base*(*)())dlsym(handle, "tclptr"); + if (!tclptr) { + if (verbose) + printf("dlsym failed: %s\n", dlerror()); + return (0); + } + + char idstr[64]; + sprintf(idstr, "%s %s", XM()->OSname(), XIC_RELEASE_TAG); + cTcl_base *tcl = (*tclptr)(); + if (tcl && (!tcl->id_string() || strcmp(idstr, tcl->id_string()))) { + if (verbose) { + printf ("%s plug-in version mismatch:\n" + "Xic is \"%s\", plug-in is \"%s\"\n", + with_tk ? "Tcl/Tk" : "Tcl", idstr, + tcl->id_string() ? tcl->id_string() : ""); + } + tcl = 0; + } + if (!tcl) { + if (verbose) + printf("%s interface returned null pointer\n", + with_tk ? "Tcl/Tk" : "Tcl"); + return (0); + } + if (lname) + *lname = lstring::copy(lstring::strip_path(lstr.string())); + return (tcl); + } + + + void bang_tcl(const char *s) + { + if (TclIf()->run(s)) + PL()->ShowPrompt("Tcl/Tk done."); + else { + Log()->ErrorLog("Tck/Tk Interface", Errs()->get_error()); + PL()->ShowPrompt("Tcl/Tk execution failed."); + } + } + +} +#endif + + +cTclIf * +cMain::openTclTk() +{ + cTcl_base *tcl = 0; +#ifdef HAVE_TCL + char *lname = 0; + tcl = find_tcl(true, &lname); // First try with Tk. + if (!tcl) + tcl = find_tcl(false, &lname); // Try again without Tk. + if (tcl) { + RegisterBangCmd("tcl", &bang_tcl); + if (tcl->hasTk()) { + RegisterBangCmd("tk", &bang_tcl); + printf("Using Tcl/Tk (%s).\n", lname); + } + else + printf("Using Tcl (%s).\n", lname); + delete [] lname; + } + return (new cTclIf(tcl)); +#endif +} + diff --git a/xic/src/oa/Makefile.in b/xic/src/oa/Makefile.in index 0b7022989..f279d62e7 100644 --- a/xic/src/oa/Makefile.in +++ b/xic/src/oa/Makefile.in @@ -23,32 +23,15 @@ LIB_TARGET = oa.a SHLIB_TARGET = oa.$(SOEXT) BASE = ../../../xt_base -INCLUDE = -I../../include -I$(BASE)/include -I$(OA_INCLUDE) +INCLUDE = -I. -I../../include -I$(BASE)/include -I$(OA_INCLUDE) HFILES = \ - oa.h \ - oa_alib.h \ - oa_errlog.h \ - oa_lib_observer.h \ - oa_nametab.h \ - oa_net.h \ - oa_prop.h \ - oa_tech_observer.h \ - oa_via.h + oa.h oa_alib.h oa_errlog.h oa_lib_observer.h oa_nametab.h oa_net.h \ + oa_prop.h oa_tech_observer.h oa_via.h CCFILES = \ - oa.cc \ - oa_alib.cc \ - oa_errlog.cc \ - oa_lib_observer.cc \ - oa_library.cc \ - oa_load.cc \ - oa_nametab.cc \ - oa_net.cc \ - oa_prop.cc \ - oa_save.cc \ - oa_tech.cc \ - oa_tech_observer.cc \ - oa_via.cc + oa.cc oa_alib.cc oa_errlog.cc oa_lib_observer.cc oa_library.cc \ + oa_load.cc oa_nametab.cc oa_net.cc oa_prop.cc oa_save.cc oa_tech.cc \ + oa_tech_observer.cc oa_via.cc CCOBJS = $(CCFILES:.cc=.o) DARGS = -DOSNAME="\"$(OSNAME)\"" diff --git a/xic/src/parser/Makefile.in b/xic/src/parser/Makefile.in index 6f7f714ff..b93d93397 100644 --- a/xic/src/parser/Makefile.in +++ b/xic/src/parser/Makefile.in @@ -23,7 +23,7 @@ CCFILES = \ funcs_lexpr.cc funcs_math.cc python_if.cc si_daemon.cc si_debug.cc \ si_handle.cc si_interp.cc si_lexpr.cc si_lisp.cc si_lspec.cc \ si_macro.cc si_parsenode.cc si_parser.cc si_spt.cc si_support.cc \ - si_variable.cc + si_variable.cc tcltk_if.cc EXPOBJS = $(CCFILES_EXPORT:.cc=.o) CCOBJS = $(CCFILES:.cc=.o) diff --git a/xic/src/parser/python_if.cc b/xic/src/parser/python_if.cc index dd0d45b47..cea618af0 100644 --- a/xic/src/parser/python_if.cc +++ b/xic/src/parser/python_if.cc @@ -77,8 +77,12 @@ cPyIf::cPyIf(cPy_base *py) instancePtr = this; pyPtr = py; - if (!pyPtr) + if (pyPtr) + pyAvail = true; + else { pyPtr = new cPy_nogo; + pyAvail = false; + } } diff --git a/xic/src/main/tcltk_if.cc b/xic/src/parser/tcltk_if.cc similarity index 67% rename from xic/src/main/tcltk_if.cc rename to xic/src/parser/tcltk_if.cc index d02b1dcc6..5b3796113 100644 --- a/xic/src/main/tcltk_if.cc +++ b/xic/src/parser/tcltk_if.cc @@ -38,18 +38,9 @@ $Id:$ *========================================================================*/ -#include "config.h" -#include "main.h" -#include "promptline.h" -#include "errorlog.h" -#include "dsp_inlines.h" +#include "cd.h" #include "tcltk_if.h" #include "tcl_base.h" -#include "reltag.h" - -#ifdef HAVE_TCL -#include -#endif //----------------------------------------------------------------------------- @@ -76,76 +67,10 @@ class cTcl_nogo : public cTcl_base }; -#ifdef HAVE_TCL -namespace { - // Dynamically open our helper lib, and return a pointer to the - // interface if successful. - // - cTcl_base *find_tcl(bool with_tk, char **lname) - { - bool verbose = (getenv("XIC_PLUGIN_DBG") != 0); - sLstr lstr; - const char *tclso_path = getenv("XIC_TCLSO_PATH"); - if (tclso_path) { - // User told us where to look. - lstr.add(tclso_path); - } - else { - // Look in the plugins directory. - lstr.add(XM()->ProgramRoot()); - lstr.add("/plugins/"); - lstr.add(with_tk ? "tcltk." : "tcl."); -#ifdef __APPLE__ - lstr.add("dylib"); -#else - lstr.add("so"); -#endif - } - - void *handle = dlopen(lstr.string(), RTLD_LAZY | RTLD_GLOBAL); - if (!handle) { - if (verbose) - printf("dlopen failed: %s\n", dlerror()); - return (0); - } - - cTcl_base*(*tclptr)() = (cTcl_base*(*)())dlsym(handle, "tclptr"); - if (!tclptr) { - if (verbose) - printf("dlsym failed: %s\n", dlerror()); - return (0); - } - - char idstr[64]; - sprintf(idstr, "%s %s", XM()->OSname(), XIC_RELEASE_TAG); - cTcl_base *tcl = (*tclptr)(); - if (tcl && (!tcl->id_string() || strcmp(idstr, tcl->id_string()))) { - if (verbose) { - printf ("%s plug-in version mismatch:\n" - "Xic is \"%s\", plug-in is \"%s\"\n", - with_tk ? "Tcl/Tk" : "Tcl", idstr, - tcl->id_string() ? tcl->id_string() : ""); - } - tcl = 0; - } - if (!tcl) { - if (verbose) - printf("%s interface returned null pointer\n", - with_tk ? "Tcl/Tk" : "Tcl"); - return (0); - } - if (lname) - *lname = lstring::copy(lstring::strip_path(lstr.string())); - return (tcl); - } -} -#endif - - SymTab *cTclIf::tcl_functions = 0; cTclIf *cTclIf::instancePtr = 0; -cTclIf::cTclIf() +cTclIf::cTclIf(cTcl_base *tcl) { if (instancePtr) { fprintf(stderr, "Singleton class cTclIf already instantiated.\n"); @@ -153,28 +78,16 @@ cTclIf::cTclIf() } instancePtr = this; -#ifdef HAVE_TCL - char *lname = 0; - tclPtr = find_tcl(true, &lname); // First try with Tk. - if (!tclPtr) - tclPtr = find_tcl(false, &lname); // Try again without Tk. + tclPtr = tcl; if (tclPtr) { - has_tcl = true; - has_tk = tclPtr->hasTk(); - XM()->RegisterBangCmd("tcl", &bang_tcl); - if (has_tk) { - XM()->RegisterBangCmd("tk", &bang_tcl); - printf("Using Tcl/Tk (%s).\n", lname); - } - else - printf("Using Tcl (%s).\n", lname); - delete [] lname; - return; + tclAvail = true; + tkAvail = tclPtr->hasTk(); + } + else { + tclPtr = new cTcl_nogo; + tclAvail = false; + tkAvail = false; } -#endif - - tclPtr = new cTcl_nogo; - has_tcl = false; } @@ -200,7 +113,7 @@ cTclIf::run(const char *s) } GCarray gc_cmdfile(cmdfile); bool is_tk = false; - if (has_tk) { + if (tkAvail) { // Tk is available. The file must have a .tcl or .tk extension. char *ext = strrchr(cmdfile, '.'); if (!ext || (!lstring::cieq(ext, ".tcl") && @@ -273,17 +186,3 @@ cTclIf::register_func(const char *fname, ent->stData = (void*)func; } - -// Static function -// -void -cTclIf::bang_tcl(const char *s) -{ - if (TclIf()->run(s)) - PL()->ShowPrompt("Tcl/Tk done."); - else { - Log()->ErrorLog("Tck/Tk Interface", Errs()->get_error()); - PL()->ShowPrompt("Tcl/Tk execution failed."); - } -} - diff --git a/xic/src/wrspif/Makefile.in b/xic/src/wrspif/Makefile.in index 1586191b6..6012e919c 100644 --- a/xic/src/wrspif/Makefile.in +++ b/xic/src/wrspif/Makefile.in @@ -23,7 +23,7 @@ HFILES = CCFILES = $(SPFILES) CCOBJS = $(CCFILES:.cc=.o) -$(LIB_TARGET): include $(CCOBJS) +$(LIB_TARGET): $(CCOBJS) @if [ -f $(LIB_TARGET) ]; then \ rm -f $(LIB_TARGET); \ fi @@ -41,9 +41,6 @@ paramsub.cc: $(BASE)/spnumber/paramsub.cc spnumber.cc: $(BASE)/spnumber/spnumber.cc spparse.cc: $(BASE)/spnumber/spparse.cc -include: - cd ../../include; $(MAKE) - depend: $(SPFILES) @echo depending in $(LOCATION) @if [ x$(DEPEND_DONE) = x ]; then \ diff --git a/xt_base/configure.in b/xt_base/configure.in index 35758867f..61a6cb79c 100644 --- a/xt_base/configure.in +++ b/xt_base/configure.in @@ -879,6 +879,7 @@ dnl Try to link static graphics libraries if found. AC_CHECK_LIB(X11, main, EXTRALIBS="$EXTRALIBS -lX11") AC_CHECK_LIB(Xext, main, EXTRALIBS="$EXTRALIBS -lXext") fi + AC_CHECK_LIB(dl, main, LIBDL="-ldl") AC_CHECK_LIB(ncurses, main, [ CURSES="-lncurses" ], AC_CHECK_LIB(curses, main, [ @@ -918,6 +919,7 @@ AC_SUBST(IMG_FLAGS) AC_SUBST(IMG_INCLUDES) AC_SUBST(IMG_LIBS) AC_SUBST(EXTRALIBS) +AC_SUBST(LIBDL) dnl *** dnl *** WRspice device library