From dd4d42c2b998b2b95912ac04106fb7a9b1b0a57e Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Thu, 31 May 2001 21:23:20 +0000 Subject: Removed INSTALL_DIR and replaced it with DEVEL_PREFIX, ROOT_DIR, and TARGET_PREFIX to allow more flexibility. Also modified the gcc wrapper to do the right thing if -Wl,--dynamic-linker,xxx is passed on the command line. The gcc wrapper will also check the env variable UCLIBC_GCC_LDOPT for a dynamic linker option at runtime (although command line arg overrides the env variable). --- .cvsignore | 1 + Makefile | 49 ++++++++++++++++---------- README | 6 +++- Rules.mak | 2 +- extra/Configs/Config.arm | 33 +++++++++-------- extra/Configs/Config.i386 | 33 +++++++++-------- extra/Configs/Config.m68k | 33 +++++++++-------- extra/Configs/Config.mips | 33 +++++++++-------- extra/Configs/Config.mipsel | 33 +++++++++-------- extra/Configs/Config.powerpc | 33 +++++++++-------- extra/Configs/Config.sh | 34 +++++++++--------- extra/Configs/Config.x86 | 33 +++++++++-------- extra/gcc-uClibc/Makefile | 25 ++++++------- extra/gcc-uClibc/gcc-uClibc.c | 82 +++++++++++++++++++++++++------------------ ldso/README | 19 ---------- ldso/Rules.mak | 7 ++-- ldso/config.h | 10 +++--- ldso/ldso/dl-elf.c | 30 ++-------------- ldso/ldso/readelflib1.c | 30 ++-------------- ldso/util/ldconfig.c | 6 ++-- 20 files changed, 255 insertions(+), 277 deletions(-) diff --git a/.cvsignore b/.cvsignore index 45aa35e0c..f1a5a4de1 100644 --- a/.cvsignore +++ b/.cvsignore @@ -7,3 +7,4 @@ uClibc-0* libuClibc-0* lib Config +_install diff --git a/Makefile b/Makefile index 04624727b..3de16caf9 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ ifeq ($(DO_SHARED),shared) endif DIRS = extra $(LDSO_DIR) libc libcrypt libresolv libutil libm +ifndef $(TARGET_PREFIX) + TARGET_PREFIX = `pwd`/_install +endif + all: headers uClibc_config.h subdirs $(DO_SHARED) done shared: @@ -143,40 +147,49 @@ $(patsubst %, _dir_%, $(DIRS)) : dummy tags: ctags -R -install: install_runtime install_dev +install: install_dev -# Installs shared library -install_runtime: - install -d $(INSTALL_DIR)/lib - cp -fa lib/* $(INSTALL_DIR)/lib; +# Installs shared libraries for a target. +install_target: +ifeq ($(DO_SHARED),shared) + install -d $(TARGET_PREFIX)$(ROOT_DIR)/lib + cp -fa lib/*.so* $(TARGET_PREFIX)$(ROOT_DIR)/lib; #ifeq ($(LDSO_PRESENT), $(TARGET_ARCH)) - ln -sf $(INSTALL_DIR)/lib/$(UCLIBC_LDSO) /lib/$(UCLIBC_LDSO); - install -d $(INSTALL_DIR)/etc - -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi +# install -d $(TARGET_PREFIX)$(ROOT_DIR)/etc +# -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi #endif +endif # Installs development library and headers # This is done with the assumption that it can blow away anything -# in $(INSTALL_DIR)/include. Probably true only if you're using +# in $(DEVEL_PREFIX)$(ROOT_DIR)/include. Probably true only if you're using # a packaging system. install_dev: - install -d $(INSTALL_DIR)/usr/include - install -d $(INSTALL_DIR)/usr/include/bits - rm -f $(INSTALL_DIR)/usr/include/asm - rm -f $(INSTALL_DIR)/usr/include/linux - ln -s $(KERNEL_SOURCE)/include/asm $(INSTALL_DIR)/usr/include/asm - ln -s $(KERNEL_SOURCE)/include/linux $(INSTALL_DIR)/usr/include/linux + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/lib + cp -fa lib/*.so* $(DEVEL_PREFIX)$(ROOT_DIR)/lib; + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib + cp -fa lib/*.[ao] $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib; + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits + rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm + rm -f $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux + ln -s $(KERNEL_SOURCE)/include/asm $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/asm + ln -s $(KERNEL_SOURCE)/include/linux $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/linux find include/ -type f -depth -not -path "*CVS*" -exec install \ - -D -m 644 {} $(INSTALL_DIR)/usr/'{}' ';' + -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';' find include/bits/ -type f -depth -not -path "*CVS*" -exec install \ - -D -m 644 {} $(INSTALL_DIR)/usr/'{}' ';' - install -m 644 include/bits/uClibc_config.h $(INSTALL_DIR)/usr/include/bits/ + -D -m 644 {} $(DEVEL_PREFIX)$(ROOT_DIR)/usr/'{}' ';' + install -m 644 include/bits/uClibc_config.h $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include/bits/ $(MAKE) -C extra/gcc-uClibc install clean: @rm -rf tmp lib - find include -type l -exec rm -f {} \; - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core \) -exec rm -f {} \; +ifeq ($(DO_SHARED),shared) + make -C ldso clean +endif .PHONY: dummy subdirs diff --git a/README b/README index ab3ca34b5..845294cd2 100644 --- a/README +++ b/README @@ -7,6 +7,10 @@ To build uClibc, To compile programs with uClibc, -export PATH={uClibc INSTALL_DIR}/bin:$PATH +export PATH={uClibc DEVEL_PREFIX/ROOT_DIR}/bin:$PATH and then just ./configure and make as usual. + +Note: You may also want to look at extra/gcc-uclibc/gcc-uclibc.c for + additional information concerning what options and environment + variables the gcc wrapper handles. diff --git a/Rules.mak b/Rules.mak index 28a1c84a5..a90786adc 100644 --- a/Rules.mak +++ b/Rules.mak @@ -79,7 +79,7 @@ endif ifeq ($(LDSO_PRESENT), $(TARGET_ARCH)) LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO) - DYNAMIC_LINKER=/lib/$(UCLIBC_LDSO) + DYNAMIC_LINKER=$(ROOT_DIR)/lib/$(UCLIBC_LDSO) else LDSO=$(SYSTEM_LDSO) DYNAMIC_LINKER=$(SYSTEM_LDSO) diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm index 603ae7e07..85f3cab74 100644 --- a/extra/Configs/Config.arm +++ b/extra/Configs/Config.arm @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/Configs/Config.i386 b/extra/Configs/Config.i386 index 47d422289..0897d9a1f 100644 --- a/extra/Configs/Config.i386 +++ b/extra/Configs/Config.i386 @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/Configs/Config.m68k b/extra/Configs/Config.m68k index f1f8ed8e7..8ae75d2fb 100644 --- a/extra/Configs/Config.m68k +++ b/extra/Configs/Config.m68k @@ -129,23 +129,26 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = true -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /opt/uClinux/$(TARGET_ARCH)-pic-elf +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /opt/uClinux/$(TARGET_ARCH)-pic-elf +TARGET_PREFIX = # # ARCH_CFLAGS if your have something special to add to the CFLAGS diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips index a3a45c623..ea989a596 100644 --- a/extra/Configs/Config.mips +++ b/extra/Configs/Config.mips @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/Configs/Config.mipsel b/extra/Configs/Config.mipsel index a3a45c623..ea989a596 100644 --- a/extra/Configs/Config.mipsel +++ b/extra/Configs/Config.mipsel @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/Configs/Config.powerpc b/extra/Configs/Config.powerpc index 703298958..6b96f8c77 100644 --- a/extra/Configs/Config.powerpc +++ b/extra/Configs/Config.powerpc @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/Configs/Config.sh b/extra/Configs/Config.sh index 77a0b0b1a..82ff6daf3 100644 --- a/extra/Configs/Config.sh +++ b/extra/Configs/Config.sh @@ -150,21 +150,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /opt/uClinux/$(TARGET_ARCH)-pic-elf - +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /opt/uClinux/$(TARGET_ARCH)-pic-elf +TARGET_PREFIX = diff --git a/extra/Configs/Config.x86 b/extra/Configs/Config.x86 index 47d422289..0897d9a1f 100644 --- a/extra/Configs/Config.x86 +++ b/extra/Configs/Config.x86 @@ -129,20 +129,23 @@ DOLFS = false # disabled. This is off by default. INCLUDE_RPC = false -# Installation location. For the default uClinux installation from -# Lineo for m68k, it should be: -# /opt/uClinux/m68k-pic-coff -# so includes installed in: /opt/uClinux/m68k-pic-coff/include -# libc.a and crt0.o in: /opt/uClinux/m68k-pic-coff/lib -# -# For ARM it should be: -# /opt/uClinux/arm-pic-elf -# so includes installed in: /opt/uClinux/arm-pic-elf/include -# libc.a and crt0.o in: /opt/uClinux/arm-pic-elf/lib +# ROOT_DIR is the base directory which will be compiled into the uClibc +# runtime environment. When compiled as a shared library, the shared +# library loader will look in /lib and /usr/lib +# for shared libraries. # -# For x86 this should be: -# /usr/i386-linux-uclibc -# so includes installed in: /usr/i386-linux-uclibc/include -# libc.a, libc.so.#, crt0.o in: /usr/i386-linux-uclibc/lib +# DEVEL_PREFIX is the base directory which will be compiled into the uClibc +# development environment. The uClibc development environment will +# look for the uClibc header files under /usr/include, +# and for static libs and crt0.o in /usr/lib. +# Also, 'make install' will install the compiler tools to +# /bin and /usr/bin. # -INSTALL_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +# TARGET_PREFIX is the directory under which 'make install' will install the +# uClibc runtime environment. This path does not get compiled into anything, +# and is provided simply to make it easier to build standalone target systems. +# Note: This doesn't do anything if there are no shared libs. + +DEVEL_PREFIX = +ROOT_DIR = /usr/$(TARGET_ARCH)-linux-uclibc +TARGET_PREFIX = diff --git a/extra/gcc-uClibc/Makefile b/extra/gcc-uClibc/Makefile index 71e31620c..3cfdad478 100644 --- a/extra/gcc-uClibc/Makefile +++ b/extra/gcc-uClibc/Makefile @@ -11,7 +11,8 @@ all: gcc-uClibc ld-uClibc gcc-uClibc.h: clean @echo "/* this file was autogenerated by make */" > gcc-uClibc.h - @echo "#define UCLIBC_INSTALL_DIR " \"$(INSTALL_DIR)/\" >> gcc-uClibc.h + @echo "#define UCLIBC_ROOT_DIR " \"$(ROOT_DIR)\" >> gcc-uClibc.h + @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)/\" >> gcc-uClibc.h @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h @echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h @@ -25,28 +26,28 @@ gcc-uClibc: gcc-uClibc.h gcc-uClibc.c ld-uClibc: @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld - @echo "$(LD_BIN) -L- -L$(INSTALL_DIR)/lib -L$(INSTALL_DIR)/usr/lib "\ + @echo "$(LD_BIN) -L- -L$(DEVEL_PREFIX)$(ROOT_DIR)/lib -L$(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib "\ "-L$(UCLIBC_DIR) \$$@" >> $(TARGET_ARCH)-uclibc-ld chmod a+x $(TARGET_ARCH)-uclibc-ld install: all - install -d $(INSTALL_DIR)/bin; - install -d $(INSTALL_DIR)/usr/bin; + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/bin; + install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin; if [ -x ./$(TARGET_ARCH)-uclibc-gcc ] ; then \ - install -m 755 $(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/usr/bin/ ; \ - install -m 755 $(TARGET_ARCH)-uclibc-ld $(INSTALL_DIR)/usr/bin/ ; \ - ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/cc; \ - ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/gcc; \ - ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-ld $(INSTALL_DIR)/bin/ld; \ - ln -fs $(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-cc; \ + install -m 755 $(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/ ; \ + install -m 755 $(TARGET_ARCH)-uclibc-ld $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/ ; \ + ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/bin/cc; \ + ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/bin/gcc; \ + ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-ld $(DEVEL_PREFIX)$(ROOT_DIR)/bin/ld; \ + ln -fs $(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-cc; \ fi; for app in addr2line ar as cpp gasp nm objcopy \ objdump ranlib readelf size strings strip; do \ - ln -fs `which $(CROSS)$${app}` $(INSTALL_DIR)/bin/$${app}; \ + ln -fs `which $(CROSS)$${app}` $(DEVEL_PREFIX)$(ROOT_DIR)/bin/$${app}; \ done; for app in addr2line ar as cpp gasp nm objcopy \ objdump ranlib readelf size strings strip; do \ - ln -fs `which $(CROSS)$${app}` $(INSTALL_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-$${app}; \ + ln -fs `which $(CROSS)$${app}` $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-$${app}; \ done; diff --git a/extra/gcc-uClibc/gcc-uClibc.c b/extra/gcc-uClibc/gcc-uClibc.c index 9c6cec3eb..2cbf7f3d4 100644 --- a/extra/gcc-uClibc/gcc-uClibc.c +++ b/extra/gcc-uClibc/gcc-uClibc.c @@ -36,6 +36,29 @@ * * The wrapper now displays the command line passed to gcc when '-v' is used. * + * May 31, 2001 + * + * "rpath" and "build" behavior are now decoupled. You can of course get + * the old "build" behavior by setting UCLIBC_GCC="rpath-build". Order + * isn't important here, as only the substrings are searched for. + * + * Added environment variable check for UCLIBC_GCC_DLOPT to let user specify + * an alternative dynamic linker at runtime without using command line args. + * Since this wouldn't commonly be used, I made it easy on myself. You have + * to match the option you would have passed to the gcc wrapper. As an + * example, + * + * export UCLIBC_GCC_DLOPT="-Wl,--dynamic-linker,/lib/ld-alt-linker.so.3" + * + * This is really only useful if target arch == devel arch and DEVEL_PREFIX + * isn't empty. It involves a recompile, but you can at least test apps + * on your devel system if combined with the "rpath" behavor if by using + * LD_LIBRARY_PATH, etc. + * + * Also added check for "-Wl,--dynamic-linker" on the command line. The + * use default dynamic linker or the envirnment-specified dynamic linker + * is disabled in that case. + * */ /* @@ -51,34 +74,32 @@ #include "gcc-uClibc.h" -#if 0 static char *rpath_link[] = { - "-Wl,-rpath-link,"UCLIBC_INSTALL_DIR"lib", - "-Wl,-rpath-link,"UCLIBC_BUILD_DIR"lib" + "-Wl,-rpath-link,"UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/lib", + "-Wl,-rpath-link,"UCLIBC_BUILD_DIR"/lib" }; static char *rpath[] = { - "-Wl,-rpath,"UCLIBC_INSTALL_DIR"lib", - "-Wl,-rpath,"UCLIBC_BUILD_DIR"lib" + "-Wl,-rpath,"UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/lib", + "-Wl,-rpath,"UCLIBC_BUILD_DIR"/lib" }; -#endif static char *uClibc_inc[] = { - "-I"UCLIBC_INSTALL_DIR"usr/include/", - "-I"UCLIBC_BUILD_DIR"include/" + "-I"UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/usr/include/", + "-I"UCLIBC_BUILD_DIR"/include/" }; static char *crt0_path[] = { - UCLIBC_INSTALL_DIR"lib/crt0.o", - UCLIBC_BUILD_DIR"lib/crt0.o" + UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/usr/lib/crt0.o", + UCLIBC_BUILD_DIR"/lib/crt0.o" }; static char *lib_path[] = { - "-L"UCLIBC_INSTALL_DIR"lib", - "-L"UCLIBC_BUILD_DIR"lib" + "-L"UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/lib", + "-L"UCLIBC_BUILD_DIR"/lib" }; -static char *usr_lib_path = "-L"UCLIBC_INSTALL_DIR"usr/lib"; +static char *usr_lib_path = "-L"UCLIBC_DEVEL_PREFIX UCLIBC_ROOT_DIR"/usr/lib"; static char static_linking[] = "-static"; static char nostdinc[] = "-nostdinc"; @@ -93,8 +114,14 @@ int main(int argc, char **argv) int source_count = 0, use_rpath = 0, verbose = 0; int i, j; char ** gcc_argv; + char *dlstr; char *ep; + dlstr = getenv("UCLIBC_GCC_DLOPT"); + if (!dlstr) { + dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER; + } + ep = getenv("UCLIBC_GCC"); if (!ep) { ep = ""; @@ -102,7 +129,8 @@ int main(int argc, char **argv) if ((strstr(argv[0],"build") != 0) || (strstr(ep,"build") != 0)) { use_build_dir = 1; - } + +} if ((strstr(argv[0],"rpath") != 0) || (strstr(ep,"rpath") != 0)) { use_rpath = 1; @@ -144,6 +172,9 @@ int main(int argc, char **argv) if (strstr(argv[i],static_linking) != 0) { use_static_linking = 1; } + if (strstr(argv[i],"--dynamic-linker") != 0) { + dlstr = 0; + } } break; case '-': @@ -177,33 +208,14 @@ int main(int argc, char **argv) } if (linking && source_count) { if (!use_static_linking) { - if (DYNAMIC_LINKER[0]) { /* not empty string */ -#if 1 - gcc_argv[i++] = "-Wl,--dynamic-linker,"DYNAMIC_LINKER; - if (strstr(DYNAMIC_LINKER,"uclibc") != 0) { /* custom linker */ - use_rpath = 0; /* so -rpath not needed for normal case */ - } -#else - char *dlstr = "-Wl,--dynamic-linker,"DYNAMIC_LINKER; - if (strstr(DYNAMIC_LINKER,"uclibc") != 0) { /* custom linker */ - use_rpath = 0; /* so -rpath not needed for normal case */ - if (use_build_dir) { - dlstr = "-Wl,--dynamic-linker," \ - UCLIBC_BUILD_DIR DYNAMIC_LINKER; - } - } + if (dlstr) { gcc_argv[i++] = dlstr; -#endif } -#if 0 - if (use_build_dir || use_rpath) { + if (use_rpath) { gcc_argv[i++] = rpath[use_build_dir]; } -#endif } -#if 0 gcc_argv[i++] = rpath_link[use_build_dir]; /* just to be safe */ -#endif gcc_argv[i++] = lib_path[use_build_dir]; if (!use_build_dir) { gcc_argv[i++] = usr_lib_path; diff --git a/ldso/README b/ldso/README index b5bb93e67..dc37ea65c 100644 --- a/ldso/README +++ b/ldso/README @@ -5,25 +5,6 @@ Inital port for uClibc from debian ld.so_1.9.11-9.tar.gz. Removed a.out support. -"make" generates the ld-uclibc.so.0, libdl.so.0, ldd, ldconfig - suitable for the target platform. - -"make DEVEL=true" generates the same files, but ld-uclibc.so.0 and - ldconfig are modified to not conflict with the devel platform system - libs. (This is only of use if TARGET_ARCH == NATIVE_ARCH.) These - modified versions ignore /lib and /usr/lib and look for shared libs - only in $(INSTALL_DIR)/lib. The modified ldconfig writes ld.so.cache - in $(INSTALL_DIR)/etc. - -The above assumes you've set the DYNAMIC_LINKER to /lib/ld-uclibc.so.0 -in extra/gcc-uClibc/Makefile. - -Todo: - -Remove unneeded code in util/ldd.c. -Link against static uClibc instead of using custom routines. ??? -Lots more cleanup... especially the arch-dependent Makefiles. - ****************** original ld.so.lsm file ************************** Begin3 Title: Linux shared, dynamic linker and utilities. diff --git a/ldso/Rules.mak b/ldso/Rules.mak index c0bd561bb..f2eccd4a8 100644 --- a/ldso/Rules.mak +++ b/ldso/Rules.mak @@ -2,12 +2,9 @@ include $(TOPDIR)Rules.mak LDSO_VERSION=1.9.11 -DEVEL=true - # Do NOT use -fomit-frame-pointer -- It won't work! CFLAGS += -DVERSION=\"$(LDSO_VERSION)\" CC = $(TOPDIR)extra/gcc-uClibc/$(NATIVE_ARCH)-uclibc-gcc -ifeq ($(DEVEL),true) - CFLAGS += -DUCLIBC_INSTALL_DIR=\"$(INSTALL_DIR)\" -endif + +CFLAGS += -DUCLIBC_ROOT_DIR=\"$(ROOT_DIR)\" diff --git a/ldso/config.h b/ldso/config.h index 26171138d..3dbf0cdfa 100644 --- a/ldso/config.h +++ b/ldso/config.h @@ -5,11 +5,11 @@ # define LDSO_PRELOAD "../util/ld.so.preload" # define LDDSTUB "../util/lddstub" #else -# define LDSO_IMAGE UCLIBC_INSTALL_DIR"/lib/ld.so" -# define LDSO_CONF UCLIBC_INSTALL_DIR"/etc/ld.so.conf" -# define LDSO_CACHE UCLIBC_INSTALL_DIR"/etc/ld.so.cache" -# define LDSO_PRELOAD UCLIBC_INSTALL_DIR"/etc/ld.so.preload" -# define LDDSTUB UCLIBC_INSTALL_DIR"/usr/lib/lddstub" +# define LDSO_IMAGE UCLIBC_ROOT_DIR "/lib/ld.so" +# define LDSO_CONF UCLIBC_ROOT_DIR "/etc/ld.so.conf" +# define LDSO_CACHE UCLIBC_ROOT_DIR "/etc/ld.so.cache" +# define LDSO_PRELOAD UCLIBC_ROOT_DIR "/etc/ld.so.preload" +# define LDDSTUB UCLIBC_ROOT_DIR "/usr/lib/lddstub" #endif #define LDD_ARGV0 "__LDD_ARGV0" diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 78ba9d0d2..a80aa0579 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -248,7 +248,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, #endif /* Check in /usr/lib */ - pnt1 = UCLIBC_INSTALL_DIR "/usr/lib/"; + pnt1 = UCLIBC_ROOT_DIR "/usr/lib/"; pnt = mylibname; while (*pnt1) *pnt++ = *pnt1++; @@ -261,33 +261,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, return tpnt1; /* Check in /lib */ - pnt1 = UCLIBC_INSTALL_DIR "/lib/"; - pnt = mylibname; - while (*pnt1) - *pnt++ = *pnt1++; - pnt1 = libname; - while (*pnt1) - *pnt++ = *pnt1++; - *pnt++ = 0; - tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0); - if (tpnt1) - return tpnt1; - - /* Check in /usr/lib */ - pnt1 = "/usr/lib/"; - pnt = mylibname; - while (*pnt1) - *pnt++ = *pnt1++; - pnt1 = libname; - while (*pnt1) - *pnt++ = *pnt1++; - *pnt++ = 0; - tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0); - if (tpnt1) - return tpnt1; - - /* Check in /lib */ - pnt1 = "/lib/"; + pnt1 = UCLIBC_ROOT_DIR "/lib/"; pnt = mylibname; while (*pnt1) *pnt++ = *pnt1++; diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c index 78ba9d0d2..a80aa0579 100644 --- a/ldso/ldso/readelflib1.c +++ b/ldso/ldso/readelflib1.c @@ -248,7 +248,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, #endif /* Check in /usr/lib */ - pnt1 = UCLIBC_INSTALL_DIR "/usr/lib/"; + pnt1 = UCLIBC_ROOT_DIR "/usr/lib/"; pnt = mylibname; while (*pnt1) *pnt++ = *pnt1++; @@ -261,33 +261,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, return tpnt1; /* Check in /lib */ - pnt1 = UCLIBC_INSTALL_DIR "/lib/"; - pnt = mylibname; - while (*pnt1) - *pnt++ = *pnt1++; - pnt1 = libname; - while (*pnt1) - *pnt++ = *pnt1++; - *pnt++ = 0; - tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0); - if (tpnt1) - return tpnt1; - - /* Check in /usr/lib */ - pnt1 = "/usr/lib/"; - pnt = mylibname; - while (*pnt1) - *pnt++ = *pnt1++; - pnt1 = libname; - while (*pnt1) - *pnt++ = *pnt1++; - *pnt++ = 0; - tpnt1 = _dl_load_elf_shared_library(secure, mylibname, 0); - if (tpnt1) - return tpnt1; - - /* Check in /lib */ - pnt1 = "/lib/"; + pnt1 = UCLIBC_ROOT_DIR "/lib/"; pnt = mylibname; while (*pnt1) *pnt++ = *pnt1++; diff --git a/ldso/util/ldconfig.c b/ldso/util/ldconfig.c index 5c041f8b8..55f79f773 100644 --- a/ldso/util/ldconfig.c +++ b/ldso/util/ldconfig.c @@ -684,10 +684,8 @@ int main(int argc, char **argv) free(extpath); } - scan_dir(UCLIBC_INSTALL_DIR"/usr/lib"); - scan_dir(UCLIBC_INSTALL_DIR"/lib"); - scan_dir("/usr/lib"); - scan_dir("/lib"); + scan_dir(UCLIBC_ROOT_DIR "/usr/lib"); + scan_dir(UCLIBC_ROOT_DIR "/lib"); } if (!nocache) -- cgit v1.2.3