summaryrefslogtreecommitdiff
path: root/libc/Makefile.in
blob: 4f919acac7327c538ada624e6b2ed93d695f7044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Makefile for uClibc
#
# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#

libc_DIR := $(top_srcdir)libc
libc_OUT := $(top_builddir)libc

# Check if the target architecture has a version script for
# libc, and if so, include it when linking.
VERSION_SCRIPT := $(wildcard $(libc_DIR)/sysdeps/linux/$(TARGET_ARCH)/libc.map)
ifneq ($(VERSION_SCRIPT),)
VERSION_SCRIPT := -Wl,--version-script,$(VERSION_SCRIPT)
endif

LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libc.so := -Wl,--dsbt-index=2
LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -Wl,-init,$(SYMBOL_PREFIX)__uClibc_init
ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
CFLAGS += -D__USE_STDIO_FUTEXES__
endif
LIBS-libc.so := $(interp) $(ldso) $(top_builddir)lib/$(NONSHARED_LIBNAME) $(libubacktrace.depend)

# we have SHARED_LIBNAME=libc.so.$(ABI_VERSION) defined in Rules.mak
libc_FULL_NAME := libuClibc-$(VERSION).so

# this comes first, so duplicate removal works correctly
include $(libc_DIR)/sysdeps/Makefile.in

include $(libc_DIR)/misc/Makefile.in
include $(libc_DIR)/pwd_grp/Makefile.in
include $(libc_DIR)/stdio/Makefile.in
include $(libc_DIR)/string/Makefile.in
include $(libc_DIR)/termios/Makefile.in
include $(libc_DIR)/inet/Makefile.in
include $(libc_DIR)/signal/Makefile.in
include $(libc_DIR)/stdlib/Makefile.in
include $(libc_DIR)/unistd/Makefile.in

ifeq ($(DOPIC),y)
libc-a-y = $(libc-y:.o=.os) $(libc-static-y:.o=.os)
else
libc-a-y = $(libc-y) $(libc-static-y)
endif

ifeq ($(DOMULTI),n)
libc-so-y = $(libc-y:.o=.os) $(libc-shared-y)
else
all_sources = $(libc-y:.o=.c)
all_sources += $(libc-shared-y:.oS=.c)
libc-multi-y = $(filter-out $(libc-nomulti-y:.o=.c),$(all_sources))
endif

lib-a-y += $(top_builddir)lib/libc.a
lib-gdb-y += $(top_builddir)lib/libc.gdb
lib-so-y += $(libc.depend)
objclean-y += CLEAN_libc

OUTPUT_FORMAT = $(CC) $(CFLAGS) -Wl,--verbose 2>&1 | $(SED) -n '/OUTPUT_FORMAT/,/)/p'

ifeq ($(DOMULTI),n)
$(libc.depend): $(libc_OUT)/libc_so.a $(LIBS-libc.so)
	$(call link.so,$(libc_FULL_NAME),$(ABI_VERSION))
else
$(libc.depend): $(libc_OUT)/libc.oS $(libc-nomulti-y:.o=.oS) | $(LIBS-libc.so)
	$(call linkm.so,$(libc_FULL_NAME),$(ABI_VERSION))
endif
	$(Q)$(RM) $@
	$(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
	$(Q)$(OUTPUT_FORMAT) >> $@.tmp
ifeq ($(COMPAT_ATEXIT),y)
	$(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_LIBNAME) $(ASNEEDED) )" >> $@.tmp
else
	$(Q)echo "GROUP ( $(SHARED_LIBNAME) $(NONSHARED_LIBNAME) $(ASNEEDED) )" >> $@.tmp
endif
	$(Q)echo "$(UBACKTRACE_ASNEEDED)" >> $@.tmp
	$(Q)mv $@.tmp $@

$(libc_OUT)/libc_so.a: $(libc-so-y) | $(top_builddir)lib/libc.a $(top_builddir)lib/$(NONSHARED_LIBNAME)
	$(Q)$(RM) $@
ifeq ($(DOPIC),y)
	$(Q)$(STRIPTOOL) $(STRIP_FLAGS) $(libc-shared-y)
else
	$(do_strip)
endif
	$(do_ar)

$(libc_OUT)/libc.oS: $(libc-multi-y) | $(top_builddir)lib/libc.a $(top_builddir)lib/$(NONSHARED_LIBNAME)
	$(Q)$(RM) $@
	$(compile-m)

$(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
	$(Q)$(INSTALL) -d $(dir $@)
	$(Q)$(RM) $@
	$(do_ar)

# We use libc_so.a so that we can compile the shared library with special
# flags - i.e. -mleaf-id-shared-library.  The static libc.a needs to be
# compiled without it.
$(top_builddir)lib/libc.gdb: $(libc_OUT)/libc_so.a $(LINK_FLAT_CRTS)
	$(call link-flat.so,$(@:.gdb=),$(UCLIBC_SHARED_FLAT_ID))

CLEAN_libc:
	$(do_rm) $(addprefix $(libc_OUT)/*., o os oS a)