]> Git Repo - uclibc-ng.git/blame - Makerules
sync with glibc and fix warning when building pthreads
[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
a80fc77b 5.SUFFIXES: .c .S .o .os .oS .so .a .s .i
9ef10914 6
a80fc77b 7# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
9ef10914 8ifeq ($(HAVE_SHARED),y)
768f982c 9.LIBPATTERNS: "lib%.so"
a80fc77b 10libs: lib-so-y lib-a-y
9ef10914 11else
768f982c 12.LIBPATTERNS: "lib%.a"
a80fc77b 13libs: lib-a-y
9ef10914 14endif
9ef10914 15
237277e9
PM
16lib-a-y: $(lib-a-y)
17lib-so-y: $(lib-so-y)
a80fc77b 18
8c7a3d7c
MF
19ifneq ($(findstring s,$(MAKEFLAGS)),)
20DISP := sil
21Q := @
22else
23ifneq ($(V)$(VERBOSE),)
24DISP := ver
25Q :=
26else
27DISP := pur
28Q := @
29endif
30endif
31
f3adfd4d
MF
32show_objs = $(subst ../,,$@)
33
34pur_disp_compile.c = echo " "CC $(show_objs)
35pur_disp_compile.S = echo " "AS $(show_objs)
8c7a3d7c 36pur_disp_compile.m = $(pur_disp_compile.c)
f3adfd4d 37pur_disp_compile-m = echo " "CC-m $(show_objs)
8c7a3d7c
MF
38pur_disp_strip = echo " "STRIP $(STRIP_FLAGS)
39pur_disp_ar = echo " "AR $(ARFLAGS) $@
40pur_disp_ld = echo " "LD $($(LIB_NAME)_FULL_NAME)
41
42sil_disp_compile.c = true
43sil_disp_compile.S = true
44sil_disp_compile.m = true
45sil_disp_compile-m = true
46sil_disp_strip = true
47sil_disp_ar = true
48sil_disp_ld = true
49
50ver_disp_compile.c = echo $(cmd_compile.c)
51ver_disp_compile.S = echo $(cmd_compile.S)
52ver_disp_compile.m = echo $(cmd_compile.m)
53ver_disp_compile-m = echo $(cmd_compile-m)
54ver_disp_strip = echo $(cmd_strip)
55ver_disp_ar = echo $(cmd_ar)
56ver_disp_ld =
57
f3adfd4d
MF
58disp_compile.c = $($(DISP)_disp_compile.c)
59disp_compile.S = $($(DISP)_disp_compile.S)
60disp_compile.m = $($(DISP)_disp_compile.m)
61disp_compile-m = $($(DISP)_disp_compile-m)
62disp_strip = $($(DISP)_disp_strip)
63disp_ar = $($(DISP)_disp_ar)
64disp_ld = $($(DISP)_disp_ld)
65
8c7a3d7c
MF
66cmd_compile.c = $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<))
67cmd_compile.S = $(cmd_compile.c) $(S_CPPFLAGS) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $@)) $(ASFLAGS-$(notdir $<))
68cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
69cmd_compile-m = $(CC) $^ -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $@)) $(CFLAGS-$(notdir $<)) $(CFLAGS-multi-y)
70cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
71cmd_ar = $(AR) $(ARFLAGS) $@ $^
72
f3adfd4d 73compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
274fdbb0 74compile.E = $(cmd_compile.c:-c=-E)
f3adfd4d
MF
75compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
76compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
77compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
78do_strip = @$(disp_strip) ; $(cmd_strip)
79do_ar = @$(disp_ar) ; $(cmd_ar)
a80fc77b
PM
80
81CFLAGS-.os+=$(PICFLAG)
237277e9 82CFLAGS-.oS+=$(PICFLAG) -DSHARED
a80fc77b 83
8b9c2bd0
PM
84%.o: %.c
85 $(compile.c)
8b9c2bd0 86%.os: %.c
a80fc77b 87 $(compile.c)
a80fc77b 88%.oS: %.c
237277e9 89 $(compile.c)
8b9c2bd0
PM
90%.o: %.S
91 $(compile.S)
8b9c2bd0 92%.os: %.S
a80fc77b 93 $(compile.S)
274fdbb0
MF
94%.o: %.s
95 $(compile.S)
96%.os: %.s
97 $(compile.S)
98%.E: %.c
99 $(compile.E)
100%.E: %.S
101 $(compile.E)
a80fc77b
PM
102
103#ifeq ($(HAVE_ELF),y)
104CRT=crt1
105#else
8585cd4d 106#CRT=crt0
a80fc77b
PM
107#endif
108
237277e9 109ifeq ($(HAVE_SHARED),y)
a80fc77b 110CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
237277e9
PM
111else
112CRTS=$(top_builddir)lib/$(CRT).o
113endif
a80fc77b
PM
114
115$(top_builddir)lib/$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
8c7a3d7c 116 $(Q)$(INSTALL) -d $(dir $@)
a80fc77b 117 $(compile.S) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
f3adfd4d
MF
118 @$(disp_strip) $(show_objs)
119 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
a80fc77b
PM
120
121$(top_builddir)lib/S$(CRT).o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
8c7a3d7c 122 $(Q)$(INSTALL) -d $(dir $@)
a80fc77b 123 $(compile.S) $(PIEFLAG) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
f3adfd4d
MF
124 @$(disp_strip) $(show_objs)
125 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
a80fc77b
PM
126
127CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
128
129ifeq ($(UCLIBC_CTOR_DTOR),y)
130$(top_builddir)lib/crti.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crti.S
8c7a3d7c 131 $(Q)$(INSTALL) -d $(dir $@)
a80fc77b
PM
132 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
133
134$(top_builddir)lib/crtn.o: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/crtn.S
8c7a3d7c 135 $(Q)$(INSTALL) -d $(dir $@)
a80fc77b
PM
136 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
137else
138$(CTOR_TARGETS):
8c7a3d7c
MF
139 $(Q)$(INSTALL) -d $(top_builddir)lib
140 $(do_ar)
a80fc77b
PM
141endif
142
237277e9 143crt-y: $(crt-y)
a80fc77b
PM
144$(crt-y): $(CRTS) $(CTOR_TARGETS)
145
237277e9 146other-y: $(other-y)
2386d6cd 147headers-y: $(headers-y)
a80fc77b 148
237277e9 149objclean-y: $(objclean-y)
a80fc77b
PM
150headers_clean-y: $(headers_clean-y)
151
237277e9 152$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
8c7a3d7c
MF
153 $(Q)$(INSTALL) -d $(dir $@)
154 $(do_ar)
237277e9
PM
155
156.PHONY: dummy create
157clean: objclean-y headers_clean-y
158
159ifeq ($(strip $(LIB_NAME)),)
160LIB_NAME=libc
161endif
a80fc77b
PM
162
163ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),)
164$(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
165endif
166
237277e9
PM
167$(LIB_NAME)-SHARED_OBJS=$($(LIB_NAME)-so-y) $($(LIB_NAME)-shared-y)
168ifeq ($(HAVE_SHARED),y)
169shared: $($(LIB_NAME)-SHARED_OBJS)
a80fc77b 170else
237277e9 171shared:
a80fc77b 172endif
a80fc77b 173
237277e9
PM
174$(LIB_NAME)-ARCHIVE_OBJS=$($(LIB_NAME)-a-y) $($(LIB_NAME)-static-y)
175ifeq ($(DOPIC),y)
176objs: shared $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os) $(crt-y) $(other-y)
a80fc77b 177else
237277e9 178objs: shared $($(LIB_NAME)-ARCHIVE_OBJS) $(crt-y) $(other-y)
a80fc77b
PM
179endif
180
a80fc77b
PM
181libc=$(top_builddir)lib/libc.so
182interp=$(top_builddir)libc/misc/internals/interp.os
183ifeq ($(strip $(EXTRA_LINK_LIBS)),)
184#EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
7eb68fa0 185EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib $(libc) $(LDADD_LIBFLOAT) $(LIBGCC)
a80fc77b
PM
186endif
187
188ifneq ($(strip $(LIB_NAME)),libc)
189ifneq ($(strip $(LIB_NAME)),ld-uClibc)
190$(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp) $(libc)
191else
192$(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a
193endif
194else
195$(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a $(interp)
196endif
8c7a3d7c
MF
197 $(Q)$(INSTALL) -d $(dir $@)
198 $(Q)$(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
199 @$(disp_ld)
200 $(Q)$(LD) $(LDFLAGS) $(EXTRA_LINK_OPTS) -soname=$(notdir $@).$(MAJOR_VERSION) \
a80fc77b
PM
201 -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) $(SHARED_START_FILES) \
202 --whole-archive $(firstword $^) --no-whole-archive \
203 $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
8c7a3d7c 204 $(Q)$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
a80fc77b
PM
205ifneq ($(strip $(LIB_NAME)),libc)
206ifneq ($(strip $(LIB_NAME)),ld-uClibc)
8c7a3d7c 207 $(Q)$(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
a80fc77b
PM
208endif
209else
8c7a3d7c
MF
210 $(Q)echo "/* GNU ld script" > $@
211 $(Q)echo " * Use the shared library, but some functions are only in" >> $@
212 $(Q)echo " * the static library, so try that secondarily. */" >> $@
a80fc77b 213ifeq ($(COMPAT_ATEXIT),y)
8c7a3d7c 214 $(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_MAJORNAME) $(ASNEEDED) )" >> $@
a80fc77b 215else
8c7a3d7c 216 $(Q)echo "GROUP ( $(SHARED_MAJORNAME) $(NONSHARED_LIBNAME) $(ASNEEDED) )" >> $@
a80fc77b 217endif
237277e9
PM
218endif
219
220$($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os: $($(LIB_NAME)-multi-y)
221 $(compile-m)
222
223# local testing only until libc is multi-capable
224libc_m.os: $(libc-multi-y)
225 $(compile-m)
a80fc77b 226
bddfb866 227ifneq ($(DOMULTI),n)
a80fc77b 228
237277e9 229$($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os $($(LIB_NAME)-nomulti-y:.o=.os) $($(LIB_NAME)-shared-y)
8c7a3d7c
MF
230 $(Q)$(RM) $@
231 $(do_strip)
232 $(do_ar)
a80fc77b
PM
233
234ifeq ($(DOPIC),y)
237277e9 235$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.os $($(LIB_NAME)-nomulti-y:.o=.os) $($(LIB_NAME)-static-y:.o=.os)
a80fc77b 236else
237277e9 237$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OUT)/$(LIB_NAME)_m.o $($(LIB_NAME)-nomulti-y) $($(LIB_NAME)-static-y)
a80fc77b 238endif
8c7a3d7c
MF
239 $(Q)$(INSTALL) -d $(dir $@)
240 $(Q)$(RM) $@
241 $(do_strip)
242 $(do_ar)
a80fc77b
PM
243
244else # DOMULTI
245
237277e9 246$($(LIB_NAME)_OUT)/$(LIB_NAME)_so.a: $($(LIB_NAME)-SHARED_OBJS)
8c7a3d7c
MF
247 $(Q)$(RM) $@
248 $(do_strip)
249 $(do_ar)
a80fc77b
PM
250
251ifeq ($(DOPIC),y)
237277e9 252$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS:.o=.os)
a80fc77b 253else
237277e9 254$(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)-ARCHIVE_OBJS)
a80fc77b 255endif
8c7a3d7c
MF
256 $(Q)$(INSTALL) -d $(dir $@)
257 $(Q)$(RM) $@
258 $(do_strip)
259 $(do_ar)
a80fc77b
PM
260
261endif # DOMULTI
262
263$(LIB_NAME)_clean:
8c7a3d7c 264 $(RM) $($(LIB_NAME)_OUT)/*.{o,os,a}
This page took 0.054982 seconds and 4 git commands to generate.