Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (62 sloc) 2.57 KB
QEMU := qemu-system-i386
CC := clang
ASM := nasm
ARCH := i386
ARCHES := i386 x86_64
BUILD_TYPE := debug
QEMU_FLAGS :=
# Add all of these flags to whatever user input we get.
override CFLAGS += -std=c99 -Wall -nostdinc -ffreestanding -fno-stack-protector -fno-builtin -g -I include -fdiagnostics-show-option -Wextra -Wunused -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-overflow=4 -Wfloat-equal -Wwrite-strings -Wconversion -Wundef -Wtrigraphs -Wunused-parameter -Wunknown-pragmas -Wcast-align -Wswitch-enum -Waggregate-return -Wmissing-noreturn -Wmissing-format-attribute -Wpacked -Wredundant-decls -Wunreachable-code -Winline -Winvalid-pch -Wdisabled-optimization -Wsystem-headers -Wbad-function-cast
override LDFLAGS += -nostdlib -g
# May as well place this here in case it's needed later
#override ASFLAGS +=
ifeq "${ARCH}" "i386"
override CFLAGS += -m32
override LDFLAGS += -melf_i386
override ASFLAGS += -felf32
else
ifeq "${ARCH}" "x86_64"
override CFLAGS += -m64
override LDFLAGS += -melf_x86_64
override ASFLAGS += -felf64
endif
endif
SOURCE_SUFFIXES := '(' -name '*.c' -o -name '*.asm' ')'
SRCFILES := $(shell find "src/" ${SOURCE_SUFFIXES})
ASMTARGETS = $(shell find "src/" -name '*.asm' | sed 's/asm/o/g')
OBJFILES := $(patsubst %.asm, %.o, $(patsubst %.c,%.o,$(SRCFILES)))
DEPFILES := $(patsubst %.c,%.d,$(SRCFILES))
BUILDINFO := $(shell ./tools/buildinfo.sh ${BUILD_TYPE} ${ARCH} > ./include/buildinfo.h)
all: iso
kernel.exe: kernel-libs $(filter generic/src/kernel/% src/kernel/%, ${OBJFILES})
ld -o src/kernel/parvos.exe ${LDFLAGS} -T src/kernel/link.ld src/kernel/boot/start.o $(filter-out kernel-libs src/kernel/boot/start.o, $^)
@echo $^
kernel-libs:
# krnllib.lib libc.lib
#this needs to take advantage of static rules to apply for all of:
# <libname>: src/lib/<libname>/*.o
#krnllib.lib: $(filter src/lib/krnllib/%.o, ${OBJFILES})
# ar rc src/lib/krnllib/krnllib.lib $^
# ranlib src/lib/krnllib/krnllib.lib
#libc.lib: $(filter src/lib/libc/%.o, ${OBJFILES})
# ar rc src/lib/libc/libc.lib $^
# ranlib src/lib/libc/libc.lib
%.o: %.c
@${CC} ${CFLAGS} -MMD -MP -MT "$*.d $*.o" -c $< -o $@
$(ASMTARGETS): %.o: %.asm
${ASM} ${ASFLAGS} -o $@ $<
%::
@echo "NOHIT" ${ARCH} '$$@' $@ '$$%' $% '$$<' $< '$$?' $? '$$^' $^ '$$+' $+ '$$|' $| '$$*' $*
clean:
@find ./src -name '*.o' -delete
@find ./src -name '*.lib' -delete
@find ./src -name '*.exe' -delete
qemu: iso
$(QEMU) $(QEMU_FLAGS) -monitor stdio -cdrom iso/parvos.iso
iso: kernel.exe
./makeiso.sh $(ARCH) $(BUILD_TYPE)
test:
@echo ${ALLARCHTARGETS}
@echo ${NOARCHTARGETS}
@echo ${CURARCHTARGETS}
@echo ${objects}