This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Relocatable binutils installs [1/2]
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: binutils at sources dot redhat dot com
- Date: Mon, 30 Dec 2002 16:12:02 -0500
- Subject: Relocatable binutils installs [1/2]
Right now, LD will search for the ldscripts dir in "<binarypath>/../lib".
This means that if you take an installed binutils tree and move it, it won't
find the ldscripts dir when run by hand; because LD is installed in
$(exec_prefix)/bin/ld and ldscripts are installed in
$(exec_prefix)/$(target_alias)/lib/ldscripts. There's another ld hardlink
in $(exec_prefix)/$(target_alias)/bin/ld, which can find the scripts
(although it searches the installed absolute path first, tsk tsk).
This patch uses the new make_relative_prefix in libiberty, moved there for
this reason, to find the scripts directory. This just adds an additional
search path before the others. I was going to remove the last fallback
until I noticed the problem above; there might conceivably be someone
relying on this...
This OK?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2002-12-30 Daniel Jacobowitz <drow@mvista.com>
* Makefile.am (ldmain.o): Pass BINDIR.
* Makefile.in: Regenerated.
* ldmain.c (set_scripts_dir): Use make_relative_prefix for the first
search path.
Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.116
diff -u -p -r1.116 Makefile.am
--- Makefile.am 30 Dec 2002 19:25:04 -0000 1.116
+++ Makefile.am 30 Dec 2002 21:02:10 -0000
@@ -391,7 +391,7 @@ po/POTFILES.in: @MAINT@ Makefile
&& mv tmp $(srcdir)/po/POTFILES.in
ldmain.o: ldmain.c config.status
- $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' -DSCRIPTDIR='"$(scriptdir)"' -DTARGET='"@target@"' $(srcdir)/ldmain.c
+ $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' -DTARGET='"@target@"' $(srcdir)/ldmain.c
ldemul-list.h: Makefile
(echo "/* This file is automatically generated. DO NOT EDIT! */";\
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/ld/Makefile.in,v
retrieving revision 1.126
diff -u -p -r1.126 Makefile.in
--- Makefile.in 30 Dec 2002 19:25:04 -0000 1.126
+++ Makefile.in 30 Dec 2002 21:02:11 -0000
@@ -1119,7 +1119,7 @@ po/POTFILES.in: @MAINT@ Makefile
&& mv tmp $(srcdir)/po/POTFILES.in
ldmain.o: ldmain.c config.status
- $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' -DSCRIPTDIR='"$(scriptdir)"' -DTARGET='"@target@"' $(srcdir)/ldmain.c
+ $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' -DTARGET='"@target@"' $(srcdir)/ldmain.c
ldemul-list.h: Makefile
(echo "/* This file is automatically generated. DO NOT EDIT! */";\
Index: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.57
diff -u -p -r1.57 ldmain.c
--- ldmain.c 23 Dec 2002 12:05:38 -0000 1.57
+++ ldmain.c 30 Dec 2002 21:02:11 -0000
@@ -612,14 +612,25 @@ check_for_scripts_dir (dir)
We look for the "ldscripts" directory in:
SCRIPTDIR (passed from Makefile)
+ (adjusted according to the current location of the binary)
+ SCRIPTDIR (passed from Makefile)
the dir where this program is (for using it from the build tree)
- the dir where this program is/../lib (for installing the tool suite elsewhere) */
+ the dir where this program is/../lib
+ (for installing the tool suite elsewhere) */
static void
set_scripts_dir ()
{
char *end, *dir;
size_t dirlen;
+
+ dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
+ if (dir && check_for_scripts_dir (dir))
+ /* Success. Don't free dir. */
+ return;
+
+ if (dir)
+ free (dir);
if (check_for_scripts_dir (SCRIPTDIR))
/* We've been installed normally. */