]>
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 | |
3830b27a | 5 | .SUFFIXES: .c .S .o .os .oS .so .a .s .i .E |
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" |
b20ee706 | 10 | libs: $(lib-so-y) $(lib-a-y) |
5ffab643 | 11 | $(lib-so-y): $(interp) |
9ef10914 | 12 | else |
768f982c | 13 | .LIBPATTERNS: "lib%.a" |
b20ee706 | 14 | libs: $(lib-a-y) |
9ef10914 | 15 | endif |
ec80cbc1 | 16 | objs: all_objs |
9ef10914 | 17 | |
eaf180ee | 18 | shared_objs = $(ldso-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) $(libdl-so-y) |
72c0f6a2 | 19 | shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y) |
78563c79 | 20 | shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y) |
eaf180ee | 21 | ar_objs = $(libc-y) $(libc-static-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y) |
78563c79 | 22 | ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y) |
ec80cbc1 PM |
23 | ifeq ($(DOPIC),y) |
24 | ar_objs := $(ar_objs:.o=.os) | |
25 | endif | |
26 | ||
27 | ifeq ($(HAVE_SHARED),y) | |
28 | all_objs: $(sort $(shared_objs) $(ar_objs)) | |
29 | else | |
30 | all_objs: $(ar_objs) | |
31 | endif | |
94c41e72 | 32 | $(shared_objs) $(ar_objs): | $(sub_headers) |
0a7b9d5d PM |
33 | |
34 | headers-y: $(headers-y) | |
b5db14a3 | 35 | @true |
a80fc77b | 36 | |
9bf5af92 | 37 | MAKEFLAGS += --no-print-directory |
b5db14a3 | 38 | SHELL_SET_X := set +x |
8c7a3d7c | 39 | ifneq ($(findstring s,$(MAKEFLAGS)),) |
b5db14a3 MF |
40 | export MAKE_IS_SILENT := y |
41 | SECHO := -@false | |
8c7a3d7c MF |
42 | DISP := sil |
43 | Q := @ | |
44 | else | |
b5db14a3 MF |
45 | export MAKE_IS_SILENT := n |
46 | SECHO := @echo | |
8c7a3d7c | 47 | ifneq ($(V)$(VERBOSE),) |
b5db14a3 | 48 | SHELL_SET_X := set -x |
8c7a3d7c MF |
49 | DISP := ver |
50 | Q := | |
51 | else | |
52 | DISP := pur | |
53 | Q := @ | |
54 | endif | |
55 | endif | |
56 | ||
f3adfd4d MF |
57 | show_objs = $(subst ../,,$@) |
58 | ||
59 | pur_disp_compile.c = echo " "CC $(show_objs) | |
60 | pur_disp_compile.S = echo " "AS $(show_objs) | |
8c7a3d7c | 61 | pur_disp_compile.m = $(pur_disp_compile.c) |
f3adfd4d | 62 | pur_disp_compile-m = echo " "CC-m $(show_objs) |
ad93127a | 63 | pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@ |
686016a7 | 64 | pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@ |
8c7a3d7c | 65 | pur_disp_ar = echo " "AR $(ARFLAGS) $@ |
0a7b9d5d | 66 | pur_disp_ld = echo " "LD $(1) |
8c7a3d7c MF |
67 | |
68 | sil_disp_compile.c = true | |
69 | sil_disp_compile.S = true | |
70 | sil_disp_compile.m = true | |
71 | sil_disp_compile-m = true | |
72 | sil_disp_strip = true | |
686016a7 | 73 | sil_disp_t_strip = true |
8c7a3d7c MF |
74 | sil_disp_ar = true |
75 | sil_disp_ld = true | |
76 | ||
77 | ver_disp_compile.c = echo $(cmd_compile.c) | |
78 | ver_disp_compile.S = echo $(cmd_compile.S) | |
79 | ver_disp_compile.m = echo $(cmd_compile.m) | |
80 | ver_disp_compile-m = echo $(cmd_compile-m) | |
81 | ver_disp_strip = echo $(cmd_strip) | |
686016a7 | 82 | ver_disp_t_strip = echo $(cmd_t_strip) |
8c7a3d7c MF |
83 | ver_disp_ar = echo $(cmd_ar) |
84 | ver_disp_ld = | |
85 | ||
f3adfd4d MF |
86 | disp_compile.c = $($(DISP)_disp_compile.c) |
87 | disp_compile.S = $($(DISP)_disp_compile.S) | |
88 | disp_compile.m = $($(DISP)_disp_compile.m) | |
89 | disp_compile-m = $($(DISP)_disp_compile-m) | |
90 | disp_strip = $($(DISP)_disp_strip) | |
686016a7 | 91 | disp_t_strip = $($(DISP)_disp_t_strip) |
f3adfd4d MF |
92 | disp_ar = $($(DISP)_disp_ar) |
93 | disp_ld = $($(DISP)_disp_ld) | |
94 | ||
6cc179a4 | 95 | cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(^D)))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@)) |
6af91aa0 | 96 | cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@)) |
8c7a3d7c | 97 | cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
cd84f06d | 98 | cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) |
8c7a3d7c | 99 | cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^ |
cd84f06d | 100 | cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@ |
8c7a3d7c MF |
101 | cmd_ar = $(AR) $(ARFLAGS) $@ $^ |
102 | ||
f3adfd4d | 103 | compile.c = @$(disp_compile.c) ; $(cmd_compile.c) |
274fdbb0 | 104 | compile.E = $(cmd_compile.c:-c=-E) |
575f2cfb | 105 | compile.s = $(cmd_compile.c:-c=-S) |
f3adfd4d MF |
106 | compile.S = @$(disp_compile.S) ; $(cmd_compile.S) |
107 | compile.m = @$(disp_compile.m) ; $(cmd_compile.m) | |
108 | compile-m = @$(disp_compile-m) ; $(cmd_compile-m) | |
109 | do_strip = @$(disp_strip) ; $(cmd_strip) | |
686016a7 | 110 | do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip) |
f3adfd4d | 111 | do_ar = @$(disp_ar) ; $(cmd_ar) |
a80fc77b | 112 | |
3321ce75 MF |
113 | define compile.u |
114 | @$(disp_compile.c) | |
115 | $(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) | |
116 | @$(disp_strip) | |
117 | $(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@ | |
118 | endef | |
119 | hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) | |
120 | hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) | |
121 | ||
76d780f4 PM |
122 | define link.so |
123 | $(Q)$(INSTALL) -d $(dir $@) | |
124 | $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1) | |
125 | @$(disp_ld) | |
126 | $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \ | |
127 | -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \ | |
128 | --whole-archive $(firstword $^) --no-whole-archive \ | |
129 | $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@)) | |
130 | $(Q)$(LN) -sf $(1) $@.$(2) | |
131 | $(Q)$(LN) -sf $(1) $@ | |
132 | endef | |
133 | ||
8e8e47fc PM |
134 | define linkm.so |
135 | $(Q)$(INSTALL) -d $(dir $@) | |
136 | $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1) | |
137 | @$(disp_ld) | |
138 | $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \ | |
a29eb4f2 | 139 | -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $^ \ |
8e8e47fc PM |
140 | $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@)) |
141 | $(Q)$(LN) -sf $(1) $@.$(2) | |
142 | $(Q)$(LN) -sf $(1) $@ | |
143 | endef | |
144 | ||
a80fc77b | 145 | CFLAGS-.os+=$(PICFLAG) |
237277e9 | 146 | CFLAGS-.oS+=$(PICFLAG) -DSHARED |
a80fc77b | 147 | |
5396647d MF |
148 | %.o: %.c ; $(compile.c) |
149 | %.os: %.c ; $(compile.c) | |
150 | %.oS: %.c ; $(compile.c) | |
151 | %.o: %.S ; $(compile.S) | |
152 | %.os: %.S ; $(compile.S) | |
c0087777 | 153 | %.oS: %.S ; $(compile.S) |
5396647d MF |
154 | %.o: %.s ; $(compile.S) |
155 | %.os: %.s ; $(compile.S) | |
c0087777 | 156 | %.oS: %.s ; $(compile.S) |
5396647d MF |
157 | %.E: %.c ; $(compile.E) |
158 | %.E: %.S ; $(compile.E) | |
acc9d401 MF |
159 | %.i: %.c ; $(compile.E) |
160 | %.i: %.S ; $(compile.E) | |
575f2cfb MF |
161 | %.s: %.c ; $(compile.s) |
162 | %.s: %.S ; $(compile.s) | |
a80fc77b | 163 | |
94c41e72 | 164 | $(top_builddir)lib/interp.c: | $(sub_headers) |
72c0f6a2 PM |
165 | $(Q)$(INSTALL) -d $(dir $@) |
166 | $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@ | |
167 | $(Q)echo "#include <features.h>" >> $@ | |
72c0f6a2 PM |
168 | $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \ |
169 | "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@ | |
72c0f6a2 PM |
170 | |
171 | $(interp): $(top_builddir)lib/interp.c | |
172 | $(compile.c) | |
72c0f6a2 PM |
173 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ |
174 | ||
175 | $(ldso): | |
7ca2d776 | 176 | @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@)) |
72c0f6a2 | 177 | |
cf5e4b82 | 178 | $(libc): |
7ca2d776 | 179 | @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@)) |
cf5e4b82 | 180 | |
3c45ffd2 | 181 | $(headers_dep): |
94c41e72 | 182 | $(Q)cd $(top_builddir); $(MAKE) headers |
3c45ffd2 | 183 | |
28f1d458 | 184 | CRT := crt1 |
a80fc77b | 185 | |
237277e9 | 186 | ifeq ($(HAVE_SHARED),y) |
a80fc77b | 187 | CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o |
237277e9 PM |
188 | else |
189 | CRTS=$(top_builddir)lib/$(CRT).o | |
190 | endif | |
a80fc77b | 191 | |
28f1d458 MF |
192 | ASFLAGS-$(CRT).o := -DL_$(CRT) |
193 | ASFLAGS-S$(CRT).o := $(PIEFLAG) -DL_S$(CRT) | |
194 | $(CRTS): $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S | |
8c7a3d7c | 195 | $(Q)$(INSTALL) -d $(dir $@) |
28f1d458 | 196 | $(compile.S) |
f3adfd4d | 197 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ |
a80fc77b | 198 | |
fe774e4e | 199 | ifeq ($(UCLIBC_CTOR_DTOR),y) |
a80fc77b | 200 | CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o |
fe774e4e MF |
201 | else |
202 | CTOR_TARGETS:= | |
203 | endif | |
a80fc77b | 204 | |
fe774e4e MF |
205 | ifneq ($(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c),) |
206 | $(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c | |
207 | $(compile.c) -S -finhibit-size-directive | |
208 | ||
209 | $(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s | |
210 | $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \ | |
211 | gawk -f $(top_srcdir)extra/scripts/defs.awk > [email protected] | |
212 | $(Q)mv [email protected] $@ | |
213 | ||
214 | $(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h | |
215 | $(Q)sed -n -e '1,/@HEADER_ENDS/p' \ | |
216 | -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \ | |
217 | -e '/@TRAILER_BEGINS/,$$p' $< > $@ | |
218 | ||
219 | $(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s | |
220 | $(Q)sed -n -e '1,/@HEADER_ENDS/p' \ | |
221 | -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \ | |
222 | -e '/@TRAILER_BEGINS/,$$p' $< > $@ | |
223 | ||
224 | $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_builddir)lib/%.S | |
8c7a3d7c | 225 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b PM |
226 | $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS) |
227 | else | |
fe774e4e | 228 | $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S |
72c0f6a2 | 229 | $(Q)$(INSTALL) -d $(dir $@) |
fe774e4e | 230 | $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS) |
a80fc77b PM |
231 | endif |
232 | ||
0ee2f561 MF |
233 | #ifeq ($(TARGET_ARCH),nios) |
234 | #CRTS_COMPAT := $(top_builddir)lib/crt0.o | |
235 | #$(CRTS_COMPAT): | |
236 | # ln -fs crt1.o $(top_builddir)lib/crt0.o | |
237 | #else | |
d0bd553f | 238 | CRTS_COMPAT := |
0ee2f561 | 239 | #endif |
b9b124c1 MF |
240 | |
241 | $(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) | |
fec64b1a | 242 | $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT): | headers |
a80fc77b | 243 | |
237277e9 | 244 | $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y) |
8c7a3d7c MF |
245 | $(Q)$(INSTALL) -d $(dir $@) |
246 | $(do_ar) | |
237277e9 PM |
247 | |
248 | .PHONY: dummy create | |
249 | clean: objclean-y headers_clean-y | |
250 | ||
0a7b9d5d PM |
251 | objclean-y: $(objclean-y) |
252 | headers_clean-y: $(headers_clean-y) | |
ad93127a MF |
253 | |
254 | .PHONY: \ | |
255 | all check clean distclean test \ | |
256 | config dist menuconfig oldconfig release \ | |
257 | subdirs utils |