swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 1 | jmk_project := kernel |
| 2 | jmk_target = kernel.elf |
| 3 | ROOT := /home/ch/dev/bluejay |
| 4 | ASM ?= nasm |
| 5 | CC ?= gcc |
| 6 | LD ?= ld |
| 7 | CFLAGS += -I$(ROOT)/include |
| 8 | |
| 9 | all: $(jmk_target) |
| 10 | |
| 11 | CFLAGS += -nostdlib -nostdinc -fno-builtin -fno-stack-protector -ffreestanding |
| 12 | CFLAGS += -O2 |
| 13 | CFLAGS += -g |
| 14 | CFLAGS += -m32 |
| 15 | CFLAGS += -Wall -Wno-unused-function -Wno-unused-variable |
| 16 | ASM = nasm |
| 17 | |
| 18 | |
| 19 | .c.o: |
| 20 | $(CC) -c $< -o $@ $(CFLAGS) |
| 21 | |
| 22 | .s.o: |
| 23 | $(ASM) $(ASMFLAGS) $< -o $@ |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | jmk_lib_path_initrd = $(ROOT)/boot/initrd |
| 29 | jmk_lib_target_initrd = initrd.img |
| 30 | jmk_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 | |
| 35 | LDFLAGS = -Tlink.ld -melf_i386 |
| 36 | ASMFLAGS = -felf |
| 37 | QEMUFLAGS = -d cpu_reset |
| 38 | |
| 39 | OBJECTS = boot.o \ |
swissChili | 7eef438 | 2021-02-21 19:23:15 -0800 | [diff] [blame] | 40 | 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 \ |
swissChili | e4f0199 | 2021-02-25 15:38:12 -0800 | [diff] [blame] | 52 | scan_codes.o \ |
| 53 | kheap.o \ |
swissChili | 8efa492 | 2021-03-02 16:34:49 -0800 | [diff] [blame] | 54 | alloc.o \ |
swissChili | 9752ab3 | 2021-03-05 11:20:13 -0800 | [diff] [blame] | 55 | vfs.o \ |
swissChili | 6c0519e | 2021-03-07 19:40:23 -0800 | [diff] [blame] | 56 | multiboot.o \ |
| 57 | vfs_initrd.o |
swissChili | 8efa492 | 2021-03-02 16:34:49 -0800 | [diff] [blame] | 58 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 59 | $(jmk_target): $(OBJECTS) |
| 60 | $(LD) $(LDFLAGS) -o $@ $^ |
| 61 | |
swissChili | 7eef438 | 2021-02-21 19:23:15 -0800 | [diff] [blame] | 62 | |
| 63 | debug: 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 | |
| 69 | qemu: kernel.elf |
| 70 | qemu-system-i386 $(QEMUFLAGS) -monitor stdio -kernel kernel.elf -no-reboot |
| 71 | |
| 72 | qemu-iso: install |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 73 | qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso |
swissChili | 7eef438 | 2021-02-21 19:23:15 -0800 | [diff] [blame] | 74 | |
| 75 | scan_codes.c: gen_scan_codes.py scan_codes.tsv |
| 76 | python3 $< > $@ |
| 77 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 78 | install: 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) |
swissChili | 7eef438 | 2021-02-21 19:23:15 -0800 | [diff] [blame] | 82 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 83 | clean: |
| 84 | rm -f *.o *.a *.so $(jmk_target) |
swissChili | f46600c | 2021-03-03 12:35:33 -0800 | [diff] [blame] | 85 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 86 | Makefile: Jmk |
| 87 | cd "/home/ch/dev/bluejay" && ./bin/jmk |
swissChili | 7eef438 | 2021-02-21 19:23:15 -0800 | [diff] [blame] | 88 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame^] | 89 | .PHONY: $(jmk_libs_phony) $(jmk_custom_phony) clean all |