Makefile (882B)
1 BIN = os.bin 2 BINDIR = ../build 3 4 CC = cc 5 ASM = nasm 6 LD = ld 7 CFLAGS = -g -m32 -nostdlib -ffreestanding -Wall -Wextra -std=c99 -O2 8 LDFLAGS = -Ttext 0x1000 --oformat binary 9 10 BOOTFILE = boot.asm 11 BOOT_BIN = boot.bin 12 KERNEL_BIN = kernel.bin 13 SRC = *.c *.asm 14 OBJ = kmain.o \ 15 string.o \ 16 tty.o \ 17 idt.o \ 18 int.o \ 19 kbd.o \ 20 timer.o 21 22 all: options ${BIN} 23 24 options: 25 @echo ${BIN} build options 26 @echo CC = ${CC} 27 @echo ASM = ${ASM} 28 @echo LD = ${LD} 29 @echo CFLAGS = ${CFLAGS} 30 @echo LDFLAGS = ${LDFLAGS} 31 32 ${BIN}: ${OBJ} 33 mkdir -p ${BINDIR} 34 ${ASM} -fbin ${BOOTFILE} -o ${BOOT_BIN} 35 ${LD} ${LDFLAGS} ${OBJ} -o ${KERNEL_BIN} 36 dd if=/dev/zero bs=1000000 count=1 >> ${KERNEL_BIN} 37 cat ${BOOT_BIN} ${KERNEL_BIN} > $@ 38 39 .c.o: 40 ${CC} -c ${CFLAGS} $< 41 42 .asm.o: 43 ${ASM} -felf $< 44 45 install: all 46 mv ${BIN} ${BINDIR} 47 48 clean: 49 rm -rf *.bin *.o 50 51 .PHONY: all options install clean