build: replace hosted target with static linux and add kernel target

Co-authored-by: aider (openrouter/moonshotai/kimi-k2.6) <aider@aider.chat>
This commit is contained in:
2026-05-04 10:48:51 +03:00
parent fcbc810db8
commit 23451c8e85
4 changed files with 279 additions and 8 deletions
+9 -8
View File
@@ -2,21 +2,22 @@ CC = clang
CFLAGS = -Wall -Wextra -g -std=c11
COMMON_SRCS = forth_core.c forth_dict.c forth_words.c forth_interp.c main.c
HOSTED_SRCS = $(COMMON_SRCS) platform_hosted.c
FREESTANDING_SRCS = $(COMMON_SRCS) platform_freestanding.c
LINUX_SRCS = $(COMMON_SRCS) platform_linux.c
KERNEL_SRCS = $(COMMON_SRCS) platform_kernel.c kernel_entry.S
KERNEL_LD = kernel.ld
TARGET = forth
FREESTANDING_TARGET = forth_freestanding
KERNEL_TARGET = forth.kernel
all: $(TARGET)
$(TARGET): $(HOSTED_SRCS) forth.h
$(CC) $(CFLAGS) -D_POSIX_C_SOURCE=200809L -o $@ $(HOSTED_SRCS)
$(TARGET): $(LINUX_SRCS) forth.h
$(CC) $(CFLAGS) -static -nostdlib -ffreestanding -fno-stack-protector -o $@ $(LINUX_SRCS)
$(FREESTANDING_TARGET): $(FREESTANDING_SRCS) forth.h
$(CC) $(CFLAGS) -ffreestanding -nostdlib -fno-stack-protector -o $@ $(FREESTANDING_SRCS)
$(KERNEL_TARGET): $(KERNEL_SRCS) forth.h $(KERNEL_LD)
$(CC) $(CFLAGS) -ffreestanding -nostdlib -fno-stack-protector -mno-red-zone -o $@ $(KERNEL_SRCS) -T$(KERNEL_LD) -Wl,--build-id=none
clean:
rm -f $(TARGET) $(FREESTANDING_TARGET)
rm -f $(TARGET) $(KERNEL_TARGET)
.PHONY: all clean