blob: ebac3b5a0b438797250ddb8bcfd2cbe346f2ab18 [file] [log] [blame]
swissChili2b5acc82021-03-13 17:06:42 -08001jmk_project := kernel
2jmk_target = kernel.elf
3ROOT := /home/ch/dev/bluejay
4ASM ?= nasm
5CC ?= gcc
6LD ?= ld
7CFLAGS += -I$(ROOT)/include
8
9all: $(jmk_target)
10
11CFLAGS += -nostdlib -nostdinc -fno-builtin -fno-stack-protector -ffreestanding
12CFLAGS += -O2
13CFLAGS += -g
14CFLAGS += -m32
15CFLAGS += -Wall -Wno-unused-function -Wno-unused-variable
16ASM = nasm
17
18
19.c.o:
20 $(CC) -c $< -o $@ $(CFLAGS)
21
22.s.o:
23 $(ASM) $(ASMFLAGS) $< -o $@
24
25
26
27
28jmk_lib_path_initrd = $(ROOT)/boot/initrd
29jmk_lib_target_initrd = initrd.img
30jmk_libs_phony += $(jmk_lib_path_initrd)/$(jmk_lib_target_initrd)
31
32$(jmk_lib_path_initrd)/$(jmk_lib_target_initrd):
33 $(MAKE) -C $(jmk_lib_path_initrd) $(jmk_lib_target_initrd)
34
35LDFLAGS = -Tlink.ld -melf_i386
36ASMFLAGS = -felf
37QEMUFLAGS = -d cpu_reset
38
39OBJECTS = boot.o \
swissChili7eef4382021-02-21 19:23:15 -080040 main.o \
41 descriptor_tables.o \
42 io.o \
43 vga.o \
44 gdt_flush.o \
45 idt.o \
46 log.o \
47 irq.o \
48 pic.o \
49 timer.o \
50 paging.o \
51 switch_table.o \
swissChilie4f01992021-02-25 15:38:12 -080052 scan_codes.o \
53 kheap.o \
swissChili8efa4922021-03-02 16:34:49 -080054 alloc.o \
swissChili9752ab32021-03-05 11:20:13 -080055 vfs.o \
swissChili6c0519e2021-03-07 19:40:23 -080056 multiboot.o \
57 vfs_initrd.o
swissChili8efa4922021-03-02 16:34:49 -080058
swissChili2b5acc82021-03-13 17:06:42 -080059$(jmk_target): $(OBJECTS)
60 $(LD) $(LDFLAGS) -o $@ $^
61
swissChili7eef4382021-02-21 19:23:15 -080062
63debug: kernel.elf
64 qemu-system-i386 -s -S -kernel kernel.elf &
65 @echo run "target remote localhost:1234" to connect to qemu
66 gdb
67 @pkill qemu-system-i38
68
69qemu: kernel.elf
70 qemu-system-i386 $(QEMUFLAGS) -monitor stdio -kernel kernel.elf -no-reboot
71
72qemu-iso: install
swissChili2b5acc82021-03-13 17:06:42 -080073 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
swissChili7eef4382021-02-21 19:23:15 -080074
75scan_codes.c: gen_scan_codes.py scan_codes.tsv
76 python3 $< > $@
77
swissChili2b5acc82021-03-13 17:06:42 -080078install: kernel.elf $(jmk_lib_path_initrd)/$(jmk_lib_target_initrd)
79 cp kernel.elf $(ROOT)/boot/
80 rm -f $(ROOT)/bin/bluejay.iso
81 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
swissChili7eef4382021-02-21 19:23:15 -080082
swissChili2b5acc82021-03-13 17:06:42 -080083clean:
84 rm -f *.o *.a *.so $(jmk_target)
swissChilif46600c2021-03-03 12:35:33 -080085
swissChili2b5acc82021-03-13 17:06:42 -080086Makefile: Jmk
87 cd "/home/ch/dev/bluejay" && ./bin/jmk
swissChili7eef4382021-02-21 19:23:15 -080088
swissChili2b5acc82021-03-13 17:06:42 -080089.PHONY: $(jmk_libs_phony) $(jmk_custom_phony) clean all