blob: 8beb214b96540bb12b4680d3c076c6452a695ea1 [file] [log] [blame]
swissChili2b5acc82021-03-13 17:06:42 -08001init(kernel, kernel.elf)
2
3preset(freestanding)
4preset(optimize)
5preset(debug)
6preset(32)
7preset(warn)
8preset(nasm)
9
10archetype(c)
11archetype(asm)
12
13depends(initrd, $(ROOT)/boot/initrd, initrd.img)
swissChili1a3f07f2021-04-05 20:01:55 -070014depends(ata_pio, dri/ata_pio, ata_pio.a)
swissChilie8491742021-04-08 20:38:06 -070015depends(pci, dri/pci, pci.a)
swissChili5fe85a12021-05-31 08:10:27 -070016depends(ide, dri/ide, ide.a)
swissChili4418ca52021-06-14 17:36:00 -070017depends(ext2, dri/fs/ext2, ext2.a)
swissChilie8491742021-04-08 20:38:06 -070018# AHCI not yet implemented
19# depends(ahci, dri/ahci, ahci.a)
swissChili1a3f07f2021-04-05 20:01:55 -070020
swissChili402a3832021-05-29 21:41:31 -070021TEST ?=
22test_defines = $(TEST:%=-DTEST_%)
23
swissChili4418ca52021-06-14 17:36:00 -070024FS ?= ext2
25
swissChili402a3832021-05-29 21:41:31 -070026CFLAGS += -I $(ROOT)/include/kernel $(test_defines)
swissChili2b5acc82021-03-13 17:06:42 -080027
swissChili64228692021-03-16 08:19:23 -070028LDFLAGS += -Tlink.ld -melf_i386
swissChili7be32742021-04-03 21:17:24 -070029ASMFLAGS += -felf -Fdwarf
swissChili9bd74de2021-06-15 20:30:48 -070030QEMUFLAGS = -hda hd0_$(FS).img
swissChili2b5acc82021-03-13 17:06:42 -080031
32OBJECTS = boot.o \
33 main.o \
34 descriptor_tables.o \
35 io.o \
36 vga.o \
37 gdt_flush.o \
38 idt.o \
39 log.o \
40 irq.o \
41 pic.o \
42 timer.o \
43 paging.o \
44 switch_table.o \
45 scan_codes.o \
46 kheap.o \
47 alloc.o \
48 vfs.o \
49 multiboot.o \
swissChili64228692021-03-16 08:19:23 -070050 vfs_initrd.o \
swissChilie20b79b2021-03-17 21:20:13 -070051 syscall.o \
swissChilicfd3c3c2021-04-03 15:04:24 -070052 task.o \
swissChili1a3f07f2021-04-05 20:01:55 -070053 task_api.o \
swissChiliaed6ff32021-05-29 17:51:04 -070054 faults.o \
swissChili4418ca52021-06-14 17:36:00 -070055 lib(ext2) \
swissChilie8491742021-04-08 20:38:06 -070056 lib(ata_pio) \
swissChili5fe85a12021-05-31 08:10:27 -070057 lib(pci) \
58 lib(ide)
swissChili2b5acc82021-03-13 17:06:42 -080059
60type(custom_link)
61
swissChilicfd3c3c2021-04-03 15:04:24 -070062debug-wait: kernel.elf
63 qemu-system-i386 -s -S -kernel kernel.elf
64
swissChili2b5acc82021-03-13 17:06:42 -080065debug: kernel.elf
swissChili9bd74de2021-06-15 20:30:48 -070066 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
swissChili2b5acc82021-03-13 17:06:42 -080067 @echo run "target remote localhost:1234" to connect to qemu
swissChilicfd3c3c2021-04-03 15:04:24 -070068 gdb $<
swissChili2b5acc82021-03-13 17:06:42 -080069 @pkill qemu-system-i38
70
swissChili4418ca52021-06-14 17:36:00 -070071hd0_%.img:
swissChilief829f32021-06-13 20:00:54 -070072 status_log(MKFS, $@)
73 @dd bs=4M count=8 if=/dev/zero of=$@
swissChili4418ca52021-06-14 17:36:00 -070074 @$(patsubst hd0_%.img,mkfs.%,$@) $@
swissChilief829f32021-06-13 20:00:54 -070075
swissChili4418ca52021-06-14 17:36:00 -070076qemu: kernel.elf hd0_$(FS).img
swissChili9bd74de2021-06-15 20:30:48 -070077 qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
swissChili2b5acc82021-03-13 17:06:42 -080078
79qemu-iso: install
80 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
81
82scan_codes.c: gen_scan_codes.py scan_codes.tsv
83 python3 $< > $@
84
swissChili4418ca52021-06-14 17:36:00 -070085mount: hd0_$(FS).img
swissChilief829f32021-06-13 20:00:54 -070086 status_log(MOUNT, $^ $(ROOT)/mnt)
swissChili9bd74de2021-06-15 20:30:48 -070087 @if [ "$(whoami)" = root ]; then echo "DON'T RUN THIS AS ROOT" && exit 1; fi
swissChilief829f32021-06-13 20:00:54 -070088 @mkdir -p $(ROOT)/mnt
swissChili9bd74de2021-06-15 20:30:48 -070089 @mount $^ $(ROOT)/mnt
swissChilief829f32021-06-13 20:00:54 -070090
91umount:
92 status_log(UMOUNT, $(ROOT)/mnt)
93 @umount $(ROOT)/mnt
94
swissChili2b5acc82021-03-13 17:06:42 -080095install: kernel.elf lib(initrd)
96 cp kernel.elf $(ROOT)/boot/
97 rm -f $(ROOT)/bin/bluejay.iso
98 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
99
100finish