Now I'm making a more clean Makefile:
Code: Select all
KERNEL_NAME := jeko.img
CC := ccache gcc
AS := nasm
LD := ld
PROJDIRS := .
CFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.c")
ASMFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.asm")
OBJFILES := $(shell find $(PROJDIRS) -mindepth 1 -maxdepth 3 -name "*.o")
CFLAGS := -Wall -O -floop-optimize2 -fno-builtin -nostdlib -nostartfiles -nodefaultlibs -nostdinc -I include -ffreestanding -fno-stack-protector
LDFLAGS := -Tlink.ld -o $(KERNEL_NAME)
ASFLAGS := -felf
all: $(KERNEL_NAME)
install:
mount /floppy/
cp $(KERNEL_NAME) /floppy/
umount /floppy/
clean:
rm $(OBJFILES)
%.o: %.asm
$(AS) $(ASFLAGS) -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(KERNEL_NAME): $(OBJFILES)
$(LD) $(LDFLAGS) $(OBJFILES)