-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
67 lines (49 loc) · 2 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
BASE_DIR=$(CURDIR)
include $(BASE_DIR)/dependencies.properties
TARGET=$(OS_ARCH)-elf
SYSROOT=$(BASE_DIR)/sysroot
BUILD_DIR=$(BASE_DIR)/build
MODULES_DIR=$(BUILD_DIR)/bootloader/boot
KERNEL_IMAGE=$(BUILD_DIR)/bootloader/boot/kernel.elf
.PHONY: all build run run-debug shell gdb docker-build
.SUFFIXES:
default: iso
clean: module-clean
@echo cleaning...
@rm -rf build src/build
prepare-build: clean module-prepare-build
@cd src && cmake -DCMAKE_TOOLCHAIN_FILE=$(BASE_DIR)/src/intel-x86_64.cmake -H. -Bbuild -G "Ninja"
build:
@cd $(BASE_DIR)/src && cmake --build build
module-clean:
@find src/modules -name build -type d | xargs rm -rf
module-prepare-build: module-clean
@cd src/modules ; for module in `cat modules.list`; do \
echo "Building $$module"; cd $$module && cmake -DCMAKE_TOOLCHAIN_FILE=$(BASE_DIR)/src/intel-x86_64.cmake -H. -Bbuild -G "Ninja" ; \
done
module-build:
@cd src/modules ; for module in `cat modules.list`; do \
echo "Building $$module"; cd $$module && cmake --build build; \
done
lint:
@cd $(BASE_DIR)/src && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -H. build && \
cd $(BASE_DIR) && oclint-json-compilation-database -p $(BASE_DIR)/src/build
test: build lint
@cd $(BASE_DIR)/src/build && ctest -VV
iso: build module-build
@rm -rf $(BASE_DIR)/build
@mkdir -p $(BASE_DIR)/build
@cp -Rv $(BASE_DIR)/bootloader $(BASE_DIR)/build
@cp -v $(BASE_DIR)/src/build/kernel.elf $(KERNEL_IMAGE)
@for module in `cat src/modules/modules.list`; do cp -v $(BASE_DIR)/src/modules/$$module/build/$$module.mod $(MODULES_DIR); done
@grub-mkrescue -o $(BASE_DIR)/build/myos.iso $(BASE_DIR)/build/bootloader
run:
@./tools/start-emulator.sh $(BUILD_DIR)/myos.iso
run-debug:
@./tools/start-emulator.sh $(BUILD_DIR)/myos.iso $(KERNEL_IMAGE)
gdb:
@gdb -iex 'file $(KERNEL_IMAGE)' -iex 'target remote docker.for.mac.localhost:1234' -iex 'break intel_start' -iex 'continue'
dump-symbols:
@objdump -t $(KERNEL_IMAGE) | sort -n
dump-asm:
@bash -c 'objdump -d --section=.text build/bootloader/boot/*.{elf,mod}'