summaryrefslogtreecommitdiffstats
path: root/Makerules
diff options
context:
space:
mode:
Diffstat (limited to 'Makerules')
-rw-r--r--Makerules38
1 files changed, 31 insertions, 7 deletions
diff --git a/Makerules b/Makerules
index f9810d0a1..b4df69bb6 100644
--- a/Makerules
+++ b/Makerules
@@ -2,7 +2,7 @@
# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
#
-.SUFFIXES: .c .S .o .os .oS .so .a .s .i .E
+.SUFFIXES: .c .S .o .os .oS .so .a .s .i
# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
ifeq ($(HAVE_SHARED),y)
@@ -11,6 +11,9 @@ libs: $(lib-so-y) $(lib-a-y)
$(lib-so-y): $(interp)
else
.LIBPATTERNS: "lib%.a"
+ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
+libs: $(lib-gdb-y)
+endif
libs: $(lib-a-y)
endif
objs: all_objs
@@ -101,7 +104,7 @@ cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
cmd_ar = $(AR) $(ARFLAGS) $@ $^
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
-compile.E = $(cmd_compile.c:-c=-E)
+compile.i = $(cmd_compile.c:-c=-E -dD)
compile.s = $(cmd_compile.c:-c=-S)
compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
@@ -131,6 +134,29 @@ define link.so
$(Q)$(LN) -sf $(1) $@
endef
+# CRT files needed by link-flat.so
+LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
+ $(top_builddir)lib/crtn.o
+
+# Create a shared flat library from the archive named by the first dependency.
+# $@ names the shared library's .gdb file, not the flat file itself.
+# (This is because the .gdb suffix makes the ELF file more distinctive
+# than the suffixless flat file.)
+#
+# Argument 1 is the shared library file -- i.e. $(@:.gdb=) -- and argument 2
+# is the shared library identifier. If it wasn't for $(disp_ld), we could
+# avoid passing $(@:.gdb=) as an argument and use $(@:.gdb=) instead of $(1).
+define link-flat.so
+ $(Q)$(INSTALL) -d $(dir $@)
+ $(Q)$(RM) $(1) $@
+ @$(disp_ld)
+ $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -o $(1) \
+ -elf2flt -shared-lib-id $(2) $(top_builddir)lib/Scrt1.o \
+ $(top_builddir)/lib/crti.o --whole-archive $(firstword $^) \
+ --no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
+ $(top_builddir)/lib/crtn.o
+endef
+
define linkm.so
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@@ -154,10 +180,8 @@ CFLAGS-.oS+=$(PICFLAG) -DSHARED
%.o: %.s ; $(compile.S)
%.os: %.s ; $(compile.S)
%.oS: %.s ; $(compile.S)
-%.E: %.c ; $(compile.E)
-%.E: %.S ; $(compile.E)
-%.i: %.c ; $(compile.E)
-%.i: %.S ; $(compile.E)
+%.i: %.c ; $(compile.i)
+%.i: %.S ; $(compile.i)
%.s: %.c ; $(compile.s)
%.s: %.S ; $(compile.s)
@@ -183,7 +207,7 @@ $(headers_dep):
CRT := crt1
-ifeq ($(HAVE_SHARED),y)
+ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
else
CRTS=$(top_builddir)lib/$(CRT).o