blob: eefaa34e72d6e855309eadb35308bd1264bba9b8 [file] [log] [blame]
swissChili2b5acc82021-03-13 17:06:42 -08001init(kernel, kernel.elf)
2
3preset(freestanding)
swissChilib7ef65d2021-07-17 12:51:52 -07004# This makes debugging hard :(
5# preset(optimize)
swissChili2b5acc82021-03-13 17:06:42 -08006preset(debug)
7preset(32)
8preset(warn)
9preset(nasm)
10
11archetype(c)
12archetype(asm)
13
14depends(initrd, $(ROOT)/boot/initrd, initrd.img)
swissChili1a3f07f2021-04-05 20:01:55 -070015depends(ata_pio, dri/ata_pio, ata_pio.a)
swissChilie8491742021-04-08 20:38:06 -070016depends(pci, dri/pci, pci.a)
swissChili5fe85a12021-05-31 08:10:27 -070017depends(ide, dri/ide, ide.a)
swissChili4418ca52021-06-14 17:36:00 -070018depends(ext2, dri/fs/ext2, ext2.a)
swissChilie8491742021-04-08 20:38:06 -070019# AHCI not yet implemented
20# depends(ahci, dri/ahci, ahci.a)
swissChili1a3f07f2021-04-05 20:01:55 -070021
swissChili402a3832021-05-29 21:41:31 -070022TEST ?=
23test_defines = $(TEST:%=-DTEST_%)
24
swissChili4418ca52021-06-14 17:36:00 -070025FS ?= ext2
26
swissChilicbd43632021-07-17 16:19:44 -070027CFLAGS += -I $(ROOT)/include/kernel $(test_defines) -O0
swissChili2b5acc82021-03-13 17:06:42 -080028
swissChili64228692021-03-16 08:19:23 -070029LDFLAGS += -Tlink.ld -melf_i386
swissChili7be32742021-04-03 21:17:24 -070030ASMFLAGS += -felf -Fdwarf
swissChili276b8cf2021-07-16 13:24:42 -070031QEMUFLAGS = -hda hd0_ext2.img
swissChili2b5acc82021-03-13 17:06:42 -080032
33OBJECTS = boot.o \
34 main.o \
35 descriptor_tables.o \
36 io.o \
37 vga.o \
38 gdt_flush.o \
39 idt.o \
40 log.o \
41 irq.o \
42 pic.o \
43 timer.o \
44 paging.o \
45 switch_table.o \
46 scan_codes.o \
47 kheap.o \
48 alloc.o \
49 vfs.o \
50 multiboot.o \
swissChili64228692021-03-16 08:19:23 -070051 vfs_initrd.o \
swissChilie20b79b2021-03-17 21:20:13 -070052 syscall.o \
swissChilicfd3c3c2021-04-03 15:04:24 -070053 task.o \
swissChili1a3f07f2021-04-05 20:01:55 -070054 task_api.o \
swissChiliaed6ff32021-05-29 17:51:04 -070055 faults.o \
swissChili4418ca52021-06-14 17:36:00 -070056 lib(ext2) \
swissChilie5adca52021-06-16 21:00:31 -070057 lib(ide) \
swissChilie8491742021-04-08 20:38:06 -070058 lib(ata_pio) \
swissChilie5adca52021-06-16 21:00:31 -070059 lib(pci)
swissChili2b5acc82021-03-13 17:06:42 -080060
61type(custom_link)
62
swissChilicfd3c3c2021-04-03 15:04:24 -070063debug-wait: kernel.elf
swissChilib7ef65d2021-07-17 12:51:52 -070064 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
swissChilicfd3c3c2021-04-03 15:04:24 -070065
swissChili2b5acc82021-03-13 17:06:42 -080066debug: kernel.elf
swissChili9bd74de2021-06-15 20:30:48 -070067 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
swissChili2b5acc82021-03-13 17:06:42 -080068 @echo run "target remote localhost:1234" to connect to qemu
swissChilicfd3c3c2021-04-03 15:04:24 -070069 gdb $<
swissChili2b5acc82021-03-13 17:06:42 -080070 @pkill qemu-system-i38
71
swissChili4418ca52021-06-14 17:36:00 -070072hd0_%.img:
swissChilief829f32021-06-13 20:00:54 -070073 status_log(MKFS, $@)
74 @dd bs=4M count=8 if=/dev/zero of=$@
swissChili4418ca52021-06-14 17:36:00 -070075 @$(patsubst hd0_%.img,mkfs.%,$@) $@
swissChilief829f32021-06-13 20:00:54 -070076
swissChili4418ca52021-06-14 17:36:00 -070077qemu: kernel.elf hd0_$(FS).img
swissChili9bd74de2021-06-15 20:30:48 -070078 qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
swissChili2b5acc82021-03-13 17:06:42 -080079
80qemu-iso: install
81 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
82
83scan_codes.c: gen_scan_codes.py scan_codes.tsv
84 python3 $< > $@
85
swissChili4418ca52021-06-14 17:36:00 -070086mount: hd0_$(FS).img
swissChilief829f32021-06-13 20:00:54 -070087 status_log(MOUNT, $^ $(ROOT)/mnt)
swissChili9bd74de2021-06-15 20:30:48 -070088 @if [ "$(whoami)" = root ]; then echo "DON'T RUN THIS AS ROOT" && exit 1; fi
swissChilief829f32021-06-13 20:00:54 -070089 @mkdir -p $(ROOT)/mnt
swissChili9bd74de2021-06-15 20:30:48 -070090 @mount $^ $(ROOT)/mnt
swissChilief829f32021-06-13 20:00:54 -070091
92umount:
93 status_log(UMOUNT, $(ROOT)/mnt)
94 @umount $(ROOT)/mnt
95
swissChili2b5acc82021-03-13 17:06:42 -080096install: kernel.elf lib(initrd)
97 cp kernel.elf $(ROOT)/boot/
98 rm -f $(ROOT)/bin/bluejay.iso
99 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
100
101finish