forked from LREGS/TacOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
59 lines (38 loc) · 1.34 KB
/
makefile
File metadata and controls
59 lines (38 loc) · 1.34 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
52
53
54
55
56
57
58
59
CC = /usr/local/i386elfgcc/bin/i386-elf-gcc
LD = /usr/local/i386elfgcc/bin/i386-elf-ld
CFLAGS= -ffreestanding -m32 -g -c
SRC = src
BIN= ./bins
_CSRCS := $(shell find ./ -name "*.c")
CSRCS = $(patsubst %.c,%,$(_CSRCS))
ASMBINS := src/bootloader/boot src/bootloader/zeroes
ASMELFS := src/kernel/idtasm src/bootloader/kernel_entry
all: prebuild build
run: prebuild build resize
qemu-system-x86_64 -drive format=raw,file=$(BIN)/OS.bin,index=0,if=ide, -m 256M
test: CFLAGS += -DTEST
test: prebuild build resize
qemu-system-x86_64 -drive format=raw,file=$(BIN)/OS.bin,index=0,if=ide, -m 256M
resize:
qemu-img resize $(BIN)/OS.bin 1G
build: bin elf c
$(LD) -o $(BIN)/full_kernel.bin -Ttext 0x1000 $(shell find $(BIN) -name "*.o" | xargs) --oformat binary
cat $(BIN)/bootloader/boot.bin $(BIN)/full_kernel.bin $(BIN)/bootloader/zeroes.bin > $(BIN)/OS.bin
prebuild:
rm -rf $(BIN)
mkdir $(BIN)
elf: $(ASMELFS)
$(ASMELFS): %: %.asm
mkdir -p $(BIN)/$(shell dirname $(subst $(SRC)/,,$@))
nasm $< -f elf -o $(subst $(SRC),$(BIN),$@.o)
bin: $(ASMBINS)
$(ASMBINS): %: %.asm
mkdir -p $(BIN)/$(shell dirname $(subst $(SRC)/,,$@))
nasm $< -f bin -o $(subst $(SRC),$(BIN),$@.bin)
c: $(CSRCS)
$(CSRCS): % : %.c
mkdir -p $(BIN)/$(shell dirname $(subst $(SRC)/,,$@))
$(CC) $(CFLAGS) $< -o $(subst $(SRC),$(BIN),$@.o)
.PHONY: clean
clean:
rm -rf $(BIN)