]> Git Repo - uclibc-ng.git/blame - Makerules
- fix whitespace
[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
82334a1b 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"
b20ee706 10libs: $(lib-so-y) $(lib-a-y)
5ffab643 11$(lib-so-y): $(interp)
9ef10914 12else
768f982c 13.LIBPATTERNS: "lib%.a"
e1d59aed 14ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
808694e8
MF
15libs: $(lib-gdb-y)
16endif
b20ee706 17libs: $(lib-a-y)
9ef10914 18endif
ec80cbc1 19objs: all_objs
9ef10914 20
eaf180ee 21shared_objs = $(ldso-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) $(libdl-so-y)
e8451264 22shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y) $(libpthread-nonshared-y)
78563c79 23shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
eaf180ee 24ar_objs = $(libc-y) $(libc-static-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
78563c79 25ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
ec80cbc1
PM
26ifeq ($(DOPIC),y)
27ar_objs := $(ar_objs:.o=.os)
28endif
29
30ifeq ($(HAVE_SHARED),y)
31all_objs: $(sort $(shared_objs) $(ar_objs))
32else
33all_objs: $(ar_objs)
34endif
94c41e72 35$(shared_objs) $(ar_objs): | $(sub_headers)
0a7b9d5d
PM
36
37headers-y: $(headers-y)
b5db14a3 38 @true
a80fc77b 39
9bf5af92 40MAKEFLAGS += --no-print-directory
b5db14a3 41SHELL_SET_X := set +x
8c7a3d7c 42ifneq ($(findstring s,$(MAKEFLAGS)),)
b5db14a3
MF
43export MAKE_IS_SILENT := y
44SECHO := -@false
8c7a3d7c
MF
45DISP := sil
46Q := @
47else
b5db14a3
MF
48export MAKE_IS_SILENT := n
49SECHO := @echo
8c7a3d7c 50ifneq ($(V)$(VERBOSE),)
b5db14a3 51SHELL_SET_X := set -x
8c7a3d7c 52DISP := ver
49d47f2b 53Q :=
8c7a3d7c
MF
54else
55DISP := pur
56Q := @
57endif
58endif
59
f3adfd4d
MF
60show_objs = $(subst ../,,$@)
61
62pur_disp_compile.c = echo " "CC $(show_objs)
30c6496f 63pur_disp_compile.u = echo " "CC $(show_objs)
f3adfd4d 64pur_disp_compile.S = echo " "AS $(show_objs)
8c7a3d7c 65pur_disp_compile.m = $(pur_disp_compile.c)
f3adfd4d 66pur_disp_compile-m = echo " "CC-m $(show_objs)
ad93127a 67pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
686016a7 68pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@
8c7a3d7c 69pur_disp_ar = echo " "AR $(ARFLAGS) $@
0a7b9d5d 70pur_disp_ld = echo " "LD $(1)
8c7a3d7c
MF
71
72sil_disp_compile.c = true
30c6496f 73sil_disp_compile.u = true
8c7a3d7c
MF
74sil_disp_compile.S = true
75sil_disp_compile.m = true
76sil_disp_compile-m = true
77sil_disp_strip = true
686016a7 78sil_disp_t_strip = true
8c7a3d7c
MF
79sil_disp_ar = true
80sil_disp_ld = true
81
82ver_disp_compile.c = echo $(cmd_compile.c)
30c6496f 83ver_disp_compile.u = echo $(cmd_compile.u)
8c7a3d7c
MF
84ver_disp_compile.S = echo $(cmd_compile.S)
85ver_disp_compile.m = echo $(cmd_compile.m)
86ver_disp_compile-m = echo $(cmd_compile-m)
87ver_disp_strip = echo $(cmd_strip)
686016a7 88ver_disp_t_strip = echo $(cmd_t_strip)
8c7a3d7c 89ver_disp_ar = echo $(cmd_ar)
49d47f2b 90ver_disp_ld =
8c7a3d7c 91
f3adfd4d 92disp_compile.c = $($(DISP)_disp_compile.c)
30c6496f 93disp_compile.u = $($(DISP)_disp_compile.u)
f3adfd4d
MF
94disp_compile.S = $($(DISP)_disp_compile.S)
95disp_compile.m = $($(DISP)_disp_compile.m)
96disp_compile-m = $($(DISP)_disp_compile-m)
97disp_strip = $($(DISP)_disp_strip)
686016a7 98disp_t_strip = $($(DISP)_disp_t_strip)
f3adfd4d
MF
99disp_ar = $($(DISP)_disp_ar)
100disp_ld = $($(DISP)_disp_ld)
101
6cc179a4 102cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(^D)))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
30c6496f 103cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@))
592900df 104cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
8c7a3d7c 105cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
cd84f06d 106cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
8c7a3d7c 107cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
cd84f06d 108cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
8c7a3d7c
MF
109cmd_ar = $(AR) $(ARFLAGS) $@ $^
110
f3adfd4d 111compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
82334a1b 112compile.i = $(cmd_compile.c:-c=-E -dD)
575f2cfb 113compile.s = $(cmd_compile.c:-c=-S)
f3adfd4d
MF
114compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
115compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
116compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
117do_strip = @$(disp_strip) ; $(cmd_strip)
686016a7 118do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
f3adfd4d 119do_ar = @$(disp_ar) ; $(cmd_ar)
a80fc77b 120
3321ce75 121define compile.u
30c6496f 122 @$(disp_compile.u) ; $(cmd_compile.u)
65ebd664 123 @$(disp_t_strip)
3321ce75
MF
124endef
125hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
126hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
127
76d780f4
PM
128define link.so
129 $(Q)$(INSTALL) -d $(dir $@)
130 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
131 @$(disp_ld)
51ce75b5 132 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
bcfe4064 133 $(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
51ce75b5 134 -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
76d780f4
PM
135 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
136 $(Q)$(LN) -sf $(1) $@.$(2)
137 $(Q)$(LN) -sf $(1) $@
138endef
139
808694e8
MF
140# CRT files needed by link-flat.so
141LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
142 $(top_builddir)lib/crtn.o
143
144# Create a shared flat library from the archive named by the first dependency.
145# $@ names the shared library's .gdb file, not the flat file itself.
146# (This is because the .gdb suffix makes the ELF file more distinctive
147# than the suffixless flat file.)
148#
149# Argument 1 is the shared library file -- i.e. $(@:.gdb=) -- and argument 2
150# is the shared library identifier. If it wasn't for $(disp_ld), we could
151# avoid passing $(@:.gdb=) as an argument and use $(@:.gdb=) instead of $(1).
e682ab41
BS
152#
153# This is so far only used for libc, for which we want to link the entire
154# libgcc into the shared object.
808694e8
MF
155define link-flat.so
156 $(Q)$(INSTALL) -d $(dir $@)
157 $(Q)$(RM) $(1) $@
158 @$(disp_ld)
bcfe4064 159 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(NOSTDLIB_CFLAGS) -o $(1) \
e682ab41 160 -Wl,-elf2flt -Wl,-shared-lib-id,$(2) $(top_builddir)lib/Scrt1.o \
51ce75b5 161 $(top_builddir)/lib/crti.o -Wl,--whole-archive $(firstword $^) \
e682ab41 162 $(LIBGCC) -Wl,--no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
808694e8
MF
163 $(top_builddir)/lib/crtn.o
164endef
165
8e8e47fc
PM
166define linkm.so
167 $(Q)$(INSTALL) -d $(dir $@)
168 $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
169 @$(disp_ld)
51ce75b5 170 $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
49d47f2b
BRF
171 $(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
172 $^ \
8e8e47fc
PM
173 $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
174 $(Q)$(LN) -sf $(1) $@.$(2)
175 $(Q)$(LN) -sf $(1) $@
176endef
177
a80fc77b 178CFLAGS-.os+=$(PICFLAG)
237277e9 179CFLAGS-.oS+=$(PICFLAG) -DSHARED
a80fc77b 180
5396647d
MF
181%.o: %.c ; $(compile.c)
182%.os: %.c ; $(compile.c)
183%.oS: %.c ; $(compile.c)
184%.o: %.S ; $(compile.S)
185%.os: %.S ; $(compile.S)
c0087777 186%.oS: %.S ; $(compile.S)
5396647d
MF
187%.o: %.s ; $(compile.S)
188%.os: %.s ; $(compile.S)
c0087777 189%.oS: %.s ; $(compile.S)
82334a1b
MF
190%.i: %.c ; $(compile.i)
191%.i: %.S ; $(compile.i)
575f2cfb
MF
192%.s: %.c ; $(compile.s)
193%.s: %.S ; $(compile.s)
a80fc77b 194
94c41e72 195$(top_builddir)lib/interp.c: | $(sub_headers)
72c0f6a2
PM
196 $(Q)$(INSTALL) -d $(dir $@)
197 $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
198 $(Q)echo "#include <features.h>" >> $@
72c0f6a2
PM
199 $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
200 "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
72c0f6a2
PM
201
202$(interp): $(top_builddir)lib/interp.c
203 $(compile.c)
72c0f6a2
PM
204 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
205
30a86497 206$(ldso):
7ca2d776 207 @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
72c0f6a2 208
cf5e4b82 209$(libc):
7ca2d776 210 @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
cf5e4b82 211
d6442235 212$(headers_dep): $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh
30a86497 213 $(Q)cd $(top_builddir); $(MAKE) pregen
3c45ffd2 214
28f1d458 215CRT := crt1
a80fc77b 216
e1d59aed 217ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
a80fc77b 218CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
237277e9
PM
219else
220CRTS=$(top_builddir)lib/$(CRT).o
221endif
a80fc77b 222
28f1d458
MF
223ASFLAGS-$(CRT).o := -DL_$(CRT)
224ASFLAGS-S$(CRT).o := $(PIEFLAG) -DL_S$(CRT)
225$(CRTS): $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
8c7a3d7c 226 $(Q)$(INSTALL) -d $(dir $@)
28f1d458 227 $(compile.S)
f3adfd4d 228 $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
a80fc77b 229
fe774e4e 230ifeq ($(UCLIBC_CTOR_DTOR),y)
a80fc77b 231CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
fe774e4e
MF
232else
233CTOR_TARGETS:=
234endif
a80fc77b 235
0e910924
BS
236ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
237CRTRELOC=$(top_builddir)lib/crtreloc.o
238$(CRTRELOC): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.c
239 $(Q)$(INSTALL) -d $(dir $@)
240 $(compile.c)
241endif
242
fe774e4e 243ifneq ($(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c),)
41d42afb 244CFLAGS-initfini.s := -S -g0 $(PICFLAG) -fno-inline-functions -finhibit-size-directive
fe774e4e 245$(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c
41d42afb 246 $(compile.c)
fe774e4e
MF
247
248$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s
249 $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
250 gawk -f $(top_srcdir)extra/scripts/defs.awk > [email protected]
251 $(Q)mv [email protected] $@
252
253$(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h
254 $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
49d47f2b
BRF
255 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
256 -e '/@TRAILER_BEGINS/,$$p' $< > $@
fe774e4e
MF
257
258$(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s
259 $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
49d47f2b
BRF
260 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
261 -e '/@TRAILER_BEGINS/,$$p' $< > $@
fe774e4e
MF
262
263$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_builddir)lib/%.S
8c7a3d7c 264 $(Q)$(INSTALL) -d $(dir $@)
a80fc77b
PM
265 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
266else
fe774e4e 267$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
72c0f6a2 268 $(Q)$(INSTALL) -d $(dir $@)
fe774e4e 269 $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
a80fc77b
PM
270endif
271
0ee2f561
MF
272#ifeq ($(TARGET_ARCH),nios)
273#CRTS_COMPAT := $(top_builddir)lib/crt0.o
274#$(CRTS_COMPAT):
275# ln -fs crt1.o $(top_builddir)lib/crt0.o
276#else
d0bd553f 277CRTS_COMPAT :=
0ee2f561 278#endif
b9b124c1 279
0e910924
BS
280$(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC)
281$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | headers
a80fc77b 282
237277e9 283$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
8c7a3d7c 284 $(Q)$(INSTALL) -d $(dir $@)
e8451264
PM
285 $(Q)$(RM) $@
286 $(do_strip)
287 $(do_ar)
288
289$(top_builddir)lib/libpthread_nonshared.a: $(libpthread-nonshared-y)
290 $(Q)$(INSTALL) -d $(dir $@)
291 $(Q)$(RM) $@
292 $(do_strip)
8c7a3d7c 293 $(do_ar)
237277e9
PM
294
295.PHONY: dummy create
296clean: objclean-y headers_clean-y
297
0a7b9d5d
PM
298objclean-y: $(objclean-y)
299headers_clean-y: $(headers_clean-y)
ad93127a
MF
300
301.PHONY: \
302 all check clean distclean test \
303 config dist menuconfig oldconfig release \
304 subdirs utils
This page took 0.145923 seconds and 4 git commands to generate.