-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
35 lines (26 loc) · 1.04 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
BOCHS:=./bochs
BUILD:=./build
SRC:=./src
Include:=$(SRC)/include
Bootloader:=bootloader
Kernel:=kernel
CFLAGS=-Wall -Wextra -Wswitch-enum -Wmissing-prototypes -std=c11 -pedantic
LDFLAGS=-Ttext 0xC0001500 -e main
$(BUILD)/$(Bootloader)/%.bin: $(SRC)/$(Bootloader)/%.asm
@if [ ! -d "$(dir $@)" ]; then mkdir -p $(dir $@); fi
nasm -I $(Include) $< -o $@
$(BUILD)/$(Kernel)/%.bin: $(BUILD)/$(Kernel)/%.o
@if [ ! -d "$(dir $@)" ]; then mkdir -p $(dir $@); fi
$(LD) $(LDFLAGS) $< -o $@
$(BUILD)/$(Kernel)/%.o: $(SRC)/$(Kernel)/%.c
@if [ ! -d "$(dir $@)" ]; then mkdir -p $(dir $@); fi
$(CC) $(CFLAGS) -c $< -o $@
build: $(BUILD)/$(Bootloader)/boot.bin $(BUILD)/$(Bootloader)/loader.bin $(BUILD)/$(Kernel)/main.bin
yes | bximage -q -func=create -hd=60M -imgmode=flat $(BUILD)/master.img
dd if=$(BUILD)/$(Bootloader)/boot.bin of=$(BUILD)/master.img bs=512 count=1 conv=notrunc
dd if=$(BUILD)/$(Bootloader)/loader.bin of=$(BUILD)/master.img bs=512 count=4 seek=2 conv=notrunc
run:
bochs -f $(BOCHS)/bochsrc.disk
clean:
@rm -rf $(BUILD)
.PHONY: build run