-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
78 lines (66 loc) · 2.09 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
include Make.defaults
MODULES := $(basename $(notdir $(wildcard make/*.mk)))
PROGRAMS := $(basename $(notdir $(wildcard make/programs/*.mk)))
TARGET := bin/PatchworkOS.img
setup:
$(MAKE) -C lib/gnu-efi
$(MODULES): setup
$(MAKE) -f make/[email protected] SRCDIR=src/$@ BUILDDIR=build/$@ BINDIR=bin/$@
$(PROGRAMS): $(MODULES)
$(MAKE) -f make/programs/[email protected] SRCDIR=src/programs/$@ BUILDDIR=build/programs/$@ BINDIR=bin/programs
deploy: $(PROGRAMS)
dd if=/dev/zero of=$(TARGET) bs=1M count=64
mkfs.vfat -F 32 -n "PATCHWORKOS" $(TARGET)
mlabel -i $(TARGET) ::PatchworkOS
mmd -i $(TARGET) ::/boot
mmd -i $(TARGET) ::/bin
mmd -i $(TARGET) ::/efi
mmd -i $(TARGET) ::/efi/boot
mmd -i $(TARGET) ::/usr
mmd -i $(TARGET) ::/usr/bin
mmd -i $(TARGET) ::/usr/license
mcopy -i $(TARGET) -s root/* ::
mcopy -i $(TARGET) -s bin/bootloader/bootx64.efi ::/efi/boot
mcopy -i $(TARGET) -s bin/kernel/kernel ::/boot
mcopy -i $(TARGET) -s bin/programs/shell ::/bin
mcopy -i $(TARGET) -s bin/programs/calc ::/usr/bin
mcopy -i $(TARGET) -s bin/programs/terminal ::/usr/bin
mcopy -i $(TARGET) -s bin/programs/helloworld ::/usr/bin
mcopy -i $(TARGET) -s bin/programs/threadtest ::/usr/bin
mcopy -i $(TARGET) -s LICENSE ::/usr/license
clean:
rm -rf build
rm -rf bin
nuke: clean
$(MAKE) -C lib/gnu-efi clean
.PHONY: all
all: setup $(MODULES) $(PROGRAMS) deploy
compile_commands: clean
bear -- make all
format:
find src/ include/ -iname '*.h' -o -iname '*.c' | xargs clang-format -style=file -i
run:
@qemu-system-x86_64 \
-M q35 \
-display sdl \
-drive file=$(TARGET) \
-m 1G \
-smp 8 \
-serial stdio \
-no-shutdown -no-reboot \
-drive if=pflash,format=raw,unit=0,file=lib/OVMFbin/OVMF_CODE-pure-efi.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=lib/OVMFbin/OVMF_VARS-pure-efi.fd \
-net none
run_debug:
@qemu-system-x86_64 \
-M q35 \
-display sdl \
-drive file=$(TARGET) \
-m 1G \
-smp 8 \
-serial stdio \
-d int \
-no-shutdown -no-reboot \
-drive if=pflash,format=raw,unit=0,file=lib/OVMFbin/OVMF_CODE-pure-efi.fd,readonly=on \
-drive if=pflash,format=raw,unit=1,file=lib/OVMFbin/OVMF_VARS-pure-efi.fd \
-net none