blob: 0b1eac61f83ea2612f76fa5b4dab8ba5a6f53dc5 [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
swissChili52a03d82021-07-18 15:22:14 -070014depends(sys, $(ROOT)/src/libsys, libsys.a)
swissChili2b5acc82021-03-13 17:06:42 -080015depends(initrd, $(ROOT)/boot/initrd, initrd.img)
swissChili1a3f07f2021-04-05 20:01:55 -070016depends(ata_pio, dri/ata_pio, ata_pio.a)
swissChilie8491742021-04-08 20:38:06 -070017depends(pci, dri/pci, pci.a)
swissChili5fe85a12021-05-31 08:10:27 -070018depends(ide, dri/ide, ide.a)
swissChili4418ca52021-06-14 17:36:00 -070019depends(ext2, dri/fs/ext2, ext2.a)
swissChilie8491742021-04-08 20:38:06 -070020# AHCI not yet implemented
21# depends(ahci, dri/ahci, ahci.a)
swissChili1a3f07f2021-04-05 20:01:55 -070022
swissChili402a3832021-05-29 21:41:31 -070023TEST ?=
24test_defines = $(TEST:%=-DTEST_%)
25
swissChili4418ca52021-06-14 17:36:00 -070026FS ?= ext2
27
swissChilicbd43632021-07-17 16:19:44 -070028CFLAGS += -I $(ROOT)/include/kernel $(test_defines) -O0
swissChili2b5acc82021-03-13 17:06:42 -080029
swissChili64228692021-03-16 08:19:23 -070030LDFLAGS += -Tlink.ld -melf_i386
swissChili7be32742021-04-03 21:17:24 -070031ASMFLAGS += -felf -Fdwarf
swissChili276b8cf2021-07-16 13:24:42 -070032QEMUFLAGS = -hda hd0_ext2.img
swissChili2b5acc82021-03-13 17:06:42 -080033
34OBJECTS = boot.o \
35 main.o \
36 descriptor_tables.o \
37 io.o \
38 vga.o \
39 gdt_flush.o \
40 idt.o \
41 log.o \
42 irq.o \
43 pic.o \
44 timer.o \
45 paging.o \
46 switch_table.o \
47 scan_codes.o \
48 kheap.o \
49 alloc.o \
50 vfs.o \
51 multiboot.o \
swissChili64228692021-03-16 08:19:23 -070052 vfs_initrd.o \
swissChilie20b79b2021-03-17 21:20:13 -070053 syscall.o \
swissChilicfd3c3c2021-04-03 15:04:24 -070054 task.o \
swissChili1a3f07f2021-04-05 20:01:55 -070055 task_api.o \
swissChiliaed6ff32021-05-29 17:51:04 -070056 faults.o \
swissChili52a03d82021-07-18 15:22:14 -070057 sync.o \
swissChili4418ca52021-06-14 17:36:00 -070058 lib(ext2) \
swissChilie5adca52021-06-16 21:00:31 -070059 lib(ide) \
swissChilie8491742021-04-08 20:38:06 -070060 lib(ata_pio) \
swissChili52a03d82021-07-18 15:22:14 -070061 lib(pci) \
62 lib(sys)
swissChili2b5acc82021-03-13 17:06:42 -080063
64type(custom_link)
65
swissChilicfd3c3c2021-04-03 15:04:24 -070066debug-wait: kernel.elf
swissChilib7ef65d2021-07-17 12:51:52 -070067 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
swissChilicfd3c3c2021-04-03 15:04:24 -070068
swissChili2b5acc82021-03-13 17:06:42 -080069debug: kernel.elf
swissChili9bd74de2021-06-15 20:30:48 -070070 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
swissChili2b5acc82021-03-13 17:06:42 -080071 @echo run "target remote localhost:1234" to connect to qemu
swissChilicfd3c3c2021-04-03 15:04:24 -070072 gdb $<
swissChili2b5acc82021-03-13 17:06:42 -080073 @pkill qemu-system-i38
74
swissChili4418ca52021-06-14 17:36:00 -070075hd0_%.img:
swissChilief829f32021-06-13 20:00:54 -070076 status_log(MKFS, $@)
77 @dd bs=4M count=8 if=/dev/zero of=$@
swissChili4418ca52021-06-14 17:36:00 -070078 @$(patsubst hd0_%.img,mkfs.%,$@) $@
swissChilief829f32021-06-13 20:00:54 -070079
swissChili4418ca52021-06-14 17:36:00 -070080qemu: kernel.elf hd0_$(FS).img
swissChili9bd74de2021-06-15 20:30:48 -070081 qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
swissChili2b5acc82021-03-13 17:06:42 -080082
83qemu-iso: install
84 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
85
86scan_codes.c: gen_scan_codes.py scan_codes.tsv
87 python3 $< > $@
88
swissChili4418ca52021-06-14 17:36:00 -070089mount: hd0_$(FS).img
swissChilief829f32021-06-13 20:00:54 -070090 status_log(MOUNT, $^ $(ROOT)/mnt)
swissChili9bd74de2021-06-15 20:30:48 -070091 @if [ "$(whoami)" = root ]; then echo "DON'T RUN THIS AS ROOT" && exit 1; fi
swissChilief829f32021-06-13 20:00:54 -070092 @mkdir -p $(ROOT)/mnt
swissChili9bd74de2021-06-15 20:30:48 -070093 @mount $^ $(ROOT)/mnt
swissChilief829f32021-06-13 20:00:54 -070094
95umount:
96 status_log(UMOUNT, $(ROOT)/mnt)
97 @umount $(ROOT)/mnt
98
swissChili2b5acc82021-03-13 17:06:42 -080099install: kernel.elf lib(initrd)
100 cp kernel.elf $(ROOT)/boot/
101 rm -f $(ROOT)/bin/bluejay.iso
102 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
103
104finish