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 .E
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)
11 $(lib-so-y): $(interp)
13 .LIBPATTERNS: "lib%.a"
18 shared_objs = $(ldso-y) $(libc-so-y) $(libc-nonshared-y) $(libdl-so-y)
19 shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y)
20 shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
21 ar_objs = $(libc-a-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
22 ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
24 ar_objs := $(ar_objs:.o=.os)
27 ifeq ($(HAVE_SHARED),y)
28 all_objs: $(sort $(shared_objs) $(ar_objs))
33 headers-y: $(headers-y)
35 ifneq ($(findstring s,$(MAKEFLAGS)),)
39 ifneq ($(V)$(VERBOSE),)
48 show_objs = $(subst ../,,$@)
50 pur_disp_compile.c = echo " "CC $(show_objs)
51 pur_disp_compile.S = echo " "AS $(show_objs)
52 pur_disp_compile.m = $(pur_disp_compile.c)
53 pur_disp_compile-m = echo " "CC-m $(show_objs)
54 pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
55 pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@
56 pur_disp_ar = echo " "AR $(ARFLAGS) $@
57 pur_disp_ld = echo " "LD $(1)
59 sil_disp_compile.c = true
60 sil_disp_compile.S = true
61 sil_disp_compile.m = true
62 sil_disp_compile-m = true
64 sil_disp_t_strip = true
68 ver_disp_compile.c = echo $(cmd_compile.c)
69 ver_disp_compile.S = echo $(cmd_compile.S)
70 ver_disp_compile.m = echo $(cmd_compile.m)
71 ver_disp_compile-m = echo $(cmd_compile-m)
72 ver_disp_strip = echo $(cmd_strip)
73 ver_disp_t_strip = echo $(cmd_t_strip)
74 ver_disp_ar = echo $(cmd_ar)
77 disp_compile.c = $($(DISP)_disp_compile.c)
78 disp_compile.S = $($(DISP)_disp_compile.S)
79 disp_compile.m = $($(DISP)_disp_compile.m)
80 disp_compile-m = $($(DISP)_disp_compile-m)
81 disp_strip = $($(DISP)_disp_strip)
82 disp_t_strip = $($(DISP)_disp_t_strip)
83 disp_ar = $($(DISP)_disp_ar)
84 disp_ld = $($(DISP)_disp_ld)
86 cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
87 cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
88 cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
89 cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
90 #cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
91 cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
92 cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
93 cmd_ar = $(AR) $(ARFLAGS) $@ $^
95 compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
96 compile.E = $(cmd_compile.c:-c=-E)
97 compile.s = $(cmd_compile.c:-c=-S)
98 compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
99 compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
100 compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
101 do_strip = @$(disp_strip) ; $(cmd_strip)
102 do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
103 do_ar = @$(disp_ar) ; $(cmd_ar)
107 $(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
109 $(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@
111 hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
112 hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
115 $(Q)$(INSTALL) -d $(dir $@)
116 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
118 $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
119 -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
120 --whole-archive $(firstword $^) --no-whole-archive \
121 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
122 $(Q)$(LN) -sf $(1) $@.$(2)
123 $(Q)$(LN) -sf $(1) $@
127 $(Q)$(INSTALL) -d $(dir $@)
128 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
130 $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
131 -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $(firstword $^) \
132 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
133 $(Q)$(LN) -sf $(1) $@.$(2)
134 $(Q)$(LN) -sf $(1) $@
137 CFLAGS-.os+=$(PICFLAG)
138 CFLAGS-.oS+=$(PICFLAG) -DSHARED
140 %.o: %.c ; $(compile.c)
141 %.os: %.c ; $(compile.c)
142 %.oS: %.c ; $(compile.c)
143 %.o: %.S ; $(compile.S)
144 %.os: %.S ; $(compile.S)
145 %.oS: %.S ; $(compile.S)
146 %.o: %.s ; $(compile.S)
147 %.os: %.s ; $(compile.S)
148 %.oS: %.s ; $(compile.S)
149 %.E: %.c ; $(compile.E)
150 %.E: %.S ; $(compile.E)
151 %.s: %.c ; $(compile.s)
152 %.s: %.S ; $(compile.s)
154 $(top_builddir)lib/interp.c:
155 $(Q)$(INSTALL) -d $(dir $@)
156 $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
157 $(Q)echo "#include <features.h>" >> $@
158 $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
159 "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
161 $(interp): $(top_builddir)lib/interp.c
163 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
166 @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
169 @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
172 @cd $(top_builddir); $(MAKE) headers
176 ifeq ($(HAVE_SHARED),y)
177 CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
179 CRTS=$(top_builddir)lib/$(CRT).o
182 $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
183 $(Q)$(INSTALL) -d $(dir $@)
184 $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
185 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
187 $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
188 $(Q)$(INSTALL) -d $(dir $@)
189 $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
190 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
192 CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
194 ifeq ($(UCLIBC_CTOR_DTOR),y)
195 $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
196 $(Q)$(INSTALL) -d $(dir $@)
197 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
200 $(Q)$(INSTALL) -d $(dir $@)
204 #ifeq ($(TARGET_ARCH),nios)
205 #CRTS_COMPAT := $(top_builddir)lib/crt0.o
207 # ln -fs crt1.o $(top_builddir)lib/crt0.o
212 $(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT)
214 $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
215 $(Q)$(INSTALL) -d $(dir $@)
219 clean: objclean-y headers_clean-y
221 objclean-y: $(objclean-y)
222 headers_clean-y: $(headers_clean-y)
225 all check clean distclean test \
226 config dist menuconfig oldconfig release \