2 # Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
5 .SUFFIXES: .c .S .o .os .oS .so .a .s .i
7 # order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
8 ifeq ($(HAVE_SHARED),y)
9 .LIBPATTERNS: "lib%.so"
10 libs: lib-so-y lib-a-y
12 .LIBPATTERNS: "lib%.a"
19 compile.c=$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<))
20 compile.S=$(compile.c) $(S_CPPFLAGS) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $@)) $(ASFLAGS-$(notdir $<))
21 compile.m=$(compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
23 compile-m=$(CC) $^ -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<)) $(CFLAGS-multi-y)
25 CFLAGS-.os+=$(PICFLAG)
26 CFLAGS-.oS+=$(PICFLAG) -DSHARED
43 ifeq ($(HAVE_SHARED),y)
44 CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
46 CRTS=$(top_builddir)lib/$(CRT).o
49 $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
50 $(INSTALL) -d $(dir $@)
51 $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
52 $(STRIPTOOL) -x -R .note -R .comment $@
54 $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
55 $(INSTALL) -d $(dir $@)
56 $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
57 $(STRIPTOOL) -x -R .note -R .comment $@
59 CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
61 ifeq ($(UCLIBC_CTOR_DTOR),y)
62 $(top_builddir)lib/crti.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crti.S
63 $(INSTALL) -d $(dir $@)
64 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
66 $(top_builddir)lib/crtn.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crtn.S
67 $(INSTALL) -d $(dir $@)
68 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
71 $(INSTALL) -d $(top_builddir)lib
76 $(crt-y): $(CRTS) $(CTOR_TARGETS)
79 headers-y: $(headers-y)
81 objclean-y: $(objclean-y)
82 headers_clean-y: $(headers_clean-y)
84 $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
85 $(INSTALL) -d $(dir $@)
86 $(AR) $(ARFLAGS) $@ $^
89 clean: objclean-y headers_clean-y
91 ifeq ($(strip $(LIB_NAME)),)
95 ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),)
96 $(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
99 $(LIB_NAME)-SHARED_OBJS=$($(LIB_NAME)-so-y) $($(LIB_NAME)-shared-y)
100 ifeq ($(HAVE_SHARED),y)
101 shared: $($(LIB_NAME)-SHARED_OBJS)
106 $(LIB_NAME)-ARCHIVE_OBJS=$($(LIB_NAME)-a-y) $($(LIB_NAME)-static-y)
108 objs: shared $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os) $(crt-y) $(other-y)
110 objs: shared $($(LIB_NAME)-ARCHIVE_OBJS) $(crt-y) $(other-y)
113 libc=$(top_builddir)lib/libc.so
114 interp=$(top_builddir)libc/misc/internals/interp.os
115 ifeq ($(strip $(EXTRA_LINK_LIBS)),)
116 #EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
117 EXTRA_LINK_LIBS:=$(interp) $(libc) $(LDADD_LIBFLOAT) $(LIBGCC)
120 ifneq ($(strip $(LIB_NAME)),libc)
121 ifneq ($(strip $(LIB_NAME)),ld-uClibc)
122 $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp) $(libc)
124 $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a
127 $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp)
129 $(INSTALL) -d $(dir $@)
130 $(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
131 $(LD) $(LDFLAGS) $(EXTRA_LINK_OPTS) -soname=$(notdir $@).$(MAJOR_VERSION) \
132 -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) $(SHARED_START_FILES) \
133 --whole-archive $(firstword $^) --no-whole-archive \
134 $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
135 $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
136 ifneq ($(strip $(LIB_NAME)),libc)
137 ifneq ($(strip $(LIB_NAME)),ld-uClibc)
138 $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
141 echo "/* GNU ld script" > $@
142 echo " * Use the shared library, but some functions are only in" >> $@
143 echo " * the static library, so try that secondarily. */" >> $@
144 ifeq ($(UCLIBC_HAS_SSP),y)
145 ifeq ($(COMPAT_ATEXIT),y)
146 echo "GROUP ( $(top_builddir)lib/$(NONSHARED_LIBNAME) $(top_builddir)lib/$(SHARED_MAJORNAME) AS_NEEDED ( $(top_builddir)lib/$(UCLIBC_LDSO) ) )" >> $@
148 echo "GROUP ( $(top_builddir)lib/$(SHARED_MAJORNAME) $(top_builddir)lib/$(NONSHARED_LIBNAME) AS_NEEDED ( $(top_builddir)lib/$(UCLIBC_LDSO) ) )" >> $@
151 ifeq ($(COMPAT_ATEXIT),y)
152 echo "GROUP ( $(top_builddir)lib/$(NONSHARED_LIBNAME) $(top_builddir)lib/$(SHARED_MAJORNAME) )" >> $@
154 echo "GROUP ( $(top_builddir)lib/$(SHARED_MAJORNAME) $(top_builddir)lib/$(NONSHARED_LIBNAME) )" >> $@
159 $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os: $($(LIB_NAME)-multi-y)
162 # local testing only until libc is multi-capable
163 libc_m.os: $(libc-multi-y)
168 $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os $($(LIB_NAME)-nomulti-y:.o=.os) $($(LIB_NAME)-shared-y)
170 ifneq ($(strip $(STRIP_FLAGS)),)
171 $(STRIPTOOL) $(STRIP_FLAGS) $^
173 $(STRIPTOOL) -x -R .note -R .comment $^
175 $(AR) $(ARFLAGS) $@ $^
178 $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os $($(LIB_NAME)-nomulti-y:.o=.os) $($(LIB_NAME)-static-y:.o=.os)
180 $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)-nomulti-y) $($(LIB_NAME)-static-y)
182 $(INSTALL) -d $(dir $@)
184 $(STRIPTOOL) -x -R .note -R .comment $^
185 $(AR) $(ARFLAGS) $@ $^
189 $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)-SHARED_OBJS)
191 ifneq ($(strip $(STRIP_FLAGS)),)
192 $(STRIPTOOL) $(STRIP_FLAGS) $^
194 $(STRIPTOOL) -x -R .note -R .comment $^
196 $(AR) $(ARFLAGS) $@ $^
199 $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os)
201 $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS)
203 $(INSTALL) -d $(dir $@)
205 $(STRIPTOOL) -x -R .note -R .comment $^
206 $(AR) $(ARFLAGS) $@ $^
211 rm -f $($(LIB_NAME)_OUT)/*.{o,os,a}