Files
kaguya 95cc19fd1a build: partially transition userpsace build system to CMake
Replace the legacy userpsace Makefile with the CMake build system for the kernel

The userspace is the only one still utilizing manual Makefiles, it will eventually be CMakified

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
2026-04-15 01:41:48 -04:00

50 lines
708 B
Makefile

CC = gcc
LD = ld
BUILD = build
EXT2_ROOT = ../ext2_root
CFLAGS = \
-m64 \
-O2 \
-ffreestanding \
-fno-pie \
-fno-pic \
-fno-stack-protector \
-nostdlib \
-nodefaultlibs \
-fno-builtin
LDFLAGS = \
-m elf_x86_64 \
-T linker.ld \
-nostdlib \
-z max-page-size=0x1000
SRC_C = programs/init.c
SRC_S = crt0.S
OBJ = \
$(BUILD)/init.o \
$(BUILD)/crt0.o
all: $(BUILD)/init.elf
$(BUILD):
mkdir -p $(BUILD)
$(BUILD)/init.o: programs/init.c | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/crt0.o: crt0.S | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/init.elf: $(OBJ)
$(LD) $(LDFLAGS) $^ -o $@
install: $(BUILD)/init.elf
cp $(BUILD)/init.elf $(EXT2_ROOT)/init.elf
clean:
rm -rf $(BUILD)