aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 4b97fcc4e00e73e882c4227fb176e04d8f7af378 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# MIT License, Copyright (c) 2020 Marvin Borner

COBJS = src/main.o \
		src/drivers/vesa.o \
		src/drivers/cpu.o \
		src/drivers/serial.o \
		src/drivers/interrupts.o \
		src/drivers/interrupts_asm.o \
		src/drivers/keyboard.o \
		src/drivers/ide.o \
		src/drivers/timer.o \
		src/features/fs.o \
		src/features/psf.o \
		src/features/gui.o \
		src/lib/str.o \
		src/lib/mem.o \
		src/lib/math.o \
		src/lib/conv.o \
		src/lib/print.o
CC = cross/opt/bin/i686-elf-gcc
LD = cross/opt/bin/i686-elf-ld
AS = nasm

# Flags to make the binary smaller TODO: Remove after indirect pointer support!
CSFLAGS = -mpreferred-stack-boundary=2 -fno-asynchronous-unwind-tables -Os

# TODO: Use lib as external library
CFLAGS = $(CSFLAGS) -Wall -Wextra -nostdlib -nostdinc -ffreestanding -fno-builtin -fno-pic -mgeneral-regs-only -std=c99 -m32 -pedantic-errors -Isrc/lib/inc/ -Isrc/inc/

ASFLAGS = -f elf32

all: compile clean

%.o: %.c
	@$(CC) -c $(CFLAGS) $< -o $@

%_asm.o: %.asm
	@$(AS) $(ASFLAGS) $< -o $@

kernel: $(COBJS)

compile: kernel
	@mkdir -p build/
	@$(AS) -f bin src/entry.asm -o build/boot.bin
	@$(LD) -N -emain -Ttext 0x00050000 -o build/kernel.bin $(COBJS) --oformat binary
	@$(CC) $(CFLAGS) -emain -o build/debug.o $(COBJS)

clean:
	@find src/ -name "*.o" -type f -delete