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