-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
105 lines (84 loc) · 2.44 KB
/
Makefile
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 libphoenix
#
# Copyright 2018, 2019, 2024 Phoenix Systems
#
# %LICENSE%
#
SIL ?= @
MAKEFLAGS += --no-print-directory
include ../phoenix-rtos-build/Makefile.common
# establish sysroot
SYSROOT := $(shell $(CC) $(CFLAGS) -print-sysroot)
MULTILIB_DIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
LIBC_INSTALL_DIR := $(SYSROOT)/lib/$(MULTILIB_DIR)
LIBC_INSTALL_NAMES := libc.a libm.a libg.a libpthread.a libubsan.a
HEADERS_INSTALL_DIR := $(SYSROOT)/usr/include
LIBNAME := libphoenix.a
ifeq (,$(filter-out /,$(SYSROOT)))
$(error SYSROOT is not supported by the toolchain. Use cross-toolchain to compile.)
endif
CFLAGS += -Iinclude -fno-builtin-malloc
OBJS :=
# crt0.o should have all necessary initialization + call to main()
CRT0_OBJS := $(PREFIX_O)crt0-common.o
LIB_TARGETS := $(PREFIX_A)libphoenix.a $(PREFIX_A)crt0.o
all: $(LIB_TARGETS)
ifneq (,$(findstring arm,$(TARGET_SUFF)))
include arch/arm/Makefile
else
include arch/$(TARGET_SUFF)/Makefile
endif
include ctype/Makefile
include err/Makefile
include errno/Makefile
include locale/Makefile
include math/Makefile
include misc/Makefile
include net/Makefile
include netinet/Makefile
include posix/Makefile
include phoenix/Makefile
include pthread/Makefile
include regex/Makefile
include signal/Makefile
include stdio/Makefile
include stdlib/Makefile
include string/Makefile
include sys/Makefile
include syslog/Makefile
include termios/Makefile
include time/Makefile
include unistd/Makefile
include wchar/Makefile
include ubsan/Makefile
#include test/Makefile
$(PREFIX_A)libphoenix.a: $(OBJS)
$(ARCH)
$(PREFIX_A)crt0.o: $(CRT0_OBJS)
$(ARCH)
SRCHEADERS := $(shell find include -name \*.h)
install: install-headers install-libs
install-headers: $(SRCHEADERS)
@echo INSTALL "$(HEADERS_INSTALL_DIR)/*"; \
mkdir -p "$(HEADERS_INSTALL_DIR)"; \
cp -a include/* "$(HEADERS_INSTALL_DIR)";
# TODO: remove `rm crt0.o` when we will be sure it's not a symlink to libphoenix.a anymore
install-libs: $(LIB_TARGETS)
@echo INSTALL "$(LIBC_INSTALL_DIR)/*"; \
mkdir -p "$(LIBC_INSTALL_DIR)"; \
rm -rf "$(LIBC_INSTALL_DIR)/crt0.o"; \
cp -a $^ "$(LIBC_INSTALL_DIR)"; \
(cd $(LIBC_INSTALL_DIR) && \
for lib in $(LIBC_INSTALL_NAMES); do \
if [ ! -e "$$lib" ]; then \
ln -sf "libphoenix.a" "$$lib"; \
fi \
done)
.PHONY: clean install install-headers install-libs
clean:
@echo "rm -rf $(BUILD_DIR)"
ifneq ($(filter clean,$(MAKECMDGOALS)),)
$(shell rm -rf $(BUILD_DIR))
$(shell rm -f string/*.inc)
endif