-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (39 loc) · 1.03 KB
/
Makefile
File metadata and controls
51 lines (39 loc) · 1.03 KB
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
.PHONY: all clean
.SECONDARY:;
default: all
NASM ?= nasm
CC ?= gcc
LD ?= ld
ifeq (3.81,$(MAKE_VERSION))
$(error Error: apple make is not supported! Use gmake from homebrew instead)
endif
define TestTemplate =
$(1)/%.o: $(1)/%.asm Makefile
nasm $$< -o $$@ -felf64
$(1)/%.o: $(1)/%.c Makefile
$(CC) $$< -c -o $$@ -e _start
$(1)/%.elf: $(1)/%.o Makefile
$(LD) $$< -o $$@
$(1)/%.bin: bootelf $(1)/%.elf Makefile
cat $$^ > $$@
truncate -s '%512' $$@
tname := $$(word 2,$$(subst /, ,$(1)))
tests := $$(tests) tests/$$(tname)/$$(tname).bin
endef
$(foreach test, $(shell find tests -maxdepth 1 -mindepth 1),$(eval $(call TestTemplate,$(test))))
all: $(tests)
printf "%s\n" $(tests) | \
xargs -n 1 -I diskhere -- \
qemu-system-x86_64\
$(QEMUFlags)\
-drive format=raw,file=diskhere\
-debugcon stdio\
-no-reboot\
-s
clean:
rm -v bootelf || true
rm -v tests/*/*.bin || true
rm -v tests/*/*.elf || true
rm -v tests/*/*.o || true
bootelf: bootelf.asm framebuffer.asm elf_load.asm memmap.asm paging.asm
nasm $< -o $@