forked from redox-os/relibc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (72 loc) · 1.97 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
TARGET?=
BUILD=target
ifneq ($(TARGET),)
BUILD="target/$(TARGET)"
CARGOFLAGS+="--target=$(TARGET)"
endif
ifeq ($(TARGET),aarch64-unknown-linux-gnu)
CC=aarch64-linux-gnu-gcc
endif
ifeq ($(TARGET),x86_64-unknown-redox)
CC=x86_64-unknown-redox-gcc
endif
SRC=\
src/* \
src/*/* \
src/*/*/* \
src/*/*/*/*
.PHONY: all clean fmt include install libc libm test
all: | libc libm
clean:
cargo clean
make -C tests clean
check:
cargo check
fmt:
./fmt.sh
install: all
mkdir -pv "$(DESTDIR)/lib"
mkdir -pv "$(DESTDIR)/include"
cp -rv "include"/* "$(DESTDIR)/include"
cp -rv "$(BUILD)/include"/* "$(DESTDIR)/include"
cp -v "$(BUILD)/release/libc.a" "$(DESTDIR)/lib"
cp -v "$(BUILD)/release/crt0.o" "$(DESTDIR)/lib"
cp -rv "openlibm/include"/* "$(DESTDIR)/include"
cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
libc: $(BUILD)/release/libc.a $(BUILD)/release/crt0.o $(BUILD)/include
libm: $(BUILD)/openlibm/libopenlibm.a
sysroot:
rm -rf [email protected]
mkdir -p [email protected]
make install [email protected]
mv [email protected] $@
touch $@
test: all
make -C tests run
$(BUILD)/debug/libc.a: $(SRC)
cargo build $(CARGOFLAGS)
touch $@
$(BUILD)/debug/crt0.o: $(SRC)
CARGO_INCREMENTAL=0 cargo rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
touch $@
$(BUILD)/release/libc.a: $(SRC)
cargo build --release $(CARGOFLAGS)
touch $@
$(BUILD)/release/crt0.o: $(SRC)
CARGO_INCREMENTAL=0 cargo rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
touch $@
$(BUILD)/include: $(SRC)
rm -rf $@ [email protected]
mkdir -p [email protected]
./include.sh [email protected]
mv [email protected] $@
touch $@
$(BUILD)/openlibm: openlibm
rm -rf $@ [email protected]
mkdir -p $(BUILD)
cp -r $< [email protected]
mv [email protected] $@
touch $@
$(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm $(BUILD)/include
make CC=$(CC) CPPFLAGS="-fno-stack-protector -I$(shell pwd)/include -I $(shell pwd)/$(BUILD)/include" -C $< libopenlibm.a