-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (31 loc) · 1.5 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
SRC=src
ASM=nasm
ASM_BOOTSECTOR_FLAGS=-fbin
ASM_KERNEL_FLAGS=-felf
BUILD=build
LD=ld
LD_ARGS=-m elf_i386 -o $(BUILD)/kernel.tmp -Ttext 0x20200 --entry main
LD_SRC=$(BUILD)/kernel.o $(BUILD)/display_control.o $(BUILD)/allocator.o $(BUILD)/io.o $(BUILD)/tramplins.o $(BUILD)/interrupts.o $(BUILD)/8259.o $(BUILD)/interrupts_handlers.o $(BUILD)/virtual_memory.o
SIZE=size
OBJCOPY=objcopy
OBJCOPY_FLAGS=-I elf32-i386 -O binary
OBJCOPY_SRC=$(BUILD)/kernel.tmp $(BUILD)/kernel.bin
all:
$(ASM) $(ASM_BOOTSECTOR_FLAGS) $(SRC)/init.asm -o $(BUILD)/init.bin
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/kernel.asm -o $(BUILD)/kernel.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/display_control.asm -o $(BUILD)/display_control.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/allocator.asm -o $(BUILD)/allocator.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/io.asm -o $(BUILD)/io.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/tramplins.asm -o $(BUILD)/tramplins.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/interrupts.asm -o $(BUILD)/interrupts.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/8259.asm -o $(BUILD)/8259.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/interrupts_handlers.asm -o $(BUILD)/interrupts_handlers.o
$(ASM) $(ASM_KERNEL_FLAGS) $(SRC)/virtual_memory.asm -o $(BUILD)/virtual_memory.o
$(LD) $(LD_ARGS) $(LD_SRC)
$(SIZE) $(BUILD)/kernel.tmp
$(OBJCOPY) $(OBJCOPY_FLAGS) $(OBJCOPY_SRC)
dd if=/dev/zero of=$(BUILD)/boot.img bs=1024 count=1440
dd if=$(BUILD)/init.bin of=$(BUILD)/boot.img conv=notrunc
dd if=$(BUILD)/kernel.bin of=$(BUILD)/boot.img conv=notrunc seek=1
clean:
rm -r $(BUILD)/*