OSDN Git Service

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