Files
MontaukOS/programs/src/printd/Makefile
T
danielandClaude Fable 5 648f7111c0 feat: build userspace programs with the x86_64-montauk toolchain
Switch all program and library Makefiles from host g++ (or the
bare-metal x86_64-elf compiler) to x86_64-montauk-g++/gcc and drop the
flags the target now owns: -nostdinc + kernel freestanding -isystem
paths, -m64/-march, -fno-PIC, -mno-red-zone, -mcmodel=small, -static,
-Wl,-m,elf_x86_64, -z max-page-size, --build-id=none. Deliberate
policy flags stay (-ffreestanding, per-app SSE, -nostdlib + link.ld).

Program builds now require the montauk toolchain and fail with a
pointer to build-montauk-toolchain.sh; lib/ and libs/ keep the host
fallback since the toolchain script bootstraps libc through it.
Userspace is also now pinned to the cross GCC instead of drifting
with the distro compiler.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-14 10:19:35 +02:00

68 lines
1.6 KiB
Makefile

# Makefile for printd (userspace print spooler) on MontaukOS
MAKEFLAGS += -rR
.SUFFIXES:
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-montauk-
ifeq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
CXX = $(error x86_64-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh first)
else
CXX := $(TOOLCHAIN_PREFIX)g++
endif
PROG_INC := ../../include
LIBC_LIB := ../../lib/libc
TLS_LIB := ../../lib/tls
BEARSSL := ../../lib/bearssl
JPEGWRITE := ../../lib/libjpegwrite
LINK_LD := ../../link.ld
BINDIR := ../../bin
OBJDIR := obj
CXXFLAGS := \
-std=gnu++20 \
-g -O2 -pipe \
-Wall \
-Wextra \
-Wno-unused-parameter \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-rtti \
-fno-exceptions \
-ffunction-sections \
-fdata-sections \
-msse \
-msse2 \
-I $(PROG_INC) \
-isystem $(PROG_INC)/libc \
-I $(BEARSSL)/inc
LDFLAGS := \
-nostdlib \
-Wl,--gc-sections \
-T $(LINK_LD)
SRCS := main.cpp test_page_jpeg.cpp font_data.cpp stb_truetype_impl.cpp
OBJS := $(addprefix $(OBJDIR)/,$(SRCS:.cpp=.o))
LIBS := $(TLS_LIB)/libtls.a $(BEARSSL)/libbearssl.a $(JPEGWRITE)/libjpegwrite.a $(LIBC_LIB)/liblibc.a
TARGET := $(BINDIR)/os/printd.elf
DEPS := $(OBJS:.o=.d)
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJS) $(LIBS) $(LINK_LD) Makefile
mkdir -p $(BINDIR)/os
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
$(OBJDIR)/%.o: %.cpp Makefile
mkdir -p $(OBJDIR)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
-include $(DEPS)
clean:
rm -rf $(OBJDIR) $(TARGET)