# arch.mk - Target architecture settings shared by every userspace Makefile # Copyright (c) 2026 Daniel Hammer # # Included by programs/GNUmakefile and the per-program/per-library # Makefiles. Pass ARCH=aarch64 (the top-level build does) to build for ARM. # # x86_64 keeps the historical layout: objects in obj/, programs in bin/, # libraries next to their sources. Other architectures build side by side: # obj-/, bin-/ and lib//build-/. ARCH ?= x86_64 ifeq ($(filter $(ARCH),x86_64 aarch64),) $(error Unsupported ARCH '$(ARCH)' for userspace) endif MONTAUK_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..) ifeq ($(ARCH),x86_64) ARCH_SUFFIX := ARCH_OUT := else ARCH_SUFFIX := -$(ARCH) ARCH_OUT := build-$(ARCH)/ endif TOOLCHAIN_PREFIX := $(MONTAUK_ROOT)/toolchain/local/bin/$(ARCH)-montauk- TOOLCHAIN_MISSING := $(ARCH)-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh $(ARCH) first # ARCH_FP_FLAGS: programs that use floating point / SIMD (GUI apps) # ARCH_NOFP_FLAGS: system programs that must not touch FP/SIMD registers # ARCH_CFLAGS: code-model flags the libraries pass explicitly ifeq ($(ARCH),x86_64) ARCH_FP_FLAGS := -msse -msse2 ARCH_NOFP_FLAGS := -mno-80387 -mno-mmx -mno-sse -mno-sse2 ARCH_CFLAGS := -m64 -march=x86-64 -mno-red-zone -mcmodel=small ARCH_LD_EMULATION := elf_x86_64 else ARCH_FP_FLAGS := ARCH_NOFP_FLAGS := -mgeneral-regs-only ARCH_CFLAGS := -mcmodel=small ARCH_LD_EMULATION := aarch64elf endif