joeylib2/make/programs.mk

87 lines
4.5 KiB
Makefile

# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# Every program's rules, for JoeyLib's own examples and for a project's
# programs alike: one description per program, one set of per-port rules.
#
# Included LAST: by make/<port>.mk after JoeyLib's example descriptions
# (make/examples.mk), and by a project's Makefile after its own (see
# make/project.mk). By then the port is set up, so a description may use
# PLATFORM, ASSET_PLATFORM, BINDIR, PROGRAM_BUILD, PROJECT_DIR,
# PROJECT_BUILD, SPRITEBAKE, HOST_CC/HOST_CFLAGS and the program lookups in
# make/common.mk ($(call programDataDir,ID) and the rest) in its own rules.
#
# A program is the variables named after its ID: an upper-case name of up to
# eight letters and digits, which is also its file name unless NAME says
# otherwise. Any of them can be given for one port only as ID_<PORT>_<VAR>
# (MYGAME_AMIGA_NAME, MYGAME_IIGS_SRCS), which wins over ID_<VAR> there, even
# when empty.
#
# PROGRAMS the ids the `programs` goal (and a project's `all`) builds
# TEST_PROGRAMS ids with rules but built only when asked for (gate probes)
# ID_SRCS its C sources, in link order
# ID_CFLAGS extra compiler flags (-I, -D)
# ID_LDFLAGS extra link flags (-s)
# ID_PORTS the ports it builds for; every port when unset
# ID_NAME its file name without the extension; by default the ID,
# on the Amiga Capitalised (Hello), on DVX lower case
# ID_FOLDER non-empty: it ships in a folder of its own, bin/<name>/,
# with its DATA beside it (the Amiga, ST, DOS and X68000;
# on the IIgs, DVX and macOS every program is packaged
# apart anyway)
# ID_BINDIR build it here instead of bin/ (probe builds)
# ID_DATA its DATA files, as the files the description's own rules
# make under $(call programDataDir,ID) (or
# programOptionalDir, for files it can run without)
# ID_ICON its icon: a picture (PNG, best square, transparent
# where there is no icon), baked for each port that shows
# programs by an icon -- the IIgs Finder, the Amiga's
# Workbench, DVX, Win16, Win32, Haiku and BeOS, the PSP's
# menu, the SDL3 window, the Mac's Finder and Dock, and the
# web page; by default JoeyLib's kangaroo
# (docs/BuildIntegration.adoc, Icons)
# ID_TITLE its title: DVX's window title (default: its Amiga-style
# name), the PSP menu's, and a Mac app's display name
# (default: its name)
# ID_HELP DVX: the line of its help file (no apostrophes: the help is
# written through the shell in quotes)
# ID_IIGS_OVERFLOW_CAP IIgs: link large overflow segments (clang-build.sh's
# JOEY_OVERFLOW_CAP)
# ID_IIGS_GAME_DISK IIgs: non-empty: it ships as its own bootable volume
# (iigs-game-disks, and a project's `all`)
#
# A port's rules for one program are its programRules template, written in
# make/<port>.mk next to that port's library rules.
ifndef JOEY_DISPATCH
PORT_PROGRAMS := $(foreach p,$(PROGRAMS),$(call programOnPort,$(p)))
PORT_TEST_PROGRAMS := $(foreach p,$(TEST_PROGRAMS),$(call programOnPort,$(p)))
$(foreach p,$(PORT_PROGRAMS) $(PORT_TEST_PROGRAMS),$(eval $(call programRules,$(p))))
# Every program of this port with its DATA.
.PHONY: programs
programs: $(foreach p,$(PORT_PROGRAMS),$(call programTarget,$(p)) $(call programVar,$(p),DATA))
# One program by its id, a test program's too, with its DATA: what a gate
# asks for (make -f make/<port>.mk program-AUDPAR).
.PHONY: $(addprefix program-,$(PORT_PROGRAMS) $(PORT_TEST_PROGRAMS))
$(foreach p,$(PORT_PROGRAMS) $(PORT_TEST_PROGRAMS),$(eval program-$(p): $(call programTarget,$(p)) $(call programVar,$(p),DATA)))
# The host bakers a description's bakes use (the sprite pre-compiler, the
# asset and icon bakers, the .NTP converter); make/tools.mk owns their
# sources.
$(SPRITEBAKE) $(ASSET_BAKE) $(ICON_BAKE) $(MOD_TO_NTP): FORCE
$(MAKE) -f $(REPO_DIR)/make/tools.mk $(notdir $@)
# A project's goal for one port: its programs, their DATA and the packages
# the port makes of them (PORT_PACKAGES: the IIgs game disks). JoeyLib's own
# make/<port>.mk files say what their `all` is themselves.
ifdef JOEY_PROJECT
.PHONY: all
all: programs $(PORT_PACKAGES)
endif
endif