finix/kernel/Makefile

31 lines
790 B
Makefile
Raw Normal View History

2023-07-16 06:54:32 +00:00
include ../.env
2023-07-17 23:34:52 +00:00
C_SRC = $(shell find src -type f -name "*.c" -not -path "src/arch/*")
C_SRC += $(shell find src/arch/$(ARCH) -type f -name "*.c")
2023-07-16 06:54:32 +00:00
C_OBJ = $(patsubst %.c,bin/%.o, $(C_SRC))
2023-07-17 23:34:52 +00:00
ASM_SRC = $(shell find src -type f -name "*.asm" -not -path "src/arch/*")
ASM_SRC += $(shell find src/arch/$(ARCH) -type f -name "*.asm")
2023-07-16 23:56:56 +00:00
ASM_OBJ = $(patsubst %.asm,bin/%.asm.o, $(ASM_SRC))
2023-07-16 06:54:32 +00:00
CFLAGS += -Iinclude -Isrc -I../libk/include -std=gnu17
.PHONY: all
all: bin/kernel.bin
$(C_OBJ): bin/%.o : %.c
@mkdir -p $(@D)
$(CC) -c $(CFLAGS) -o $@ $<
2023-07-16 23:56:56 +00:00
$(ASM_OBJ): bin/%.asm.o : %.asm
2023-07-16 06:54:32 +00:00
@mkdir -p $(@D)
$(AS) $< -f elf -o $@
bin/kernel.bin: $(C_OBJ) $(ASM_OBJ)
@mkdir -p $(@D)
2023-07-17 23:34:52 +00:00
$(LD) -o bin/kernel.bin -T arch/$(ARCH)/linker.ld $(C_OBJ) $(ASM_OBJ) ../libk/bin/libk.a $(LDFLAGS)
2023-07-16 06:54:32 +00:00
clean:
rm -fr bin