forked from rcore-os/zCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
109 lines (84 loc) · 3.76 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
106
107
108
109
# Makefile for top level of zCore
# Possible things to $(MAKE):
#
# rootfs-x64 : contains alpine-rootfs for x86_64, and compiled binary of linux-syscall/test/*.c
# riscv-rootfs : prebuilt binary for riscv64, contains busybox, libc-test and oscomp
# aarch64-rootfs: prebuilt binary for aarch64
# libc-test : build binary of libc-test for x86_64
# rcore-fs-fuse : install a tool called rcore-fs-fuse
# image : make a normal x86_64 image from alpine-rootfs
# riscv-image : make a riscv64 image from riscv-rootfs for testing
# aarch64-image: make a aarch6464 image from aarch64-rootfs for testing
# clean : delete all files generated by compilation
# doc : cargo doc --open
# baremetal-test-img : make a x86_64 image for testing
ROOTFS_TAR := alpine-minirootfs-3.12.0-x86_64.tar.gz
ROOTFS_URL := http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/$(ROOTFS_TAR)
RISCV64_ROOTFS_TAR := prebuild.tar.xz
RISCV64_ROOTFS_URL := https://github.com/rcore-os/libc-test-prebuilt/releases/download/0.1/$(RISCV64_ROOTFS_TAR)
LIBC_TEST_URL := https://github.com/rcore-os/libc-test.git
AARCH64_ROOTFS_TAR := alpine-minirootfs-3.15.4-aarch64.tar.gz
AARCH64_ROOTFS_URL := http://dl-cdn.alpinelinux.org/alpine/v3.15/releases/aarch64/$(AARCH64_ROOTFS_TAR)
CROSS_TOOLCHAIN := http://musl.cc/riscv64-linux-musl-cross.tgz
PATH := $(PATH):$(PWD)/toolchain/riscv64-linux-musl-cross/bin
ARCH ?= x86_64
.PHONY: rootfs libc-test image test-image check doc clean
rootfs:
cargo rootfs $(ARCH)
.PHONY: rootfs libc-test rcore-fs-fuse image
prebuilt/linux/$(ROOTFS_TAR):
wget $(ROOTFS_URL) -O $@
prebuilt/linux/riscv64/$(RISCV64_ROOTFS_TAR):
@wget $(RISCV64_ROOTFS_URL) -O $@
prebuilt/linux/aarch64/$(AARCH64_ROOTFS_TAR):
@wget $(AARCH64_ROOTFS_URL) -O $@
toolchain:
@mkdir -p toolchain
@cd toolchain && wget $(CROSS_TOOLCHAIN)
@cd toolchain && tar xzf riscv64-linux-musl-cross.tgz
rootfs: prebuilt/linux/$(ROOTFS_TAR)
rm -rf rootfs && mkdir -p rootfs
tar xf $< -C rootfs
# libc-libos.so (convert syscall to function call) is from https://github.com/rcore-os/musl/tree/rcore
cp prebuilt/linux/libc-libos.so rootfs/lib/ld-musl-x86_64.so.1
@for VAR in $(BASENAMES); do gcc $(TEST_DIR)$$VAR.c -o $(DEST_DIR)$$VAR $(CFLAG); done
riscv-rootfs:prebuilt/linux/riscv64/$(RISCV64_ROOTFS_TAR)
@rm -rf riscv_rootfs && mkdir -p riscv_rootfs
@tar -xvf $< -C riscv_rootfs --strip-components 1
@ln -s busybox riscv_rootfs/bin/ls
aarch64-rootfs: prebuilt/linux/aarch64/$(AARCH64_ROOTFS_TAR)
@rm -rf aarch64_rootfs && mkdir -p aarch64_rootfs
@tar -xvf $< -C aarch64_rootfs --strip-components 1
libc-test:
cargo libc-test $(ARCH)
image: rootfs
cargo image $(ARCH)
test-image: rootfs libc-test image
check:
cargo xtask check
doc:
cargo doc --open
riscv-image: rcore-fs-fuse riscv-rootfs toolchain
@echo building riscv.img
@cd riscv_rootfs && mv libc-test libc-test-prebuild
@cd riscv_rootfs && git clone $(LIBC_TEST_URL) --depth 1
@cd riscv_rootfs/libc-test && cp config.mak.def config.mak && make ARCH=riscv64 CROSS_COMPILE=riscv64-linux-musl- -j
@cd riscv_rootfs && cp libc-test-prebuild/functional/tls_align-static.exe libc-test/src/functional/
@rcore-fs-fuse zCore/riscv64.img riscv_rootfs zip
@qemu-img resize -f raw zCore/riscv64.img +5M
aarch64-image: rcore-fs-fuse aarch64-rootfs
@echo building aarch64.img
@rcore-fs-fuse zCore/aarch64.img aarch64_rootfs zip
@qemu-img resize -f raw zCore/aarch64.img +5M
clean:
cargo clean
find zCore -maxdepth 1 -name "*.img" -delete
rm -rf rootfs
rm -rf riscv-rootfs
rm -rf aarch64_rootfs
find zCore/target -type f -name "*.zbi" -delete
find zCore/target -type f -name "*.elf" -delete
rt-test:
cd rootfs && git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/clrkwllms/rt-tests --depth 1
cd rootfs/rt-tests && make
echo x86 gcc build rt-test,now need manual modificy.