]>
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) |
9ef10914 | 11 | else |
768f982c | 12 | .LIBPATTERNS: "lib%.a" |
b20ee706 | 13 | libs: $(lib-a-y) |
9ef10914 | 14 | endif |
ec80cbc1 | 15 | objs: all_objs |
9ef10914 | 16 | |
ec80cbc1 | 17 | shared_objs = $(ld-uClibc-so-y) $(libc-so-y) $(libc-nonshared-y) $(libdl-so-y) |
72c0f6a2 | 18 | shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y) |
78563c79 PM |
19 | shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y) |
20 | ar_objs = $(libc-a-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y) | |
21 | ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y) | |
ec80cbc1 PM |
22 | ifeq ($(DOPIC),y) |
23 | ar_objs := $(ar_objs:.o=.os) | |
24 | endif | |
25 | ||
26 | ifeq ($(HAVE_SHARED),y) | |
27 | all_objs: $(sort $(shared_objs) $(ar_objs)) | |
28 | else | |
29 | all_objs: $(ar_objs) | |
30 | endif | |
0a7b9d5d PM |
31 | |
32 | headers-y: $(headers-y) | |
a80fc77b | 33 | |
8c7a3d7c MF |
34 | ifneq ($(findstring s,$(MAKEFLAGS)),) |
35 | DISP := sil | |
36 | Q := @ | |
37 | else | |
38 | ifneq ($(V)$(VERBOSE),) | |
39 | DISP := ver | |
40 | Q := | |
41 | else | |
42 | DISP := pur | |
43 | Q := @ | |
44 | endif | |
45 | endif | |
46 | ||
f3adfd4d MF |
47 | show_objs = $(subst ../,,$@) |
48 | ||
49 | pur_disp_compile.c = echo " "CC $(show_objs) | |
50 | pur_disp_compile.S = echo " "AS $(show_objs) | |
8c7a3d7c | 51 | pur_disp_compile.m = $(pur_disp_compile.c) |
f3adfd4d | 52 | pur_disp_compile-m = echo " "CC-m $(show_objs) |
ad93127a | 53 | pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@ |
8c7a3d7c | 54 | pur_disp_ar = echo " "AR $(ARFLAGS) $@ |
0a7b9d5d | 55 | pur_disp_ld = echo " "LD $(1) |
8c7a3d7c MF |
56 | |
57 | sil_disp_compile.c = true | |
58 | sil_disp_compile.S = true | |
59 | sil_disp_compile.m = true | |
60 | sil_disp_compile-m = true | |
61 | sil_disp_strip = true | |
62 | sil_disp_ar = true | |
63 | sil_disp_ld = true | |
64 | ||
65 | ver_disp_compile.c = echo $(cmd_compile.c) | |
66 | ver_disp_compile.S = echo $(cmd_compile.S) | |
67 | ver_disp_compile.m = echo $(cmd_compile.m) | |
68 | ver_disp_compile-m = echo $(cmd_compile-m) | |
69 | ver_disp_strip = echo $(cmd_strip) | |
70 | ver_disp_ar = echo $(cmd_ar) | |
71 | ver_disp_ld = | |
72 | ||
f3adfd4d MF |
73 | disp_compile.c = $($(DISP)_disp_compile.c) |
74 | disp_compile.S = $($(DISP)_disp_compile.S) | |
75 | disp_compile.m = $($(DISP)_disp_compile.m) | |
76 | disp_compile-m = $($(DISP)_disp_compile-m) | |
77 | disp_strip = $($(DISP)_disp_strip) | |
78 | disp_ar = $($(DISP)_disp_ar) | |
79 | disp_ld = $($(DISP)_disp_ld) | |
80 | ||
76d780f4 PM |
81 | cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@)) |
82 | cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@)) | |
8c7a3d7c | 83 | cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
76d780f4 | 84 | cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y) |
8c7a3d7c MF |
85 | cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^ |
86 | cmd_ar = $(AR) $(ARFLAGS) $@ $^ | |
87 | ||
b870fba0 PM |
88 | define compile.u |
89 | $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) | |
90 | $(STRIPTOOL) $(STRIP_FLAGS) $@ | |
91 | endef | |
905b94ad PM |
92 | hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) |
93 | hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@)) | |
b870fba0 | 94 | |
f3adfd4d | 95 | compile.c = @$(disp_compile.c) ; $(cmd_compile.c) |
274fdbb0 | 96 | compile.E = $(cmd_compile.c:-c=-E) |
f3adfd4d MF |
97 | compile.S = @$(disp_compile.S) ; $(cmd_compile.S) |
98 | compile.m = @$(disp_compile.m) ; $(cmd_compile.m) | |
99 | compile-m = @$(disp_compile-m) ; $(cmd_compile-m) | |
100 | do_strip = @$(disp_strip) ; $(cmd_strip) | |
101 | do_ar = @$(disp_ar) ; $(cmd_ar) | |
a80fc77b | 102 | |
76d780f4 PM |
103 | define link.so |
104 | $(Q)$(INSTALL) -d $(dir $@) | |
105 | $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1) | |
106 | @$(disp_ld) | |
107 | $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \ | |
108 | -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \ | |
109 | --whole-archive $(firstword $^) --no-whole-archive \ | |
110 | $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@)) | |
111 | $(Q)$(LN) -sf $(1) $@.$(2) | |
112 | $(Q)$(LN) -sf $(1) $@ | |
113 | endef | |
114 | ||
a80fc77b | 115 | CFLAGS-.os+=$(PICFLAG) |
237277e9 | 116 | CFLAGS-.oS+=$(PICFLAG) -DSHARED |
a80fc77b | 117 | |
5396647d MF |
118 | %.o: %.c ; $(compile.c) |
119 | %.os: %.c ; $(compile.c) | |
120 | %.oS: %.c ; $(compile.c) | |
121 | %.o: %.S ; $(compile.S) | |
122 | %.os: %.S ; $(compile.S) | |
c0087777 | 123 | %.oS: %.S ; $(compile.S) |
5396647d MF |
124 | %.o: %.s ; $(compile.S) |
125 | %.os: %.s ; $(compile.S) | |
c0087777 | 126 | %.oS: %.s ; $(compile.S) |
5396647d MF |
127 | %.E: %.c ; $(compile.E) |
128 | %.E: %.S ; $(compile.E) | |
a80fc77b | 129 | |
72c0f6a2 PM |
130 | $(top_builddir)lib/interp.c: |
131 | $(Q)$(INSTALL) -d $(dir $@) | |
132 | $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@ | |
133 | $(Q)echo "#include <features.h>" >> $@ | |
134 | $(Q)echo "#ifdef __HAVE_ELF__" >> $@ | |
135 | $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \ | |
136 | "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@ | |
137 | $(Q)echo "#endif" >> $@ | |
138 | ||
139 | $(interp): $(top_builddir)lib/interp.c | |
140 | $(compile.c) | |
141 | @$(disp_strip) | |
142 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ | |
143 | ||
144 | $(ldso): | |
6c5c6be0 | 145 | cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@)) |
72c0f6a2 | 146 | |
cf5e4b82 PM |
147 | $(libc): |
148 | cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@)) | |
149 | ||
3c45ffd2 PM |
150 | $(headers_dep): |
151 | cd $(top_builddir); $(MAKE) headers | |
152 | ||
a80fc77b PM |
153 | #ifeq ($(HAVE_ELF),y) |
154 | CRT=crt1 | |
155 | #else | |
8585cd4d | 156 | #CRT=crt0 |
a80fc77b PM |
157 | #endif |
158 | ||
237277e9 | 159 | ifeq ($(HAVE_SHARED),y) |
a80fc77b | 160 | CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o |
237277e9 PM |
161 | else |
162 | CRTS=$(top_builddir)lib/$(CRT).o | |
163 | endif | |
a80fc77b PM |
164 | |
165 | $(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S | |
8c7a3d7c | 166 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b | 167 | $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
ad93127a | 168 | @$(disp_strip) |
f3adfd4d | 169 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ |
a80fc77b PM |
170 | |
171 | $(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S | |
8c7a3d7c | 172 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b | 173 | $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) |
ad93127a | 174 | @$(disp_strip) |
f3adfd4d | 175 | $(Q)$(STRIPTOOL) -x -R .note -R .comment $@ |
a80fc77b PM |
176 | |
177 | CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o | |
178 | ||
179 | ifeq ($(UCLIBC_CTOR_DTOR),y) | |
72c0f6a2 | 180 | $(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S |
8c7a3d7c | 181 | $(Q)$(INSTALL) -d $(dir $@) |
a80fc77b PM |
182 | $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS) |
183 | else | |
184 | $(CTOR_TARGETS): | |
72c0f6a2 | 185 | $(Q)$(INSTALL) -d $(dir $@) |
8c7a3d7c | 186 | $(do_ar) |
a80fc77b PM |
187 | endif |
188 | ||
189 | $(crt-y): $(CRTS) $(CTOR_TARGETS) | |
190 | ||
237277e9 | 191 | $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y) |
8c7a3d7c MF |
192 | $(Q)$(INSTALL) -d $(dir $@) |
193 | $(do_ar) | |
237277e9 PM |
194 | |
195 | .PHONY: dummy create | |
196 | clean: objclean-y headers_clean-y | |
197 | ||
0a7b9d5d PM |
198 | objclean-y: $(objclean-y) |
199 | headers_clean-y: $(headers_clean-y) | |
ad93127a MF |
200 | |
201 | .PHONY: \ | |
202 | all check clean distclean test \ | |
203 | config dist menuconfig oldconfig release \ | |
204 | subdirs utils |