kern.mk (1024B)
1 CC= cc 2 AS= nasm 3 LD= ld 4 ARCH= i386 # FIXME: make this automatic 5 ARCHINCDIR+= ${PREFIX}/${ARCH} 6 INCDIR+= ${PREFIX}/include 7 CFLAGS+= -g -m32 -Wall -Wextra -Werror -pedantic -std=c99 -O2 \ 8 -nostdlib -nodefaultlibs \ 9 -ffreestanding -fno-stack-protector -fno-builtin \ 10 -I${ARCHINCDIR} -I${INCDIR} 11 LDFLAGS+= -T${LINKSCRIPT} --oformat binary -melf_${ARCH} # FIXME: elf sig osdev 12 13 all: options ${BIN} 14 15 options: 16 @echo ${BIN} build options 17 @echo "ARCH = ${ARCH}" 18 @echo "CC = ${CC}" 19 @echo "AS = ${AS}" 20 @echo "LD = ${LD}" 21 @echo "CFLAGS = ${CFLAGS}" 22 @echo "LDFLAGS = ${LDFLAGS}" 23 24 # TODO: boot, dd, kern, cat | start esp when 0x1000 | ld -T x2 | 2mb >> 25 ${BIN}: ${OBJ} 26 mkdir -p ${BINDIR} 27 ${AS} -fbin ${BOOT_FILE} -o ${BOOT_BIN} 28 ${LD} ${LDFLAGS} ${OBJ} -o ${KERNEL_BIN} 29 dd if=/dev/zero bs=1000000 count=1 >> ${KERNEL_BIN} 30 cat ${BOOT_BIN} ${KERNEL_BIN} > $@ 31 32 .c.o: 33 ${CC} -c ${CFLAGS} $< 34 35 .s.o: 36 ${AS} -felf $< 37 38 install: all 39 mv ${BIN} ${BINDIR} 40 41 clean: 42 rm -rf *.bin *.img *.o 43 44 .PHONY: all options install clean