From: Keith Seitz <keiths@cygnus.com>
To: Insight Maling List <insight@sources.redhat.com>
Cc: Ian Roxborough <irox@cygnus.com>
Subject: [PATCH] Set paths for uninstalled runs
Date: Wed, 15 Aug 2001 14:15:00 -0000 [thread overview]
Message-ID: <Pine.GSO.4.33.0108151414080.25893-100000@makita.cygnus.com> (raw)
Hi,
I've committed the following patch. We're one step closer to tcl/tk 8.3!
Much thanks to Ian Roxborough for jump-starting this.
Keith
ChangeLog
2001-08-15 Keith Seitz <keiths@redhat.com>
* generic/gdbtk.c (gdbtk_init): Don't assume a particular
layout for the source directory, let the Makefile tell us
where the real source directory is.
When compiling under Cygwin, convert the (posix) path to a
win32 path, which is what tcl really wants.
2001-08-15 Ian Roxborough <irox@redhat.com>
* generic/gdbtk.c (gdbtk_init): If Insight isn't
executed from inside a directory called "bin",
assume that we are being running from the build
directory and set the *_LIBRARY variables to point
to (hopefully) the correct source directory.
Patch
Index: generic/gdbtk.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.c,v
retrieving revision 1.15
diff -u -p -r1.15 gdbtk.c
--- gdbtk.c 2001/06/07 14:43:01 1.15
+++ gdbtk.c 2001/08/15 21:12:51
@@ -365,6 +365,9 @@ gdbtk_init (argv0)
{
struct cleanup *old_chain;
char *s;
+ int element_count;
+ char **exec_path;
+ CONST char *internal_exec_name;
/* If there is no DISPLAY environment variable, Tk_Init below will fail,
causing gdb to abort. If instead we simply return here, gdb will
@@ -388,6 +391,94 @@ gdbtk_init (argv0)
if (!gdbtk_interp)
error ("Tcl_CreateInterp failed");
+ /* We need to check if we are being run from
+ a bin directory, if not then we may have to
+ set some environment variables. */
+
+ internal_exec_name = Tcl_GetNameOfExecutable ();
+
+ Tcl_SplitPath ((char *) internal_exec_name, &element_count, &exec_path);
+
+ if (strcmp (exec_path[element_count - 2], "bin") != 0)
+ {
+ /* We check to see if TCL_LIBRARY, TK_LIBRARY,
+ ITCL_LIBRARY, ITK_LIBRARY, TIX_LIBRARY and maybe
+ a couple other environment variables have been
+ set (we don't want to override the User's settings).
+ If the *_LIBRARY variable is not set, point it at
+ the source directory. */
+
+ static char set_libs_path_script[] = "\
+ set srcDir [file dirname [file dirname $env(TCL_LIBRARY)]];\n\
+\
+ if {![info exists env(TCL_LIBRARY)]} {\n\
+ set env(TCL_LIBRARY) [file join $srcDir tcl library]\n\
+ }\n\
+\
+ if {![info exists env(TK_LIBRARY)]} {\n\
+ set env(TK_LIBRARY) [file join $srcDir tk library]\n\
+ }\n\
+\
+ if {![info exists env(ITCL_LIBRARY)]} {\n\
+ set env(ITCL_LIBRARY) [file join $srcDir itcl itcl library]\n\
+ }\n\
+\
+ if {![info exists env(ITK_LIBRARY)]} {\n\
+ set env(ITK_LIBRARY) [file join $srcDir itcl itk library]\n\
+ }\n\
+\
+ if {![info exists env(TIX_LIBRARY)]} {\n\
+ set env(TIX_LIBRARY) [file join $srcDir tix library]\n\
+ }\n\
+\
+ if {![info exists env(GDBTK_LIBRARY)]} {\n\
+ set env(GDBTK_LIBRARY) [file join $srcDir gdb gdbtk library]\n\
+ }\n";
+
+ Tcl_Obj *commandObj;
+
+ /* Before we can run our script we must set TCL_LIBRARY. */
+ if (Tcl_GetVar2 (gdbtk_interp, "env", "TCL_LIBRARY", TCL_GLOBAL_ONLY) == NULL)
+ {
+ int i, count;
+ char *src_dir = SRC_DIR;
+ char **src_path;
+ char **lib_path;
+ Tcl_DString lib_dstring;
+
+ Tcl_DStringInit (&lib_dstring);
+
+#ifdef __CYGWIN__
+ /* SRC_DIR from configure is a posix path. Tcl really needs a
+ windows path. */
+ src_dir = (char *) alloca (cygwin_posix_to_win32_path_list_buf_size (SRC_DIR));
+ cygwin_posix_to_win32_path_list (SRC_DIR, src_dir);
+#endif
+ Tcl_SplitPath (src_dir, &count, &src_path);
+
+ /* Append tcl/library to src_dir (src_dir=/foo/bar/gdb) */
+ lib_path = (char **) alloca ((count + 2) * sizeof (char *));
+ for (i = 0; i < count - 1; i++)
+ lib_path[i] = src_path[i];
+ lib_path[i++] = "tcl";
+ lib_path[i++] = "library";
+ Tcl_JoinPath (i, lib_path, &lib_dstring);
+
+ /* Set TCL_LIBRARY */
+ Tcl_SetVar2 (gdbtk_interp, "env", "TCL_LIBRARY",
+ Tcl_DStringValue (&lib_dstring) , TCL_GLOBAL_ONLY);
+ Tcl_DStringFree (&lib_dstring);
+ Tcl_Free ((char *) src_path);
+ }
+
+ commandObj = Tcl_NewStringObj (set_libs_path_script, -1);
+ Tcl_IncrRefCount (commandObj);
+ Tcl_EvalObj (gdbtk_interp, commandObj);
+ Tcl_DecrRefCount (commandObj);
+ }
+
+ Tcl_Free ((char *) exec_path);
+
if (Tcl_Init (gdbtk_interp) != TCL_OK)
error ("Tcl_Init failed: %s", gdbtk_interp->result);
@@ -467,7 +558,7 @@ gdbtk_init (argv0)
error ("Gdbtk_Init failed: %s", gdbtk_interp->result);
}
- Tcl_StaticPackage (gdbtk_interp, "Gdbtk", Gdbtk_Init, NULL);
+ Tcl_StaticPackage (gdbtk_interp, "Insight", Gdbtk_Init, NULL);
/* This adds all the hooks that call up from the bowels of gdb
* back into Tcl-land...
@@ -511,7 +602,7 @@ gdbtk_init (argv0)
proc gdbtk_find_main {} {\n\
global Paths GDBTK_LIBRARY\n\
rename gdbtk_find_main {}\n\
- tcl_findLibrary gdb 1.0 {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY gdbtk/library gdbtcl {}\n\
+ tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTKLIBRARY\n\
set Paths(appdir) $GDBTK_LIBRARY\n\
}\n\
gdbtk_find_main";
@@ -527,7 +618,7 @@ proc gdbtk_find_main {} {\n\
} else {\n\
set debug_startup 0\n\
}\n\
- tcl_findLibrary gdb 1.0 {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY gdbtk/library gdbtcl {} $debug_startup\n\
+ tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY\n\
set Paths(appdir) $GDBTK_LIBRARY\n\
}\n\
gdbtk_find_main";
reply other threads:[~2001-08-15 14:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.33.0108151414080.25893-100000@makita.cygnus.com \
--to=keiths@cygnus.com \
--cc=insight@sources.redhat.com \
--cc=irox@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).