summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2005-09-28 12:34:41 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2005-09-28 12:34:41 +0000
commitf70602be19ff8042c369ea33b29f90b8c0f5d02e (patch)
tree146eb1810d44dc99f8bf26ecd71cec4ee5ba5b32 /ldso
parente1ac781ed8b4a0f44a696f95618b73d2fa490576 (diff)
Remove ar-target and shared targets, at build time now we traverse the tree only once. Generalize all toplevel makefiles. Make sure, that libdl.so is built against libc.so and not libc.a
Diffstat (limited to 'ldso')
-rw-r--r--ldso/Makefile35
-rw-r--r--ldso/ldso/Makefile70
-rw-r--r--ldso/libdl/Makefile77
3 files changed, 97 insertions, 85 deletions
diff --git a/ldso/Makefile b/ldso/Makefile
index dd7ff2052..340ddfacb 100644
--- a/ldso/Makefile
+++ b/ldso/Makefile
@@ -21,33 +21,38 @@ include $(TOPDIR)Rules.mak
DIRS = ldso libdl
-all: ldso libdl
-
ifeq ($(strip $(BUILD_UCLIBC_LDSO)),y)
-ldso: headers
- $(MAKE) -C ldso
-libdl: ldso headers
- $(MAKE) -C libdl
-shared: libdl
- $(MAKE) -C libdl shared
+all: subdirs
else
-ldso libdl shared:
- echo "Skipping $@ target"
+all:
endif
LN_HEADERS := $(patsubst %, include/%, elf.h)
LN_ARCH_HEADERS := $(patsubst %, include/%, dl-startup.h dl-syscalls.h dl-sysdep.h dl-debug.h)
HEADERS := $(LN_HEADERS) $(LN_ARCH_HEADERS) include/dl-progname.h
+
headers: $(HEADERS)
+
$(LN_HEADERS):
- $(LN) -fs $(TOPDIR)../$@ $@
+ $(LN) -sf $(TOPDIR)../$@ $@
+
$(LN_ARCH_HEADERS):
- $(LN) -fs ../ldso/$(TARGET_ARCH)/$(patsubst include/%,%,$@) $@
+ $(LN) -sf ../ldso/$(TARGET_ARCH)/$(patsubst include/%,%,$@) $@
+
include/dl-progname.h:
echo '#include "$(TARGET_ARCH)/elfinterp.c"' \
> include/dl-progname.h
-clean:
- set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d $@ ; done
- -find . -name '*~' | xargs $(RM)
+clean: subdirs_clean
$(RM) $(HEADERS)
+
+subdirs: $(patsubst %, _dir_%, $(DIRS))
+subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS))
+
+$(patsubst %, _dir_%, $(DIRS)): headers
+ $(MAKE) -C $(patsubst _dir_%, %, $@)
+
+$(patsubst %, _dirclean_%, $(DIRS)): dummy
+ $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
+
+.PHONY: dummy
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index eb05d1f4f..f08c64c2f 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -16,16 +16,8 @@
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
TOPDIR=../../
include $(TOPDIR)Rules.mak
-LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-
-# reset to initial (disabling predefined CFLAGS)
-ASFLAGS=
-ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
-ASFLAGS+=$(call check_as,--noexecstack)
-endif
XXFLAGS=$(XWARNINGS) $(SSP_DISABLE_FLAGS)
@@ -44,21 +36,6 @@ XXFLAGS+= -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFL
# BEWARE!!! At least mips* will die if -O0 is used!!!
XXFLAGS:=$(XXFLAGS:-O0=-O1)
XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
-LDFLAGS=$(CPU_LDFLAGS-y) -e _start -z now -Bsymbolic -shared --warn-common --export-dynamic --sort-common \
- -z combreloc --discard-locals --discard-all --no-undefined
-ifeq ($(UCLIBC_BUILD_RELRO),y)
- LDFLAGS+=-z relro
-endif
-
-CSRC= ldso.c
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-ASRC=$(shell ls $(TARGET_ARCH)/*.S 2>/dev/null)
-AOBJS=$(patsubst %.S,%.o, $(ASRC))
-OBJS=$(AOBJS) $(COBJS)
-
-ifneq ($(strip $(SUPPORT_LD_DEBUG)),y)
-LDFLAGS+=-s
-endif
ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
XXFLAGS+=-D__SUPPORT_LD_DEBUG__
@@ -71,25 +48,50 @@ endif
#This stuff will not work with -fomit-frame-pointer
XXFLAGS := $(XXFLAGS:-fomit-frame-pointer=)
-all: $(LDSO_FULLNAME)
+ASFLAGS=$(XXFLAGS)
+ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
+ASFLAGS+=$(call check_as,--noexecstack)
+endif
-$(LDSO_FULLNAME): $(OBJS) $(DLINK_OBJS)
- $(LD) $(LDFLAGS) -soname=$(UCLIBC_LDSO) \
- -o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC)
+LDFLAGS=$(CPU_LDFLAGS-y) -e _start -z now -Bsymbolic -shared --warn-common --export-dynamic --sort-common \
+ -z combreloc --discard-locals --discard-all --no-undefined
+
+ifeq ($(UCLIBC_BUILD_RELRO),y)
+LDFLAGS+=-z relro
+endif
+
+ifneq ($(strip $(SUPPORT_LD_DEBUG)),y)
+LDFLAGS+=-s
+endif
+
+LIB_NAME=ld-uClibc
+SO_LIB_NAME=$(TOPDIR)lib/$(UCLIBC_LDSO)
+SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
+
+CSRC= ldso.c
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+
+ASRC=$(wildcard $(TARGET_ARCH)/*.S)
+AOBJS=$(patsubst %.S,%.o, $(ASRC))
+
+OBJS=$(AOBJS) $(COBJS)
+
+all: $(SO_LIB_NAME)
+
+$(SO_LIB_NAME): $(OBJS)
$(INSTALL) -d $(TOPDIR)lib
- $(INSTALL) -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
- $(LN) -sf $(LDSO_FULLNAME) $(TOPDIR)lib/$(UCLIBC_LDSO)
+ $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME)
+ $(LD) $(LDFLAGS) -soname=$(UCLIBC_LDSO) \
+ -o $(TOPDIR)lib/$(SO_FULL_NAME) $(OBJS) $(LIBGCC)
+ $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME)
$(COBJS): %.o : %.c
$(CC) $(XXFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(AOBJS): %.o : %.S
- $(CC) $(XXFLAGS) $(ASFLAGS) -c $< -o $@
+ $(CC) $(ASFLAGS) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
-ldso.o: $(CSRC) dl-elf.c dl-hash.c dl-startup.c dl-debug.c \
- $(TARGET_ARCH)/*.h $(TARGET_ARCH)/*.c $(TOPDIR)ldso/include/*.h
-
clean:
- $(RM) $(UCLIBC_LDSO) $(LDSO_FULLNAME) core *.o */*.o *.a *.s *.i ldso.h *~
+ $(RM) *.o */*.o *~ core
diff --git a/ldso/libdl/Makefile b/ldso/libdl/Makefile
index 6a8b46ad6..a5b2f6be2 100644
--- a/ldso/libdl/Makefile
+++ b/ldso/libdl/Makefile
@@ -29,57 +29,62 @@ XXFLAGS+=$(OPTIMIZATION)
endif
XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
- -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include
+ -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I$(TOPDIR)include
XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
+ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
+XXFLAGS+=-D__SUPPORT_LD_DEBUG__
+endif
XXFLAGS_NOPIC:=$(XXFLAGS)
ifeq ($(DOPIC),y)
XXFLAGS += $(PICFLAG) -D__LIBDL_SHARED__
endif
-ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
-XXFLAGS+=-D__SUPPORT_LD_DEBUG__
-endif
-
-LIBDL=libdl.a
-LIBDL_PIC=libdl_pic.a
-LIBDL_SHARED=libdl.so
-LIBDL_SHARED_FULLNAME=libdl-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-CSRC=libdl.c
-OBJS=libdl.o
-PIC_OBJS=libdl_pic.o
+LIB_NAME=libdl
+AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a
+SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so
+SO_FULL_NAME=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-all: $(LIBDL) $(LIBDL_PIC)
+CSRC = libdl.c
+OBJS = libdl.o
+PIC_OBJS = libdl_pic.o
-ar-target: $(LIBDL) $(LIBDL_PIC)
+# we do not get here, do we need a libdl.a, if ld.so is not ours?
+#ifeq ($(strip $(HAVE_SHARED)),y)
+all: $(AR_LIB_NAME) $(SO_LIB_NAME)
+#else
+#all: $(AR_LIB_NAME)
+#endif
-$(LIBDL): $(OBJS)
- $(AR) $(ARFLAGS) $(LIBDL) ../ldso/$(TARGET_ARCH)/resolve.o $(OBJS)
+$(AR_LIB_NAME): $(OBJS) ../ldso/$(TARGET_ARCH)/resolve.o
$(INSTALL) -d $(TOPDIR)lib
- $(RM) $(TOPDIR)lib/$(LIBDL)
- $(INSTALL) -m 644 $(LIBDL) $(TOPDIR)lib
+ $(RM) $(AR_LIB_NAME)
+ $(AR) $(ARFLAGS) $(AR_LIB_NAME) $(OBJS) ../ldso/$(TARGET_ARCH)/resolve.o
-$(LIBDL_PIC): $(PIC_OBJS)
- $(AR) $(ARFLAGS) $(LIBDL_PIC) $(PIC_OBJS)
+shared_$(LIB_NAME).a: $(PIC_OBJS)
+ $(RM) shared_$(LIB_NAME).a
+ $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $(PIC_OBJS)
-libdl.o: libdl.c $(TOPDIR)ldso/include/*.h
- $(CC) $(XXFLAGS_NOPIC) -c libdl.c -o libdl.o
- $(STRIPTOOL) -x -R .note -R .comment $*.o
+# this will be built only on the second round, when libc.so is present,
+# else we would link against libc.a
+$(SO_LIB_NAME): shared_$(LIB_NAME).a
+ if [ -f $(TOPDIR)lib/libc.so ] ; then \
+ $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) $(SO_LIB_NAME) ; \
+ $(LD) $(LDFLAGS) -soname=$(LIB_NAME).so.$(MAJOR_VERSION) \
+ -o $(TOPDIR)lib/$(SO_FULL_NAME) -fini dl_cleanup --whole-archive shared_$(LIB_NAME).a \
+ --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \
+ -L$(TOPDIR)lib -lc $(LDADD_LIBFLOAT) $(TOPDIR)lib/$(UCLIBC_LDSO) $(LIBGCC) ; \
+ $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME).$(MAJOR_VERSION) ; \
+ $(LN) -sf $(SO_FULL_NAME) $(SO_LIB_NAME) ; \
+ fi
-libdl_pic.o: libdl.c $(TOPDIR)ldso/include/*.h
- $(CC) $(XXFLAGS) -c libdl.c -o libdl_pic.o
+$(OBJS): %.o : %.c
+ $(CC) $(XXFLAGS_NOPIC) -c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
-shared: $(LIBDL_PIC)
- $(LD) $(LDFLAGS) -soname=$(LIBDL_SHARED).$(MAJOR_VERSION) \
- -o $(LIBDL_SHARED_FULLNAME) -fini dl_cleanup --whole-archive $(LIBDL_PIC) \
- --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \
- -L$(TOPDIR)/lib -lc $(LDADD_LIBFLOAT) $(TOPDIR)lib/$(UCLIBC_LDSO) $(LIBGCC);
- $(INSTALL) -d $(TOPDIR)lib
- $(RM) $(TOPDIR)lib/$(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBDL_SHARED).$(MAJOR_VERSION)
- $(INSTALL) -m 644 $(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib
- $(LN) -sf $(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBDL_SHARED)
- $(LN) -sf $(LIBDL_SHARED_FULLNAME) $(TOPDIR)lib/$(LIBDL_SHARED).$(MAJOR_VERSION)
+libdl_pic.o: libdl.c
+ $(CC) $(XXFLAGS) -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
clean:
- $(RM) .depend $(LIBDL_SHARED)* $(LIBDL_SHARED_FULLNAME) core *.o *.a *.s *.i tmp_make foo *~
+ $(RM) *.o *~ core *.a