]>
Commit | Line | Data |
---|---|---|
9ef10914 | 1 | # |
56a78630 PM |
2 | # Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details. |
3 | # | |
56a78630 | 4 | |
a80fc77b | 5 | .SUFFIXES: .c .S .o .os .oS .so .a .s .i |
9ef10914 | 6 | |
a80fc77b | 7 | # order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a |
9ef10914 | 8 | ifeq ($(HAVE_SHARED),y) |
768f982c | 9 | .LIBPATTERNS: "lib%.so" |
a80fc77b | 10 | libs: lib-so-y lib-a-y |
9ef10914 | 11 | else |
768f982c | 12 | .LIBPATTERNS: "lib%.a" |
a80fc77b | 13 | libs: lib-a-y |
9ef10914 | 14 | endif |
9ef10914 | 15 | |
237277e9 PM |
16 | lib-a-y: $(lib-a-y) |
17 | lib-so-y: $(lib-so-y) | |
a80fc77b | 18 | |
8c7a3d7c MF |
19 | ifneq ($(findstring s,$(MAKEFLAGS)),) |
20 | DISP := sil | |
21 | Q := @ | |
22 | else | |
23 | ifneq ($(V)$(VERBOSE),) | |
24 | DISP := ver | |
25 | Q := | |
26 | else | |
27 | DISP := pur | |
28 | Q := @ | |
29 | endif | |
30 | endif | |
31 | ||
f3adfd4d MF |
32 | show_objs = $(subst ../,,$@) |
33 | ||
34 | pur_disp_compile.c = echo " "CC $(show_objs) | |
35 | pur_disp_compile.S = echo " "AS $(show_objs) | |
8c7a3d7c | 36 | pur_disp_compile.m = $(pur_disp_compile.c) |
f3adfd4d | 37 | pur_disp_compile-m = echo " "CC-m $(show_objs) |
8c7a3d7c MF |
38 | pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) |
39 | pur_disp_ar = echo " "AR $(ARFLAGS) $@ | |
40 | pur_disp_ld = echo " "LD $($(LIB_NAME)_FULL_NAME) | |
41 | ||
42 | sil_disp_compile.c = true | |
43 | sil_disp_compile.S = true | |
44 | sil_disp_compile.m = true | |
45 | sil_disp_compile-m = true | |
46 | sil_disp_strip = true | |
47 | sil_disp_ar = true | |
48 | sil_disp_ld = true | |
49 | ||
50 | ver_disp_compile.c = echo $(cmd_compile.c) | |
51 | ver_disp_compile.S = echo $(cmd_compile.S) | |
52 | ver_disp_compile.m = echo $(cmd_compile.m) | |
53 | ver_disp_compile-m = echo $(cmd_compile-m) | |
54 | ver_disp_strip = echo $(cmd_strip) | |
55 | ver_disp_ar = echo $(cmd_ar) | |
56 | ver_disp_ld = | |
57 | ||
f3adfd4d MF |
58 | disp_compile.c = $($(DISP)_disp_compile.c) |
59 | disp_compile.S = $($(DISP)_disp_compile.S) | |
60 | disp_compile.m = $($(DISP)_disp_compile.m) | |
61 | disp_compile-m = $($(DISP)_disp_compile-m) | |
62 | disp_strip = $($(DISP)_disp_strip) | |
63 | disp_ar = $($(DISP)_disp_ar) | |
64 | disp_ld = $($(DISP)_disp_ld) | |
65 | ||
8c7a3d7c MF |
66 | cmd_compile.c = $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<)) |
67 | cmd_compile.S = $(cmd_compile.c) $(S_CPPFLAGS) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $@)) $(ASFLAGS-$(notdir $<)) | |
68 | cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) | |
69 | cmd_compile-m = $(CC) $^ -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<)) $(CFLAGS-multi-y) | |
70 | cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^ | |
71 | cmd_ar = $(AR) $(ARFLAGS) $@ $^ | |
72 | ||
f3adfd4d | 73 | compile.c = @$(disp_compile.c) ; $(cmd_compile.c) |
274fdbb0 | 74 | compile.E = $(cmd_compile.c:-c=-E) |
f3adfd4d MF |
75 | compile.S = @$(disp_compile.S) ; $(cmd_compile.S) |
76 | compile.m = @$(disp_compile.m) ; $(cmd_compile.m) | |
77 | compile-m = @$(disp_compile-m) ; $(cmd_compile-m) | |
78 | do_strip = @$(disp_strip) ; $(cmd_strip) | |
79 | do_ar = @$(disp_ar) ; $(cmd_ar) | |
a80fc77b PM |
80 | |
81 | CFLAGS-.os+=$(PICFLAG) | |
237277e9 | 82 | CFLAGS-.oS+=$(PICFLAG) -DSHARED |
a80fc77b | 83 | |
8b9c2bd0 PM |
84 | %.o: %.c |
85 | $(compile.c) | |
8b9c2bd0 | 86 | %.os: %.c |
a80fc77b | 87 | $(compile.c) |
a80fc77b | 88 | %.oS: %.c |
237277e9 | 89 | $(compile.c) |
8b9c2bd0 PM |
90 | %.o: %.S |
91 | $(compile.S) | |
8b9c2bd0 | 92 | %.os: %.S |
a80fc77b | 93 | $(compile.S) |
274fdbb0 MF |
94 | %.o: %.s |
95 | $(compile.S) | |
96 | %.os: %.s | |
97 | $(compile.S) | |
98 | %.E: %.c | |
99 | $(compile.E) | |
100 | %.E: %.S | |
101 | $(compile.E) | |
a80fc77b PM |
102 | |
103 | #ifeq ($(HAVE_ELF),y) | |
104 | CRT=crt1 | |
105 | #else | |
8585cd4d | 106 | #CRT=crt0 |
a80fc77b PM |
107 | #endif |
108 | ||
237277e9 | 109 | ifeq ($(HAVE_SHARED),y) |
a80fc77b | 110 | CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o |
237277e9 PM |
111 | else |
112 | CRTS=$(top_builddir)lib/$(CRT).o | |
113 | endif | |
a80fc77b PM |
114 | |
115 | $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S | |
8c7a3d7c | 116 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b | 117 | $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
f3adfd4d MF |
118 | @$(disp_strip) $(show_objs) |
119 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ | |
a80fc77b PM |
120 | |
121 | $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S | |
8c7a3d7c | 122 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b | 123 | $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
f3adfd4d MF |
124 | @$(disp_strip) $(show_objs) |
125 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ | |
a80fc77b PM |
126 | |
127 | CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o | |
128 | ||
129 | ifeq ($(UCLIBC_CTOR_DTOR),y) | |
130 | $(top_builddir)lib/crti.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crti.S | |
8c7a3d7c | 131 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b PM |
132 | $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS) |
133 | ||
134 | $(top_builddir)lib/crtn.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crtn.S | |
8c7a3d7c | 135 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b PM |
136 | $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS) |
137 | else | |
138 | $(CTOR_TARGETS): | |
8c7a3d7c MF |
139 | $(Q)$(INSTALL) -d $(top_builddir)lib |
140 | $(do_ar) | |
a80fc77b PM |
141 | endif |
142 | ||
237277e9 | 143 | crt-y: $(crt-y) |
a80fc77b PM |
144 | $(crt-y): $(CRTS) $(CTOR_TARGETS) |
145 | ||
237277e9 | 146 | other-y: $(other-y) |
2386d6cd | 147 | headers-y: $(headers-y) |
a80fc77b | 148 | |
237277e9 | 149 | objclean-y: $(objclean-y) |
a80fc77b PM |
150 | headers_clean-y: $(headers_clean-y) |
151 | ||
237277e9 | 152 | $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y) |
8c7a3d7c MF |
153 | $(Q)$(INSTALL) -d $(dir $@) |
154 | $(do_ar) | |
237277e9 PM |
155 | |
156 | .PHONY: dummy create | |
157 | clean: objclean-y headers_clean-y | |
158 | ||
159 | ifeq ($(strip $(LIB_NAME)),) | |
160 | LIB_NAME=libc | |
161 | endif | |
a80fc77b PM |
162 | |
163 | ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),) | |
164 | $(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so | |
165 | endif | |
166 | ||
237277e9 PM |
167 | $(LIB_NAME)-SHARED_OBJS=$($(LIB_NAME)-so-y) $($(LIB_NAME)-shared-y) |
168 | ifeq ($(HAVE_SHARED),y) | |
169 | shared: $($(LIB_NAME)-SHARED_OBJS) | |
a80fc77b | 170 | else |
237277e9 | 171 | shared: |
a80fc77b | 172 | endif |
a80fc77b | 173 | |
237277e9 PM |
174 | $(LIB_NAME)-ARCHIVE_OBJS=$($(LIB_NAME)-a-y) $($(LIB_NAME)-static-y) |
175 | ifeq ($(DOPIC),y) | |
176 | objs: shared $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os) $(crt-y) $(other-y) | |
a80fc77b | 177 | else |
237277e9 | 178 | objs: shared $($(LIB_NAME)-ARCHIVE_OBJS) $(crt-y) $(other-y) |
a80fc77b PM |
179 | endif |
180 | ||
a80fc77b PM |
181 | libc=$(top_builddir)lib/libc.so |
182 | interp=$(top_builddir)libc/misc/internals/interp.os | |
183 | ifeq ($(strip $(EXTRA_LINK_LIBS)),) | |
184 | #EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC) | |
7eb68fa0 | 185 | EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib $(libc) $(LDADD_LIBFLOAT) $(LIBGCC) |
a80fc77b PM |
186 | endif |
187 | ||
188 | ifneq ($(strip $(LIB_NAME)),libc) | |
189 | ifneq ($(strip $(LIB_NAME)),ld-uClibc) | |
190 | $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp) $(libc) | |
191 | else | |
192 | $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a | |
193 | endif | |
194 | else | |
195 | $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp) | |
196 | endif | |
8c7a3d7c MF |
197 | $(Q)$(INSTALL) -d $(dir $@) |
198 | $(Q)$(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) | |
199 | @$(disp_ld) | |
200 | $(Q)$(LD) $(LDFLAGS) $(EXTRA_LINK_OPTS) -soname=$(notdir $@).$(MAJOR_VERSION) \ | |
a80fc77b PM |
201 | -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) $(SHARED_START_FILES) \ |
202 | --whole-archive $(firstword $^) --no-whole-archive \ | |
203 | $(EXTRA_LINK_LIBS) $(SHARED_END_FILES) | |
8c7a3d7c | 204 | $(Q)$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION) |
a80fc77b PM |
205 | ifneq ($(strip $(LIB_NAME)),libc) |
206 | ifneq ($(strip $(LIB_NAME)),ld-uClibc) | |
8c7a3d7c | 207 | $(Q)$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@ |
a80fc77b PM |
208 | endif |
209 | else | |
8c7a3d7c MF |
210 | $(Q)echo "/* GNU ld script" > $@ |
211 | $(Q)echo " * Use the shared library, but some functions are only in" >> $@ | |
212 | $(Q)echo " * the static library, so try that secondarily. */" >> $@ | |
a80fc77b | 213 | ifeq ($(COMPAT_ATEXIT),y) |
8c7a3d7c | 214 | $(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_MAJORNAME) $(ASNEEDED) )" >> $@ |
a80fc77b | 215 | else |
8c7a3d7c | 216 | $(Q)echo "GROUP ( $(SHARED_MAJORNAME) $(NONSHARED_LIBNAME) $(ASNEEDED) )" >> $@ |
a80fc77b | 217 | endif |
237277e9 PM |
218 | endif |
219 | ||
220 | $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os: $($(LIB_NAME)-multi-y) | |
221 | $(compile-m) | |
222 | ||
223 | # local testing only until libc is multi-capable | |
224 | libc_m.os: $(libc-multi-y) | |
225 | $(compile-m) | |
a80fc77b | 226 | |
bddfb866 | 227 | ifneq ($(DOMULTI),n) |
a80fc77b | 228 | |
237277e9 | 229 | $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os $($(LIB_NAME)-nomulti-y:.o=.os) $($(LIB_NAME)-shared-y) |
8c7a3d7c MF |
230 | $(Q)$(RM) $@ |
231 | $(do_strip) | |
232 | $(do_ar) | |
a80fc77b PM |
233 | |
234 | ifeq ($(DOPIC),y) | |
237277e9 | 235 | $(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) |
a80fc77b | 236 | else |
237277e9 | 237 | $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)-nomulti-y) $($(LIB_NAME)-static-y) |
a80fc77b | 238 | endif |
8c7a3d7c MF |
239 | $(Q)$(INSTALL) -d $(dir $@) |
240 | $(Q)$(RM) $@ | |
241 | $(do_strip) | |
242 | $(do_ar) | |
a80fc77b PM |
243 | |
244 | else # DOMULTI | |
245 | ||
237277e9 | 246 | $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)-SHARED_OBJS) |
8c7a3d7c MF |
247 | $(Q)$(RM) $@ |
248 | $(do_strip) | |
249 | $(do_ar) | |
a80fc77b PM |
250 | |
251 | ifeq ($(DOPIC),y) | |
237277e9 | 252 | $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os) |
a80fc77b | 253 | else |
237277e9 | 254 | $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS) |
a80fc77b | 255 | endif |
8c7a3d7c MF |
256 | $(Q)$(INSTALL) -d $(dir $@) |
257 | $(Q)$(RM) $@ | |
258 | $(do_strip) | |
259 | $(do_ar) | |
a80fc77b PM |
260 | |
261 | endif # DOMULTI | |
262 | ||
263 | $(LIB_NAME)_clean: | |
8c7a3d7c | 264 | $(RM) $($(LIB_NAME)_OUT)/*.{o,os,a} |