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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
libc_src_dirs = $(SOURCE_DIR)/src/*/
libc_src_dirs += $(SOURCE_DIR)/crt/
libc_src_dirs += $(SOURCE_DIR)/ldso/
ifeq ($(PORT_DIR),$(PROJECT_DIR))
libc_src_dirs += $(PROJECT_DIR)/src/*/
libc_src_dirs += $(PROJECT_DIR)/crt/
libc_src_dirs += $(PROJECT_DIR)/ldso/
endif
libc_src_files = $(wildcard $(addsuffix *.c,$(libc_src_dirs)))
libc_src_sorted = $(sort $(libc_src_files))
libc_src_merged = $(subst $(SOURCE_DIR)/,./, \
$(subst $(PROJECT_DIR)/,./, \
$(libc_src_sorted)))
libc_arch_dirs = $(sort $(wildcard $(addsuffix $(ARCH)/, $(libc_src_dirs))))
libc_arch_files_c = $(subst $(PORT_DIR)/,./,$(wildcard $(addsuffix *.c,$(libc_arch_dirs))))
libc_arch_files_s = $(subst $(PORT_DIR)/,./,$(wildcard $(addsuffix *.s,$(libc_arch_dirs))))
libc_arch_files_S = $(subst $(PORT_DIR)/,./,$(wildcard $(addsuffix *.S,$(libc_arch_dirs))))
libc_arch_files = $(libc_arch_files_c) \
$(libc_arch_files_s) \
$(libc_arch_files_S)
libc_arch_substs_c = $(subst /$(ARCH)/,/,$(libc_arch_files_c))
libc_arch_substs_s = $(subst /$(ARCH)/,/,$(libc_arch_files_s))
libc_arch_substs_S = $(subst /$(ARCH)/,/,$(libc_arch_files_S))
libc_arch_substs = $(libc_arch_substs_c) \
$(libc_arch_substs_s:%.s=%.c) \
$(libc_arch_substs_S:%.S=%.c)
libc_pure_files = $(filter-out $(libc_arch_substs), $(libc_src_merged))
libc_all_files = $(libc_pure_files) $(libc_arch_files)
libc_crt_files_c = $(filter ./crt/%.c, $(libc_all_files))
libc_crt_files_s = $(filter ./crt/%.s, $(libc_all_files))
libc_crt_files_S = $(filter ./crt/%.S, $(libc_all_files))
libc_crt_files = $(filter ./crt/%, $(libc_all_files))
libc_ldso_files = $(filter ./ldso/%, $(libc_all_files))
libc_ldso_files += $(filter ./src/ldso/%, $(libc_all_files))
libc_ldso_files_c = $(filter %.c, $(libc_ldso_files))
libc_ldso_files_s = $(filter %.s, $(libc_ldso_files))
libc_ldso_files_S = $(filter %.S, $(libc_ldso_files))
libc_excl_files = $(libc_crt_files) $(libc_ldso_files) $(LIBC_EXCL_FILES)
libc_core_files = $(filter-out $(libc_excl_files), $(libc_all_files))
libc_core_files_c = $(filter %.c, $(libc_core_files))
libc_core_files_s = $(filter %.s, $(libc_core_files))
libc_core_files_S = $(filter %.S, $(libc_core_files))
libc_tree_dirs = $(subst $(SOURCE_DIR)/,./, \
$(subst $(PORT_DIR)/,./, \
$(wildcard $(SOURCE_DIR)/src/*/) \
$(wildcard $(PORT_DIR)/src/*/) \
$(wildcard $(SOURCE_DIR)/src/*/$(ARCH)/) \
$(wildcard $(PORT_DIR)/src/*/$(ARCH)/)))
libc_tree_dirs += ./crt/ ./crt/$(ARCH)/
libc_tree_dirs += ./ldso/ ./ldso/$(ARCH)/
# depend on all headers
HEADER_DEPS = $(TARGET_SYS_HEADERS) $(src_bits_h) $(src_c_headers)
ALL_HEADERS += $(HEADER_DEPS)
# core objects
STATIC_OBJS += $(libc_core_files_c:%.c=%.o)
STATIC_OBJS += $(libc_core_files_s:%.s=%.o)
STATIC_OBJS += $(libc_core_files_S:%.S=%.o)
SHARED_OBJS += $(libc_core_files_c:%.c=%.lo)
SHARED_OBJS += $(libc_core_files_s:%.s=%.lo)
SHARED_OBJS += $(libc_core_files_S:%.S=%.lo)
$(STATIC_OBJS): headers.tag host.tag tree.tag
$(SHARED_OBJS): headers.tag host.tag tree.tag
$(SHARED_OBJS): CFLAGS_SHARED += $(LIBC_CFLAGS_SHARED) -DSHARED=
$(STATIC_OBJS): CFLAGS_STATIC += $(LIBC_CFLAGS_STATIC)
src/%.o:$(PORT_DIR)/src/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
src/%.o:$(PORT_DIR)/src/%.s
$(AS) -o $@ $< $(CFLAGS_ASM)
src/%.o:$(PORT_DIR)/src/%.S $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
src/%.lo:$(PORT_DIR)/src/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
src/%.lo:$(PORT_DIR)/src/%.s
$(AS) -o $@ $< $(CFLAGS_ASM)
src/%.lo:$(PORT_DIR)/src/%.S $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
# crt objects
CRT_OBJS += $(libc_crt_files_c:%.c=%.o)
CRT_OBJS += $(libc_crt_files_s:%.s=%.o)
CRT_OBJS += $(libc_crt_files_S:%.S=%.o)
$(CRT_OBJS): headers.tag host.tag tree.tag
$(CRT_OBJS): CFLAGS_CONFIG += -DCRT
./crt/Scrt1.o: CFLAGS_CONFIG += -fPIC
./crt/rcrt1.o: CFLAGS_CONFIG += -fPIC
crt/%.o:$(PORT_DIR)/crt/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
crt/%.o:$(PORT_DIR)/crt/%.s
$(AS) -o $@ $< $(CFLAGS_ASM)
crt/%.o:$(PORT_DIR)/crt/%.S $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
crt/%.o:$(SOURCE_DIR)/crt/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_STATIC)
crt-objs: $(CRT_OBJS)
shared-lib:$(CRT_OBJS)
static-lib:$(CRT_OBJS)
clean-crt-objs:
rm -f $(CRT_OBJS)
clean: clean-crt-objs
.PHONY: crt-objs clean-crt-objs
# ldso objects
LDSO_OBJS += $(libc_ldso_files_c:%.c=%.lo)
LDSO_OBJS += $(libc_ldso_files_s:%.s=%.lo)
LDSO_OBJS += $(libc_ldso_files_S:%.S=%.lo)
$(LDSO_OBJS): headers.tag host.tag tree.tag
$(LDSO_OBJS): CFLAGS_SHARED += -DSHARED=
ldso/%.lo:$(PORT_DIR)/ldso/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
ldso/%.lo:$(PORT_DIR)/ldso/%.s
$(AS) -o $@ $< $(CFLAGS_ASM)
ldso/%.lo:$(PORT_DIR)/ldso/%.S $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
ldso/%.lo:$(SOURCE_DIR)/ldso/%.c $(HEADER_DEPS)
$(CC) -c -o $@ $< $(CFLAGS_SHARED)
ldso-objs:$(LDSO_OBJS)
clean-ldso-objs:
rm -f $(LDSO_OBJS)
clean: clean-ldso-objs
.PHONY: ldso-objs clean-ldso-objs
|