2013-12-06 14:20:46 -05:00
|
|
|
# Build environment
|
2014-02-11 12:21:12 -05:00
|
|
|
PREFIX ?= /usr/local/cross
|
2013-12-06 14:20:46 -05:00
|
|
|
ARCH ?= i586-elf
|
|
|
|
GNU ?= $(PREFIX)/$(ARCH)/bin/$(ARCH)
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
SOURCES_ASM := arch/$(ARCH)/boot.s
|
2014-01-31 16:12:04 -05:00
|
|
|
SOURCES_C := arch/$(ARCH)/multiboot.c driver/video/vga.c kernel/brados.c kernel/printk.c lib/string.c
|
2013-12-06 14:20:46 -05:00
|
|
|
|
|
|
|
# Object files
|
|
|
|
OBJS := $(patsubst %.s,%.o,$(SOURCES_ASM))
|
|
|
|
OBJS += $(patsubst %.c,%.o,$(SOURCES_C))
|
|
|
|
|
|
|
|
# Build flags
|
|
|
|
CFLAGS = -std=gnu99 -ffreestanding -Iinclude/ -O2 -Wall -Wextra
|
2014-02-11 11:57:26 -05:00
|
|
|
LDFLAGS = -ffreestanding -O2 -nostdlib
|
2013-12-06 14:20:46 -05:00
|
|
|
|
|
|
|
# Build rules
|
|
|
|
all: brados.bin
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
brados.bin: $(OBJS) arch/$(ARCH)/linker.ld
|
2014-02-11 11:57:26 -05:00
|
|
|
$(GNU)-gcc -T arch/$(ARCH)/linker.ld -o $@ $(LDFLAGS) $(OBJS) -lgcc
|
2013-12-06 14:20:46 -05:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(OBJS) brados.bin
|
|
|
|
|
|
|
|
# C
|
|
|
|
%.o: %.c Makefile
|
|
|
|
$(GNU)-gcc -c $< -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
# Assembly
|
|
|
|
%.o: %.s Makefile
|
|
|
|
$(GNU)-as $< -o $@
|