blob: 577f2d40a8ebb63a9ae52fba03b667a797096e5e [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#
2# Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
3#
4
5.SUFFIXES: .c .S .o .os .oS .so .a .s .i
6
7PHONY := FORCE
8
9.PHONY: dummy $(PHONY) subdirs \
10 all check test $(clean_targets) \
11 config dist menuconfig oldconfig release \
12 utils help
13
14# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
15ifeq ($(HAVE_SHARED),y)
16.LIBPATTERNS: "lib%.so"
17libs: $(lib-so-y) $(lib-a-y)
18$(lib-so-y): | $(interp)
19else
20.LIBPATTERNS: "lib%.a"
21ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
22libs: $(lib-gdb-y)
23endif
24libs: $(lib-a-y)
25$(lib-a-y): | $(top_builddir)lib
26endif
27objs: all_objs
28
29shared_objs = $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) \
30 $(libcrypt-so-y) $(libdl-so-y) \
31 $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) \
32 $(libpthread-so-y) $(libpthread-nonshared-y) $(libthread_db-so-y) \
33 $(libresolv-so-y) $(librt-so-y) \
34 $(ldso-y) \
35 $(libutil-so-y) $(libubacktrace-so-y)
36
37ar_objs = $(libc-y) $(libc-static-y) $(libcrypt-a-y) \
38 $(libdl-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y) \
39 $(libpthread-a-y) $(libthread_db-a-y) \
40 $(libresolv-a-y) $(librt-a-y) $(libutil-a-y) $(libubacktrace-a-y)
41ifeq ($(DOPIC),y)
42ar_objs := $(ar_objs:.o=.os)
43endif
44flat_objs = $(lib-gdb-y)
45
46ifeq ($(HAVE_SHARED),y)
47all_objs: $(sort $(shared_objs) $(ar_objs))
48else
49all_objs: $(ar_objs)
50endif
51$(shared_objs) $(ar_objs): | $(sub_headers)
52
53headers-y: $(headers-y)
54 @true
55
56MAKEFLAGS += --no-print-directory
57SHELL_SET_X := set +x
58define rel_srcdir
59 $(shell $(CONFIG_SHELL) $(top_srcdir)/extra/scripts/relative_path.sh $(@D) .)
60endef
61ifneq ($(findstring s,$(MAKEFLAGS)),)
62export MAKE_IS_SILENT := y
63SECHO := -@false
64DISP := sil
65Q := @
66else
67export MAKE_IS_SILENT := n
68SECHO := @echo
69ifneq ($(V)$(VERBOSE),)
70ifeq ($(V),1)
71DISP := bri# brief, like pur but with defines
72Q := @
73else
74SHELL_SET_X := set -x
75DISP := ver
76Q :=
77endif
78else
79DISP := pur
80Q := @
81endif
82endif
83
84show_objs = $(subst $(top_builddir),,$(subst ../,,$@))
85define show_defs
86 $(filter -D%,$(1))
87endef
88define show_ldflags
89 $(subst $(comma), ,$(subst -Wl$(comma),,$(filter -Wl%,$(1))))
90endef
91
92pur_disp_compile.c = echo " "CC $(show_objs)
93pur_disp_compile.i = echo " "CPP $(show_objs)
94pur_disp_compile.s = echo " "CC-S $(show_objs)
95pur_disp_compile.u = echo " "CC $(show_objs)
96pur_disp_compile.S = echo " "AS $(show_objs)
97pur_disp_compile.m = $(pur_disp_compile.c)
98pur_disp_compile.mi= echo " "CPP-m $(show_objs)
99pur_disp_compile-m = echo " "CC-m $(show_objs)
100pur_disp_hcompile.u= echo " "HOSTCC $(show_objs)
101pur_disp_hcompile.o= echo " "HOSTCC-o $(show_objs)
102pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
103pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@
104pur_disp_ar = echo " "AR $(ARFLAGS) $@
105pur_disp_ld = echo " "LD $(1)
106pur_disp_ln = echo " "LN $(show_objs)
107pur_disp_mkdir = echo " "MKDIR $(show_objs)
108pur_disp_gen = echo " "GEN $(show_objs)
109pur_disp_install = echo " "INSTALL $(1)
110pur_disp_unifdef = echo " "UNIFDEF $(show_objs)
111pur_disp_rm = echo " "CLEAN $(subst CLEAN_,,$(patsubst HEADERCLEAN_%,include \(%\),$@))
112
113sil_disp_compile.c = true
114sil_disp_compile.i = true
115sil_disp_compile.s = true
116sil_disp_compile.u = true
117sil_disp_compile.S = true
118sil_disp_compile.m = true
119sil_disp_compile.mi= true
120sil_disp_compile-m = true
121sil_disp_hcompile.u= true
122sil_disp_hcompile.o= true
123sil_disp_strip = true
124sil_disp_t_strip = true
125sil_disp_ar = true
126sil_disp_ld = true
127sil_disp_ln = true
128sil_disp_mkdir = true
129sil_disp_gen = true
130sil_disp_install = true
131sil_disp_unifdef = true
132sil_disp_rm = true
133
134bri_disp_compile.c = $(pur_disp_compile.c) $(call show_defs,$(cmd_compile.c))
135bri_disp_compile.i = $(pur_disp_compile.i) $(call show_defs,$(cmd_compile.i))
136bri_disp_compile.s = $(pur_disp_compile.s) $(call show_defs,$(cmd_compile.s))
137bri_disp_compile.u = $(pur_disp_compile.u) $(call show_defs,$(cmd_compile.u))
138bri_disp_compile.S = $(pur_disp_compile.S) $(call show_defs,$(cmd_compile.S))
139bri_disp_compile.m = $(pur_disp_compile.m) $(call show_defs,$(cmd_compile.m))
140bri_disp_compile.mi = $(pur_disp_compile.mi) $(call show_defs,$(cmd_compile.mi))
141bri_disp_compile-m = $(pur_disp_compile-m) $(call show_defs,$(cmd_compile-m))
142bri_disp_hcompile.u = $(pur_disp_hcompile.u) $(call show_defs,$(cmd_hcompile.u))
143bri_disp_hcompile.o = $(pur_disp_hcompile.o) $(call show_defs,$(cmd_hcompile.o))
144bri_disp_strip = $(pur_disp_strip)
145bri_disp_t_strip = $(pur_disp_t_strip)
146bri_disp_ar = $(pur_disp_ar)
147bri_disp_ld = $(pur_disp_ld) $(call show_ldflags,$(cmd_ld))
148bri_disp_ln = $(pur_disp_ln)
149bri_disp_mkdir = $(pur_disp_mkdir)
150bri_disp_gen = $(pur_disp_gen)
151bri_disp_install = $(pur_disp_install)
152bri_disp_unifdef = $(pur_disp_unifdef)
153bri_disp_rm = $(pur_disp_rm)
154
155esc=$(subst ','\'',$(1))
156# ')
157ver_disp_compile.c = echo '$(call esc,$(cmd_compile.c))'
158ver_disp_compile.i = echo '$(call esc,$(cmd_compile.i))'
159ver_disp_compile.s = echo '$(call esc,$(cmd_compile.s))'
160ver_disp_compile.u = echo '$(call esc,$(cmd_compile.u))'
161ver_disp_compile.S = echo '$(call esc,$(cmd_compile.S))'
162ver_disp_compile.m = echo '$(call esc,$(cmd_compile.m))'
163ver_disp_compile.mi= echo '$(call esc,$(cmd_compile.mi))'
164ver_disp_compile-m = echo '$(call esc,$(cmd_compile-m))'
165ver_disp_hcompile.u= echo '$(call esc,$(cmd_hcompile.u))'
166ver_disp_hcompile.o= echo '$(call esc,$(cmd_hcompile.o))'
167ver_disp_strip = echo '$(call esc,$(cmd_strip))'
168ver_disp_t_strip = echo '$(call esc,$(cmd_t_strip))'
169ver_disp_ar = echo '$(call esc,$(cmd_ar))'
170ver_disp_ld =
171ver_disp_ln =
172ver_disp_mkdir =
173ver_disp_gen =
174ver_disp_install =
175ver_disp_unifdef = echo '$(call esc,$(cmd_unifdef))'
176ver_disp_rm =
177
178disp_compile.c = $($(DISP)_disp_compile.c)
179disp_compile.i = $($(DISP)_disp_compile.i)
180disp_compile.s = $($(DISP)_disp_compile.s)
181disp_compile.u = $($(DISP)_disp_compile.u)
182disp_compile.S = $($(DISP)_disp_compile.S)
183disp_compile.m = $($(DISP)_disp_compile.m)
184disp_compile.mi= $($(DISP)_disp_compile.mi)
185disp_compile-m = $($(DISP)_disp_compile-m)
186disp_hcompile.u= $($(DISP)_disp_hcompile.u)
187disp_hcompile.o= $($(DISP)_disp_hcompile.o)
188disp_strip = $($(DISP)_disp_strip)
189disp_t_strip = $($(DISP)_disp_t_strip)
190disp_ar = $($(DISP)_disp_ar)
191disp_ld = $($(DISP)_disp_ld)
192disp_ln = $($(DISP)_disp_ln)
193disp_mkdir = $($(DISP)_disp_mkdir)
194disp_gen = $($(DISP)_disp_gen)
195disp_install = $($(DISP)_disp_install)
196disp_unifdef = $($(DISP)_disp_unifdef)
197disp_rm = $($(DISP)_disp_rm)
198
199any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
200
201# ../foo/bar/baz.ext -> foo_bar_baz.ext
202variablify = $(subst /,_,$(subst $(top_builddir),,$(1)))
203# strip the top_builddir off everything to make the *string* idempotent for -C
204dirify = $(subst $(top_builddir),,$(patsubst -L$(top_builddir)%,-L%,$(patsubst -I$(top_builddir)%,-I%,$(1))))
205
206# True if not identical. Neither order nor whitespace nor identical flags
207# matter.
208compare_flags = \
209 $(strip $(filter-out $(call dirify,$(cmd_$(call variablify,$(1)))), \
210 $(call dirify,$(cmd_$(call variablify,$(@))))) \
211 $(filter-out $(call dirify,$(cmd_$(call variablify,$(@)))), \
212 $(call dirify,$(cmd_$(call variablify,$(1))))))
213
214# Rebuild if any prerequisite, the used CC or flags changed.
215# Previously used flags are stored in the corresponding .%.dep files
216maybe_exec = \
217 $(if $(strip $(compare_flags) $(any-prereq)), \
218 @set -e; \
219 $(disp_$(1)); \
220 $(cmd_$(1)); \
221 echo 'cmd_$(call variablify,$@) := $(call dirify,$(cmd_$(call variablify,$1)))' >> $(dir $@).$(notdir $@).dep)
222
223# collect flags of domulti prereqs
224#collect_multi_flags = $(CFLAGS-$(notdir $(d))) $(CFLAGS-$(notdir $(patsubst %/,%,$(dir $(d)))))
225collect_multi_flags = $(CFLAGS-$(notdir $(patsubst %/,%,$(dir $(d)))))
226
227CFLAGS_gen.dep = -MT $@ -MD -MP -MF $(dir $@).$(notdir $@).dep
228
229cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) -mthumb \
230 $(CFLAGS-$(suffix $@)) \
231 $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))) \
232 $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
233 $(CFLAGS-$(notdir $<)) \
234 $(CFLAGS-$(notdir $@)) \
235 $(CFLAGS_gen.dep)
236cmd_compile.i = $(cmd_compile.c:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS)
237cmd_compile.s = $(cmd_compile.c:-c=-S)
238cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep)
239cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ -marm $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
240cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
241cmd_compile.mi= $(cmd_compile.m:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS)
242
243cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(sort $(foreach d,$(^:$(top_srcdir)=),$(collect_multi_flags)))
244cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
245cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
246cmd_ar = $(AR) $(ARFLAGS) $@ $^
247
248define do_ln
249 @$(disp_ln)
250 $(Q)$(LN) -fs
251endef
252
253define do_mkdir
254 @$(disp_mkdir)
255 $(Q)$(INSTALL) -d $@
256endef
257
258define do_rm
259 @$(disp_rm)
260 $(Q)$(RM)
261endef
262
263define do_awk
264 @$(disp_gen)
265 $(Q)$(AWK) -f
266endef
267
268define do_sed
269 @$(disp_gen)
270 $(Q)$(SED)
271endef
272
273compile.c = @$(call maybe_exec,compile.c)
274compile.i = $(call maybe_exec,compile.i)
275compile.s = $(call maybe_exec,compile.s)
276compile.S = @$(call maybe_exec,compile.S)
277compile.m = @$(call maybe_exec,compile.m)
278compile.mi= $(call maybe_exec,compile.mi)
279compile-m = @$(disp_compile-m) ; $(cmd_compile-m) && $(cmd_t_strip)
280do_strip = @$(disp_strip) ; $(cmd_strip)
281do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
282do_unifdef= @$(disp_unifdef) ; $(cmd_unifdef)
283hcompile.u= @$(disp_hcompile.u); $(cmd_hcompile.u)
284hcompile.o= @$(disp_hcompile.o); $(cmd_hcompile.o)
285
286define do_ar
287 @$(disp_ar) ; $(cmd_ar)
288 @$(do_t_strip)
289endef
290define compile.u
291 @$(disp_compile.u) ; $(cmd_compile.u)
292 @$(disp_t_strip)
293endef
294cmd_hcompile.u = $(HOSTCC) $(filter-out $(PHONY),$^) $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
295cmd_hcompile.o = $(HOSTCC) $(filter-out $(PHONY),$<) $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
296
297define create-lds
298 $(Q)$(RM) $@.lds
299 $(Q)$(CC) -nostdlib -nostartfiles -shared -Wl,-z,combreloc \
300 -Wl,-z,relro -Wl,--hash-style=gnu -Wl,-z,defs \
301 -Wl,--verbose 2>&1 | LC_ALL=C \
302 sed -e '/^=========/,/^=========/!d;/^=========/d' \
303 -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' > $@.lds
304endef
305
306define link.so
307 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
308 @$(disp_ld)
309 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(LDFLAGS-y-$(@F)) \
310 -Wl,-soname=$(notdir $@).$(2) \
311 $(CFLAG_-nostdlib) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
312 -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
313 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
314 $(Q)$(LN) -sf $(1) $@.$(2)
315 $(Q)$(LN) -sf $(1) $@
316endef
317
318# CRT files needed by link-flat.so
319LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
320 $(top_builddir)lib/crtn.o
321
322# Create a shared flat library from the archive named by the first dependency.
323# $@ names the shared library's .gdb file, not the flat file itself.
324# (This is because the .gdb suffix makes the ELF file more distinctive
325# than the suffixless flat file.)
326#
327# Argument 1 is the shared library file -- i.e. $(@:.gdb=) -- and argument 2
328# is the shared library identifier. If it wasn't for $(disp_ld), we could
329# avoid passing $(@:.gdb=) as an argument and use $(@:.gdb=) instead of $(1).
330#
331# This is so far only used for libc, for which we want to link the entire
332# libgcc into the shared object.
333define link-flat.so
334 $(Q)$(RM) $(1) $@
335 @$(disp_ld)
336 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(CFLAG_-nostdlib) -o $(1) \
337 -Wl,-elf2flt -Wl,-shared-lib-id,$(2) $(top_builddir)lib/Scrt1.o \
338 $(top_builddir)/lib/crti.o -Wl,--whole-archive $(firstword $^) \
339 $(LIBGCC) -Wl,--no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
340 $(top_builddir)/lib/crtn.o
341endef
342
343define linkm.so
344 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
345 $(do_strip)
346 @$(disp_ld)
347 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
348 $(CFLAG_-nostdlib) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
349 $^ \
350 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
351 $(Q)$(LN) -sf $(1) $@.$(2)
352 $(Q)$(LN) -sf $(1) $@
353endef
354
355CFLAGS-.os+=$(PICFLAG)
356CFLAGS-.oS+=$(PICFLAG) -DSHARED
357
358$(top_builddir)%.o: $(top_srcdir)%.c FORCE ; $(compile.c)
359$(top_builddir)%.os: $(top_srcdir)%.c FORCE | pregen; $(compile.c)
360$(top_builddir)%.oS: $(top_srcdir)%.c FORCE | pregen; $(compile.c)
361$(top_builddir)%.o: $(top_srcdir)%.S FORCE ; $(compile.S)
362$(top_builddir)%.os: $(top_srcdir)%.S FORCE | pregen; $(compile.S)
363$(top_builddir)%.oS: $(top_srcdir)%.S FORCE | pregen; $(compile.S)
364$(top_builddir)%.o: $(top_srcdir)%.s FORCE ; $(compile.S)
365$(top_builddir)%.os: $(top_srcdir)%.s FORCE ; $(compile.S)
366$(top_builddir)%.oS: $(top_srcdir)%.s FORCE | pregen; $(compile.S)
367$(top_builddir)%.i: $(top_srcdir)%.c FORCE | pregen; $(compile.i)
368$(top_builddir)%.i: $(top_srcdir)%.S FORCE | pregen; $(compile.i)
369$(top_builddir)%.s: $(top_srcdir)%.c FORCE | pregen; $(compile.s)
370$(top_builddir)%.s: $(top_srcdir)%.S FORCE | pregen; $(compile.s)
371$(top_builddir)%.dep:
372
373$(top_builddir)lib/interp.c: | $(top_builddir)lib
374 $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@.tmp
375 $(Q)echo "#include <features.h>" >> $@.tmp
376ifeq ($(HARDWIRED_ABSPATH),y)
377 $(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
378 "(\".interp\"))) =\""$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO)"\";" >> $@.tmp
379 $(Q)$(SED) -i -e 's://:/:g' $@.tmp
380else
381 $(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
382 "(\".interp\"))) =\""$(UCLIBC_LDSO)"\";" >> $@.tmp
383endif
384 $(Q)mv $@.tmp $@
385
386$(interp): $(top_builddir)lib/interp.c | $(sub_headers)
387 $(compile.c)
388 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
389
390$(ldso):
391 $(Q)cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(ABI_VERSION),%,$(notdir $@))
392$(libc):
393 $(Q)cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(ABI_VERSION),%,$(notdir $@))
394
395CRT := crt1
396
397ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
398CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
399else
400CRTS=$(top_builddir)lib/$(CRT).o
401endif
402
403ASFLAGS-$(CRT).o := -DL_$(CRT)
404ASFLAGS-S$(CRT).o := $(PIEFLAG) -DL_S$(CRT)
405$(CRTS): $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
406 $(compile.S)
407 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
408
409ifeq ($(UCLIBC_CTOR_DTOR),y)
410CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
411else
412CTOR_TARGETS:=
413endif
414
415ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
416CRTRELOC=$(top_builddir)lib/crtreloc.o
417$(CRTRELOC): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.c
418 $(compile.c)
419endif
420
421ifneq ($(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c),)
422CFLAGS-initfini.s := -S -g0 $(PICFLAG) -fno-inline-functions -finhibit-size-directive
423$(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c | $(top_builddir)lib
424 $(compile.c)
425
426$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s | $(top_builddir)lib
427 $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
428 gawk -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
429 $(Q)mv $@.tmp $@
430
431$(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h
432 $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
433 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
434 -e '/@TRAILER_BEGINS/,$$p' $< > $@
435
436$(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s
437 $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
438 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
439 -e '/@TRAILER_BEGINS/,$$p' $< > $@
440
441$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_builddir)lib/%.S
442 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
443else
444$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
445 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
446endif
447
448#ifeq ($(TARGET_ARCH),nios)
449#CRTS_COMPAT := $(top_builddir)lib/crt0.o
450#$(CRTS_COMPAT):
451# ln -fs crt1.o $(top_builddir)lib/crt0.o
452#else
453CRTS_COMPAT :=
454#endif
455
456startfiles = $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC)
457$(crt-y): $(startfiles)
458$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | headers
459$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) $(LINK_FLAT_CRTS) $(SHARED_START_FILES) $(SHARED_END_FILES) : | $(top_builddir)lib
460
461$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
462 $(Q)$(RM) $@
463 $(do_ar)
464
465$(top_builddir)lib/libpthread_nonshared.a: $(libpthread-nonshared-y)
466 $(Q)$(RM) $@
467 $(do_ar)
468
469files.dep := $(libc-a-y) $(libc-so-y) $(libc-nonshared-y) \
470 $(libm-a-y) $(libm-so-y) \
471 $(libpthread-a-y) $(libpthread-so-y) $(libpthread-nonshared-y) \
472 $(libthread_db-a-y) $(libthread_db-so-y) $(libpthread-generated-y) \
473 $(librt-a-y) $(librt-so-y) $(libresolv-a-y) $(libresolv-so-y) \
474 $(libcrypt-a-y) $(libcrypt-so-y) $(libutil-a-y) $(libutil-so-y) \
475 $(libnsl-a-y) $(libnsl-so-y) $(ldso-y) $(libdl-a-y) $(libdl-so-y) \
476 $(libubacktrace-a-y) $(libubacktrace-so-y)
477.depends.dep := \
478 $(patsubst %.s,%.s.dep,$(filter %.s,$(files.dep))) \
479 $(patsubst %.o,%.o.dep,$(filter %.o,$(files.dep))) \
480 $(patsubst %.os,%.os.dep,$(filter %.os,$(files.dep))) \
481 $(patsubst %.oS,%.oS.dep,$(filter %.oS,$(files.dep)))
482# Oh, and prepend a dot to the basename so i don't have to change my habit of
483# calling 'size thefile.o*'
484.depends.dep := $(foreach f,$(.depends.dep),$(dir $(f)).$(notdir $(f)))
485.depends.dep := $(wildcard $(.depends.dep))
486
487FORCE:
488
489clean: objclean-y headers_clean-y
490realclean: clean menuconfig-clean-y
491 $(Q)$(RM) $(.depends.dep)
492
493objclean-y: $(objclean-y)
494headers_clean-y: $(headers_clean-y)
495
496ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
497ifneq ($(strip $(.depends.dep)),)
498.NOEXPORT:
499-include $(.depends.dep)
500endif
501endif
502
503# vi: ft=make :