-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
83 lines (66 loc) · 1.94 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
# directory paths for different stuff
DESTDIR = $(abspath dist)
CROSSDIR = /opt/cross/bin
# (all) source files
PYSRCS = $(shell find . -type f -name '*.py')
CSRCS = $(shell find . -type f -name '*.c')
HSRCS = $(shell find . -type f -name '*.h')
SSRCS = $(shell find . -type f -name '*.S')
# compiler, linker and archiver
CC = $(CROSSDIR)/x86_64-elf-gcc
LD = $(CROSSDIR)/x86_64-elf-ld
AR = $(CROSSDIR)/x86_64-elf-ar
# exports
export DESTDIR
export CROSSDIR
export CC
export LD
export AR
all: config/config.h $(DESTDIR) kernel_bins user_bins
$(DESTDIR):
mkdir -pv "$@/boot"
mkdir -pv "$@/bin"
mkdir -pv "$@/etc"
##################################################
## build the kernel binary, see kernel/Makefile ##
##################################################
kernel_bins:
make -C kernel all
make -C kernel install
#####################################################
## build the disk image containing userspace files ##
#####################################################
user_bins:
make -C user all
make -C user install
#################################################################
## create the configuration header from the configuration JSON ##
#################################################################
config/config.h: config/config.json
python3 scripts/config.py $^ $@
##########################################################
## additional commands for configuration and formatting ##
##########################################################
clean:
make -C kernel clean
make -C user clean
rm -f "$(DESTDIR)/sdx.img"
image:
make
./scripts/image.sh
qemu:
./scripts/qemu.sh --serial-log
test:
./scripts/test.sh
debug:
./scripts/debug.sh
tools:
./scripts/tools.sh
config:
cp config/default.json config/config.json
format:
black $(PYSRCS)
clang-format -i -style=file $(CSRCS)
clang-format -i -style=file $(HSRCS)
# TODO: find a good ASM formatter and add it here
.PHONY: clean image qemu debug tools config format