OSDN Git Service

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