]> git.dujemihanovic.xyz Git - nameless-os.git/blob - Makefile
c8f15f3d53be49549e5fb28c3afa609bef1e7536
[nameless-os.git] / Makefile
1 AS = yasm
2 LD = i686-elf-ld
3 CC = i686-elf-gcc
4
5 GIT_REV = $(shell git rev-parse --short HEAD)
6
7 KERNEL_OBJ = kernel/entry.o kernel/arch/x86/tty/tty.o kernel/drivers/irq/i8259a.o kernel/arch/x86/irq/idt.o kernel/arch/x86/irq/sample_handler.o kernel/kernel.o
8
9 all: boot.img kernel/kernel.elf
10
11 boot.img: boot/x86/boot kernel/kernel.bin
12 cat boot/x86/boot kernel/kernel.bin > $@
13 truncate -s1440K $@
14
15 boot/x86/boot: boot/x86/boot.s boot/x86/a20.s boot/x86/protected.s boot/x86/print.s
16 $(AS) -f bin boot/x86/boot.s -o $@
17
18 kernel/kernel.bin: ${KERNEL_OBJ}
19 $(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ}
20
21 kernel/entry.o: kernel/entry.s
22 $(AS) -f elf kernel/entry.s -o $@
23
24 kernel/arch/x86/tty/tty.o: kernel/arch/x86/tty/tty.c
25 $(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/arch/x86/tty/tty.c
26
27 kernel/drivers/irq/i8259a.o: kernel/drivers/irq/i8259a.c
28 $(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/drivers/irq/i8259a.c
29
30 kernel/arch/x86/irq/idt.o: kernel/arch/x86/irq/idt.c
31 $(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -c kernel/arch/x86/irq/idt.c
32
33 kernel/arch/x86/irq/sample_handler.o: kernel/arch/x86/irq/sample_handler.c
34 $(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -mgeneral-regs-only -c kernel/arch/x86/irq/sample_handler.c
35
36 kernel/kernel.o: kernel/kernel.c
37 $(CC) -std=gnu89 -g -o $@ -Iinclude/arch/x86 -ffreestanding -DGIT_COMMIT=\"$(GIT_REV)\" -c kernel/kernel.c
38
39 kernel/kernel.elf: kernel/kernel.bin
40 $(LD) -o $@ -T kernel/linker.ld ${KERNEL_OBJ} --oformat=elf32-i386
41
42 clean:
43 rm boot/x86/boot kernel/kernel.bin kernel/kernel.elf ${KERNEL_OBJ} boot.img
44
45 .PHONY: all clean