aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 6d0ddc2d5b1fed98f2bbb5ef16221dae5a0c5778 (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
# MIT License, Copyright (c) 2021 Marvin Borner

CC = $(PWD)/cross/opt/bin/i686-elf-gcc
LD = $(PWD)/cross/opt/bin/i686-elf-ld
OC = $(PWD)/cross/opt/bin/i686-elf-objcopy
ST = $(PWD)/cross/opt/bin/i686-elf-strip
AS = nasm

BUILD = $(PWD)/build/

CFLAGS = -Wall -Wextra -Werror -std=c99 -m32 -nostdlib -nostdinc -fno-builtin -fno-profile-generate -fno-omit-frame-pointer -fno-common -ffreestanding -Ofast

ASFLAGS = -f elf32

all: bootloader example

bootloader:
	@mkdir -p $(BUILD)
	@$(CC) -c $(CFLAGS) load.c -o $(BUILD)/load.o
	@$(LD) -N -emain -Ttext 0x00009000 -o $(BUILD)/load.bin $(BUILD)/load.o --oformat binary
	@$(AS) -f bin entry.asm -o $(BUILD)/boot.bin

example:
	@mkdir -p $(BUILD)
	@$(CC) -c $(CFLAGS) example.c -o $(BUILD)/example.o
	@$(LD) -N -ekernel_main -o $(BUILD)/example $(BUILD)/example.o

clean:
	@find . \( -name "*.o" -or -name "*.a" -or -name "*.elf" -or -name "*.bin" \) -type f -delete