This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
sln for glibc 2.1
- To: libc-hacker@cygnus.com
- Subject: sln for glibc 2.1
- From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Date: Thu, 13 Aug 1998 14:15:24 +0200 (CEST)
Hi,
I've ported HJ Lu's patch for sln to glibc 2.1 and had a successful
install in my test environment (glibc 2.1 as secondary libc).
Uli, please add this for glibc 2.1.
Andreas
1998-08-13 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* Makefile ($(inst_slibdir)/libc-$(version).so): Remove.
(elf/ldso_install): Remove.
* elf/Makefile (distribute): Add sln.c.
(others): Add sln.
(others-static): Add sln.
(install-rootsbin): Add sln.
(others-static): Add sln.
(ldso_install): Remove.
1998-07-24 10:58 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules (install-clean-symbolic-link-list): Make phony.
* Makefile (install-symblolic-link): Make phony. Depend on
subdir_install for parallel makes.
1998-07-22 Ulrich Drepper <drepper@cygnus.com>
* elf/Makefile (distribute): Add sln.c
1998-07-21 07:10 H.J. Lu <hjl@gnu.org>
* elf/sln.c: New file.
* Makerules (symbolic-link-prog, symbolic-link-list): New
macros.
(install-clean-symbolic-link-list): New target.
(install): Depend on install-clean-symbolic-link-list.
(make-shlib-link): Changed for $(symbolic-link-list).
* Makefile (install-symblolic-link): New target.
(install): Depend on install-symblolic-link.
============================================================
Index: Makefile
--- Makefile 1998/07/22 16:11:55 1.173
+++ Makefile 1998/08/13 11:56:37
@@ -86,17 +86,15 @@
# Install from subdirectories too.
install: subdir_install
-# Make sure that the dynamic linker is installed before libc.
-$(inst_slibdir)/libc-$(version).so: elf/ldso_install
-
-.PHONY: elf/ldso_install
-elf/ldso_install:
- $(MAKE) -C $(@D) $(@F)
-
# Create links for shared libraries using the `ldconfig' program is possible.
# Ignore the error if we cannot update /etc/ld.so.cache.
ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
+install: install-symblolic-link
+.PHONY: install-symblolic-link
+install-symblolic-link: subdir_install
+ $(symbolic-link-prog) $(symbolic-link-list)
+
install:
-test ! -x $(common-objpfx)elf/ldconfig || \
$(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
============================================================
Index: Makerules
--- Makerules 1998/07/31 17:59:40 1.309
+++ Makerules 1998/08/13 11:56:38
@@ -649,17 +649,25 @@
endef
endif
-# XXX The following will have to be changed when `ldconfig' is available.
-ifneq (yes,$(cross-compiling))
-ifeq (yes,$(has-ldconfig))
+ifeq (no,$(cross-compiling))
+ifeq (yes,$(build-shared))
+# We need to clean the symbolic link list first.
+symbolic-link-prog := $(common-objpfx)elf/sln
+symbolic-link-list := $(common-objpfx)elf/symlink.list
+install: install-clean-symbolic-link-list
+.PHONY: install-clean-symbolic-link-list
+install-clean-symbolic-link-list:
+ rm -f $(symbolic-link-list)
+
define make-shlib-link
-@:
+echo $(<F) $@ >> $(symbolic-link-list)
endef
endif
endif
ifndef make-shlib-link
define make-shlib-link
-$(make-link)
+rm -f $@
+$(LN_S) $(<F) $@
endef
endif
============================================================
Index: elf/Makefile
--- elf/Makefile 1998/07/30 12:36:37 1.96
+++ elf/Makefile 1998/08/13 11:56:38
@@ -38,7 +38,7 @@
distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c \
genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
- dl-librecon.h interp.c
+ dl-librecon.h interp.c sln.c
extra-libs = libdl
extra-libs-others = $(extra-libs)
@@ -63,13 +63,15 @@
generated += ldd
endif
-others = sprof
+others = sprof sln
install-bin += sprof
+others-static = sprof sln
+install-rootsbin = sln
ifeq (yes,$(has-ldconfig))
others-static += ldconfig
others += ldconfig
-install-rootsbin = ldconfig
+install-rootsbin += ldconfig
endif
include ../Rules
@@ -160,10 +162,6 @@
$(inst_slibdir)/$(rtld-installed-name): \
$(inst_slibdir)/$(rtld-version-installed-name)
$(make-shlib-link)
-
-# Special target called by parent to install just the dynamic linker.
-.PHONY: ldso_install
-ldso_install: $(inst_slibdir)/$(rtld-installed-name)
sh-ldd-rewrite = -e 's%@RTLD@%$(slibdir)/$(rtld-installed-name)%g' \
============================================================
Index: elf/sln.c
--- elf/sln.c created
+++ elf/sln.c Wed Aug 12 21:38:18 1998 1.1
@@ -0,0 +1,190 @@
+/* `sln' program to create symboblic links between files.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#if !defined(S_ISDIR) && defined(S_IFDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+
+static int makesymlink __P ((const char *src, const char *dest));
+static int makesymlinks __P ((const char *file));
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ switch (argc)
+ {
+ case 2:
+ return makesymlinks (argv [1]) == 0 ? 0 : 1;
+ break;
+
+ case 3:
+ return makesymlink (argv [1], argv [2]) == 0 ? 0 : 1;
+ break;
+
+ default:
+ printf ("Usage: %s src dest|file\n", argv [0]);
+ return 1;
+ break;
+ }
+}
+
+static int
+makesymlinks (file)
+ const char *file;
+{
+#ifndef PATH_MAX
+#define PATH_MAX 4095
+#endif
+ char buffer [PATH_MAX * 4];
+ int i, ret, len;
+ int lineno;
+ const char *src;
+ const char *dest;
+ const char *error;
+ FILE *fp;
+
+ fp = fopen (file, "r");
+ if (fp == NULL)
+ {
+ error = strerror (errno);
+ fprintf (stderr, "%s: file open error: %s\n", file, error);
+ return -1;
+ }
+
+ ret = 0;
+ lineno = 0;
+ while (fgets (buffer, sizeof (buffer) - 1, fp))
+ {
+ lineno++;
+ src = dest = NULL;
+ buffer [sizeof (buffer) - 1] = '\0';
+ len = strlen (buffer);
+ for (i = 0; i < len && isspace (buffer [i]); i++);
+ if (i >= len)
+ {
+ fprintf (stderr, "Fail to parse line %d: \"%s\"\n", lineno,
+ buffer);
+ ret--;
+ continue;
+ }
+
+ src = &buffer [i];
+ for (; i < len && !isspace (buffer [i]); i++);
+ if (i < len)
+ {
+ buffer [i++] = '\0';
+ for (; i < len && isspace (buffer [i]); i++);
+ if (i >= len)
+ {
+ fprintf (stderr, "No target in line %d: \"%s\"\n", lineno,
+ buffer);
+ ret--;
+ continue;
+ }
+ dest = &buffer [i];
+ for (; i < len && !isspace (buffer [i]); i++);
+ buffer [i] = '\0';
+ }
+ else
+ {
+ fprintf (stderr, "No target in line %d: \"%s\"\n", lineno,
+ buffer);
+ ret--;
+ continue;
+ }
+
+ if (makesymlink (src, dest))
+ {
+ fprintf (stderr, "Failed to make link from \"%s\" to \"%s\" in line %d\n",
+ src, dest, lineno);
+ ret--;
+ }
+ }
+ fclose (fp);
+
+ return ret;
+}
+
+static int
+makesymlink (src, dest)
+ const char *src;
+ const char *dest;
+{
+ struct stat stats;
+ const char *error;
+
+ /* Destination must not be a directory. */
+ if (lstat (dest, &stats) == 0)
+ {
+ if (S_ISDIR (stats.st_mode))
+ {
+ fprintf (stderr, "%s: destination must not be a directory\n",
+ dest);
+ return -1;
+ }
+ else if (unlink (dest) && errno != ENOENT)
+ {
+ fprintf (stderr, "%s: failed to remove the old destination\n",
+ dest);
+ return -1;
+ }
+ }
+ else if (errno != ENOENT)
+ {
+ error = strerror (errno);
+ fprintf (stderr, "%s: invalid destination: %s\n", dest, error);
+ return -1;
+ }
+
+#ifdef S_ISLNK
+ if (symlink (src, dest) == 0)
+#else
+ if (link (src, dest) == 0)
+#endif
+ {
+ /* Destination must exist by now. */
+ if (access (dest, F_OK))
+ {
+ error = strerror (errno);
+ unlink (dest);
+ fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
+ src, dest, error);
+ return -1;
+ }
+ return 0;
+ }
+ else
+ {
+ error = strerror (errno);
+ fprintf (stderr, "Invalid link from \"%s\" to \"%s\": %s\n",
+ src, dest, error);
+ return -1;
+ }
+}
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@alma.student.uni-kl.de