summaryrefslogtreecommitdiffhomepage
path: root/project/common.mk
blob: d5de244a7e73172852e7323ba42d87847f8eebea (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
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      = $(wildcard $(addsuffix $(ARCH)/, $(libc_src_dirs)))

libc_arch_files_c   = $(wildcard $(addsuffix *.c,$(libc_arch_dirs)))
libc_arch_files_s   = $(wildcard $(addsuffix *.s,$(libc_arch_dirs)))
libc_arch_files_S   = $(wildcard $(addsuffix *.S,$(libc_arch_dirs)))

libc_arch_files     = $(subst $(SOURCE_DIR)/,./, \
		      $(subst $(PROJECT_DIR)/,./, \
		        $(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    = $(subst $(SOURCE_DIR)/,./,   \
		      $(subst $(PROJECT_DIR)/,./,   \
		        $(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_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)/