# SPDX-License-Identifier: Apache-2.0 # Shared definitions for all SchOS ports. # Include this at the top of each port's Makefile: include ../mk/port.mk # # Layout contract — a port directory contains ONLY hand-written files: # # ports//Makefile required # ports//patches/* optional # # Everything generated goes under $(PORTDIR) = build/ports// : # # build/ports//src extracted upstream tarball # build/ports//obj out-of-tree build directory # build/ports//prefix install prefix (musl's headers/libs land here) # # If a file appears inside ports// that you did not write by hand, # it is in the wrong place. `make clean` deletes $(PORTDIR) and nothing else. PORTSDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) TOPDIR := $(abspath $(PORTSDIR)/..) SYSROOT := $(TOPDIR)/sysroot DISTDIR := $(TOPDIR)/dist BUILDROOT := $(TOPDIR)/build/ports # Verifying a downloaded tarball. Not `sha256sum -c -`: that command does not # exist on macOS or the BSDs, and each of them spells it differently. The # helper picks whichever of the five possibilities the host actually has. SHA256CHECK := $(TOPDIR)/tools/posix/sha256check.sh # Port name is the directory name — no per-port boilerplate needed. PORT := $(notdir $(CURDIR)) PORTDIR := $(BUILDROOT)/$(PORT) SRCDIR := $(PORTDIR)/src BUILDDIR := $(PORTDIR)/obj PREFIX := $(PORTDIR)/prefix # musl is the libc every other port links against; its install prefix is a # fixed location so ports don't need to know where musl's own source lives. MUSL := $(BUILDROOT)/musl/prefix # ncurses is the second library other ports link against, so its prefix is # fixed for the same reason musl's is. Unlike every other port it installs # nothing into sysroot/ -- a static library is not a file the OS ships. NCURSES := $(BUILDROOT)/ncurses/prefix CC := clang # FS register belongs to the kernel; never let the compiler touch %fs directly. CFLAGS_BT := -fno-stack-protector .PHONY: all download extract build install clean distclean all: install $(DISTDIR): mkdir -p $(DISTDIR) $(SYSROOT)/bin: mkdir -p $@