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
|
#
# 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 .E
# 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"
libs: $(lib-a-y)
endif
objs: all_objs
shared_objs = $(ldso-y) $(libc-so-y) $(libc-nonshared-y) $(libdl-so-y)
shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y)
shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
ar_objs = $(libc-a-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
ifeq ($(DOPIC),y)
ar_objs := $(ar_objs:.o=.os)
endif
ifeq ($(HAVE_SHARED),y)
all_objs: $(sort $(shared_objs) $(ar_objs))
else
all_objs: $(ar_objs)
endif
headers-y: $(headers-y)
ifneq ($(findstring s,$(MAKEFLAGS)),)
DISP := sil
Q := @
else
ifneq ($(V)$(VERBOSE),)
DISP := ver
Q :=
else
DISP := pur
Q := @
endif
endif
show_objs = $(subst ../,,$@)
pur_disp_compile.c = echo " "CC $(show_objs)
pur_disp_compile.S = echo " "AS $(show_objs)
pur_disp_compile.m = $(pur_disp_compile.c)
pur_disp_compile-m = echo " "CC-m $(show_objs)
pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
pur_disp_ar = echo " "AR $(ARFLAGS) $@
pur_disp_ld = echo " "LD $(1)
sil_disp_compile.c = true
sil_disp_compile.S = true
sil_disp_compile.m = true
sil_disp_compile-m = true
sil_disp_strip = true
sil_disp_ar = true
sil_disp_ld = true
ver_disp_compile.c = echo $(cmd_compile.c)
ver_disp_compile.S = echo $(cmd_compile.S)
ver_disp_compile.m = echo $(cmd_compile.m)
ver_disp_compile-m = echo $(cmd_compile-m)
ver_disp_strip = echo $(cmd_strip)
ver_disp_ar = echo $(cmd_ar)
ver_disp_ld =
disp_compile.c = $($(DISP)_disp_compile.c)
disp_compile.S = $($(DISP)_disp_compile.S)
disp_compile.m = $($(DISP)_disp_compile.m)
disp_compile-m = $($(DISP)_disp_compile-m)
disp_strip = $($(DISP)_disp_strip)
disp_ar = $($(DISP)_disp_ar)
disp_ld = $($(DISP)_disp_ld)
cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
#cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
cmd_ar = $(AR) $(ARFLAGS) $@ $^
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
compile.E = $(cmd_compile.c:-c=-E)
compile.s = $(cmd_compile.c:-c=-S)
compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_t_strip= @$(disp_strip) ; $(cmd_t_strip)
do_ar = @$(disp_ar) ; $(cmd_ar)
define compile.u
@$(disp_compile.c)
$(Q)$(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
@$(disp_strip)
$(Q)$(STRIPTOOL) $(STRIP_FLAGS) $@
endef
hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
define link.so
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@$(disp_ld)
$(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
-o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
--whole-archive $(firstword $^) --no-whole-archive \
$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
$(Q)$(LN) -sf $(1) $@.$(2)
$(Q)$(LN) -sf $(1) $@
endef
define linkm.so
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@$(disp_ld)
$(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
-o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $(firstword $^) \
$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
$(Q)$(LN) -sf $(1) $@.$(2)
$(Q)$(LN) -sf $(1) $@
endef
CFLAGS-.os+=$(PICFLAG)
CFLAGS-.oS+=$(PICFLAG) -DSHARED
%.o: %.c ; $(compile.c)
%.os: %.c ; $(compile.c)
%.oS: %.c ; $(compile.c)
%.o: %.S ; $(compile.S)
%.os: %.S ; $(compile.S)
%.oS: %.S ; $(compile.S)
%.o: %.s ; $(compile.S)
%.os: %.s ; $(compile.S)
%.oS: %.s ; $(compile.S)
%.E: %.c ; $(compile.E)
%.E: %.S ; $(compile.E)
%.s: %.c ; $(compile.s)
%.s: %.S ; $(compile.s)
$(top_builddir)lib/interp.c:
$(Q)$(INSTALL) -d $(dir $@)
$(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
$(Q)echo "#include <features.h>" >> $@
$(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
"(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
$(interp): $(top_builddir)lib/interp.c
$(compile.c)
$(Q)$(STRIPTOOL) -x -R .note -R .comment $@
$(ldso):
@cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
$(libc):
@cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
$(headers_dep):
@cd $(top_builddir); $(MAKE) headers
CRT=crt1
ifeq ($(HAVE_SHARED),y)
CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
else
CRTS=$(top_builddir)lib/$(CRT).o
endif
$(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
$(Q)$(INSTALL) -d $(dir $@)
$(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
$(Q)$(STRIPTOOL) -x -R .note -R .comment $@
$(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
$(Q)$(INSTALL) -d $(dir $@)
$(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
$(Q)$(STRIPTOOL) -x -R .note -R .comment $@
CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
ifeq ($(UCLIBC_CTOR_DTOR),y)
$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
$(Q)$(INSTALL) -d $(dir $@)
$(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
else
$(CTOR_TARGETS):
$(Q)$(INSTALL) -d $(dir $@)
$(do_ar)
endif
#ifeq ($(TARGET_ARCH),nios)
#CRTS_COMPAT := $(top_builddir)lib/crt0.o
#$(CRTS_COMPAT):
# ln -fs crt1.o $(top_builddir)lib/crt0.o
#else
CRTS_COMPAT :=
#endif
$(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT)
$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
$(Q)$(INSTALL) -d $(dir $@)
$(do_ar)
.PHONY: dummy create
clean: objclean-y headers_clean-y
objclean-y: $(objclean-y)
headers_clean-y: $(headers_clean-y)
.PHONY: \
all check clean distclean test \
config dist menuconfig oldconfig release \
subdirs utils
|