CatOS/Makefile

24 lines
550 B
Makefile
Raw Normal View History

2024-07-22 04:46:44 +00:00
# Makefile
C_SOURCES = $(wildcard kernel/*.c apps/*.c)
HEADERS = $(wildcard include/*.h)
OBJ = ${C_SOURCES:.c=.o}
CC = gcc
CFLAGS = -m32 -g -ffreestanding -Wall -Wextra
kernel.bin: boot/boot.o ${OBJ}
ld -m elf_i386 -Ttext 0x1000 $^ -o $@ --oformat binary
%.o: %.c ${HEADERS}
${CC} ${CFLAGS} -c $< -o $@
boot/boot.o: boot/boot.s
nasm -f elf32 $< -o $@
os-image.bin: kernel.bin
dd if=/dev/zero bs=512 count=2048 of=os-image.bin
dd if=kernel.bin of=os-image.bin conv=notrunc
clean:
rm -f boot/*.o kernel/*.o apps/*.o kernel.bin os-image.bin