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