-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
81 lines (66 loc) · 2.45 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
#----------------------------------------------------------------------------
# AlmeidaOS root makefile
#
# Makefile for all kernel and boot loader targets.
#----------------------------------------------------------------------------
DIR_ROOT := $(CURDIR)
include $(DIR_ROOT)/scripts/config.mk
include $(DIR_ROOT)/docker/config.mk
DIR_SRC_SUBSYSTEMS := $(wildcard $(DIR_SRC)/*)
#----------------------------------------------------------------------------
# Build targets
#----------------------------------------------------------------------------
default: build raw-disk
all: clean compile raw-disk
.PHONY: compile
compile: $(DIR_SRC_SUBSYSTEMS)
.PHONY: $(DIR_SRC_SUBSYSTEMS)
$(DIR_SRC_SUBSYSTEMS):
@$(MAKE) $(MAKE_FLAGS) --directory=$@
.PHONY: raw-disk
raw-disk:
@echo "[raw-disk] Creating Raw disk image containing the AlmeidaOS"
@$(DIR_SCRIPTS)/raw_disk.sh
@# Help: Creates a Raw disk image containing the AlmeidaOS
.PHONY: qemu-debug
qemu-debug:
@$(QEMU) -qmp tcp:localhost:4444,server,nowait \
-gdb tcp::8864 -drive format=raw,file=$(OUTPUT_RAW_DISK) \
-rtc base=localtime \
-S -d guest_errors -d int -no-reboot -no-shutdown
@# Help: Runs QEMU in debug mode so that we can debug the bootloader
.PHONY: gdb-debug
gdb-debug:
@$(GDB) -x $(DIR_SCRIPTS)/gdb/tui_debug_commands.txt \
-ex "set directories $(shell find src/ include/ -type d -exec echo -n {}: \; | sed 's/.$//')" \
-ex 'b kmain'
@# Help: Runs GDB with some personal preferences to debug the bootloader
.PHONY: test
test:
@$(QEMU) -drive format=raw,file=$(OUTPUT_RAW_DISK) \
-rtc base=localtime \
-d guest_errors \
-no-reboot \
-no-shutdown \
-serial stdio
@# Help: Runs QEMU without debugging settings
.PHONY: clean
clean:
@rm -rf $(DIR_BUILD)
@echo "[clean] Generated files deleted"
@# Help: Clean all generated files
.PHONY: build
build:
@echo "[build] Building AlmeidaOS"
@$(DOCKER) run --rm -u$(shell id -u) -v `pwd`:/code:Z $(IMAGE_NAME):$(IMAGE_TAG) \
/bin/bash -c "cd /code && make all"
@# Help: Build the OS using a docker container
MAKEOVERRIDES =
help:
@printf "%-20s %s\n" "Target" "Description"
@printf "%-20s %s\n" "------" "-----------"
@make -pqR : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| sort \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| xargs -I _ sh -c 'printf "%-20s " _; make _ -nB | (grep -i "^# Help:" || echo "") | tail -1 | sed "s/^# Help: //g"'