mbr_asm/Makefile

44 lines
1.3 KiB
Makefile
Raw Normal View History

2018-07-15 21:42:36 +02:00
# Used to generated .d file that deal with header dependencies
CPPFLAGS = -MMD
AS=nasm
ASFLAGS += -f elf32
LDFLAGS += -m32 -nostdlib -static -fno-common -fno-use-cxa-atexit -fno-exceptions -fno-non-call-exceptions -fno-weak -fno-rtti -fno-stack-protector
CFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector
2018-07-19 13:26:28 +02:00
CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie
2018-07-19 13:26:28 +02:00
SUBDIRS := core drivers
CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir))
asmsrc=$(wildcard *.asm)
asmobj=$(asmsrc:%.asm=%.o)
2018-07-19 13:26:28 +02:00
csrc=$(shell find $(SUBDIRS) -type f -name "*.c")# $(wildcard *.c)
cobj=$(csrc:%.c=%.o)
2018-07-15 21:42:36 +02:00
deps = $(csrc:%.c=%.d)
kernel:$(asmobj) $(cobj) linker.ld
$(CXX) $(LDFLAGS) $(cobj) $(asmobj) -o $@ -T linker.ld
fd.img: kernel
dd if=/dev/zero of=$@ bs=512 count=2880
dd if=$< of=$@ conv=notrunc
2018-06-30 01:03:40 +02:00
#https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes
2018-07-19 13:26:28 +02:00
core/exception_handler.o:core/exception_handler.c
$(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< -o $@
core/irq_handler.o:core/irq_handler.c
$(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< -o $@
2018-06-30 01:03:40 +02:00
%.o:%.asm
$(AS) $(ASFLAGS) -o $@ $<
test:kernel
qemu-system-x86_64 -fda $<
clean:
2018-07-15 21:42:36 +02:00
$(RM) kernel $(asmobj) $(cobj) $(deps)
ifneq ($(MAKECMDGOALS),clean)
-include $(deps)
endif