172 lines
7.2 KiB
Makefile
172 lines
7.2 KiB
Makefile
# Apple IIgs build rules.
|
|
#
|
|
# Uses GoldenGate's iix to drive ORCA/C 2.1.0 + ORCA Linker. The
|
|
# toolchains/iigs/iix-build.sh wrapper handles ORCA's case-sensitivity
|
|
# quirks (lowercase .a/.root/.sym vs linker demands for uppercase),
|
|
# multi-source compile/link, and pragma injection for include paths
|
|
# and the stdint/stdbool shim headers.
|
|
|
|
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
|
|
|
|
PLATFORM := iigs
|
|
BUILD := $(REPO_DIR)/build/$(PLATFORM)
|
|
BINDIR := $(BUILD)/bin
|
|
|
|
PORT_C_SRCS_ALL := $(wildcard $(SRC_PORT)/iigs/*.c)
|
|
|
|
# audio.c is the no-op stub linked into every demo. audio_full.c is the
|
|
# real implementation (NewHandle / fopen / JSL trampoline) and links
|
|
# only into AUDIO -- the IIgs build is monolithic, so pulling Memory
|
|
# Manager + ORCA stdio into every binary blows the linker's
|
|
# "Expression too complex" budget. The two files define the same
|
|
# halAudio* symbols; iigs/audio.c is filtered out of the AUDIO source
|
|
# set, audio_full.c is filtered out of the everyone-else set.
|
|
PORT_C_SRCS := $(filter-out %/audio_full.c, $(PORT_C_SRCS_ALL))
|
|
PORT_C_SRCS_AUDIO := $(filter-out %/audio.c, $(PORT_C_SRCS_ALL))
|
|
|
|
# IIgs uses NTPstreamsound for SFX, not the libxmp+overlay combo that
|
|
# DOS and ST share, so src/core/audioSfxMix.c is unused here. Filter
|
|
# it out so the ORCA Linker doesn't pull its dead code into every
|
|
# IIgs binary (the monolithic-link budget is tight).
|
|
CORE_C_SRCS_IIGS := $(filter-out %/audioSfxMix.c, $(CORE_C_SRCS))
|
|
|
|
# Sprite codegen: 65816 emitter + cross-platform compile dispatch.
|
|
CODEGEN_SRCS := $(REPO_DIR)/src/codegen/spriteEmitIigs.c \
|
|
$(REPO_DIR)/src/codegen/spriteCompile.c
|
|
|
|
LIB_SRCS := $(CORE_C_SRCS_IIGS) $(PORT_C_SRCS) $(CODEGEN_SRCS)
|
|
LIB_SRCS_AUDIO := $(CORE_C_SRCS_IIGS) $(PORT_C_SRCS_AUDIO) $(CODEGEN_SRCS)
|
|
|
|
# NinjaTrackerPlus replayer. Assembled with Merlin32 from the staged
|
|
# source at toolchains/iigs/ntp/ninjatrackerplus.s. Output is a 34 KB
|
|
# raw 65816 binary that the IIgs audio HAL loads at runtime via
|
|
# Memory Manager into a fixed-bank handle. NTP source is bank-internal
|
|
# (no JSL/JML cross-bank jumps) so the player works at any bank-start
|
|
# load address even though it was assembled with `org $0F0000`.
|
|
NTP_SRC := $(REPO_DIR)/toolchains/iigs/ntp/ninjatrackerplus.s
|
|
NTP_BIN := $(BUILD)/audio/ntpplayer.bin
|
|
IIGS_MERLIN := $(REPO_DIR)/toolchains/iigs/merlin32/bin/merlin32
|
|
|
|
HELLO_SRC := $(EXAMPLES)/hello/hello.c
|
|
HELLO_BIN := $(BINDIR)/HELLO
|
|
PATTERN_SRC := $(EXAMPLES)/pattern/pattern.c
|
|
PATTERN_BIN := $(BINDIR)/PATTERN
|
|
KEYS_SRC := $(EXAMPLES)/keys/keys.c
|
|
KEYS_BIN := $(BINDIR)/KEYS
|
|
JOY_SRC := $(EXAMPLES)/joy/joy.c
|
|
JOY_BIN := $(BINDIR)/JOY
|
|
SPRITE_SRC := $(EXAMPLES)/sprite/sprite.c
|
|
SPRITE_BIN := $(BINDIR)/SPRITE
|
|
AUDIO_SRC := $(EXAMPLES)/audio/audio.c
|
|
AUDIO_BIN := $(BINDIR)/AUDIO
|
|
AUDIO_MOD := $(REPO_DIR)/assets/test.mod
|
|
AUDIO_SFX := $(REPO_DIR)/assets/test.sfx
|
|
AUDIO_NTP := $(BUILD)/audio/test.ntp
|
|
AUDIO_HEADER := $(BUILD)/audio/test_assets.h
|
|
JOEYMOD := $(REPO_DIR)/tools/joeymod/joeymod
|
|
DISK_IMG := $(BINDIR)/joey.2mg
|
|
|
|
IIGS_PACKAGE := $(REPO_DIR)/toolchains/iigs/package-disk.sh
|
|
|
|
IIX_INCLUDES := \
|
|
-I $(IIGS_INCLUDE_SHIM) \
|
|
-I $(INCLUDE_DIR) \
|
|
-I $(INCLUDE_DIR)/joey \
|
|
-I $(SRC_CORE) \
|
|
-I $(REPO_DIR)/src/codegen
|
|
|
|
.PHONY: all iigs iigs-disk clean-iigs
|
|
all iigs: $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) $(NTP_BIN)
|
|
|
|
$(NTP_BIN): $(NTP_SRC) $(IIGS_MERLIN)
|
|
@mkdir -p $(dir $@)
|
|
@cp $(NTP_SRC) $(BUILD)/audio/ninjatrackerplus.s
|
|
cd $(BUILD)/audio && $(IIGS_MERLIN) . ninjatrackerplus.s
|
|
mv $(BUILD)/audio/ntpplayer $@
|
|
|
|
# iix-build.sh takes MAIN.c first, then EXTRA sources (compiled with
|
|
# #pragma noroot). The example source supplies main(); libjoey sources
|
|
# are the extras. The chtyp post-step tags the output as GS/OS S16
|
|
# ($B3) so GS/OS recognizes it as launchable; the file-type lives in
|
|
# a user.com.apple.FinderInfo xattr that iix and profuse preserve.
|
|
$(HELLO_BIN): $(HELLO_SRC) $(LIB_SRCS) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(HELLO_SRC) $(LIB_SRCS)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
$(PATTERN_BIN): $(PATTERN_SRC) $(LIB_SRCS) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(PATTERN_SRC) $(LIB_SRCS)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
$(KEYS_BIN): $(KEYS_SRC) $(LIB_SRCS) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(KEYS_SRC) $(LIB_SRCS)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
$(JOY_BIN): $(JOY_SRC) $(LIB_SRCS) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) $(IIX_INCLUDES) -o $@ $(JOY_SRC) $(LIB_SRCS)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
# Sprite demo uses ORCA-C large memory model (-b) so pointers are
|
|
# 32-bit and the codegen-arena JSL stub can call cross-bank into the
|
|
# arena. Without -b, ORCA-C's 16-bit pointers would lose the bank
|
|
# byte and the stub would JSL into bank 0 (system memory) -> crash.
|
|
$(SPRITE_BIN): $(SPRITE_SRC) $(LIB_SRCS) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) -b $(IIX_INCLUDES) -o $@ $(SPRITE_SRC) $(LIB_SRCS)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
# IIgs override of test_assets.h: gTestMod[] holds .NTP-converted bytes
|
|
# (NinjaTrackerPlus runtime format) instead of raw .MOD. The SFX bytes
|
|
# are platform-independent so we just embed the same test.sfx.
|
|
#
|
|
# .NTP conversion runs joeymod (which shells out to ntpconverter.php).
|
|
# If PHP is missing we skip the override entirely and the regular .MOD
|
|
# bytes get linked instead -- the IIgs binary still builds and the
|
|
# trampoline still calls into NTP, but NTPprepare will reject the MOD
|
|
# magic at runtime. Install php-cli to get real audio playback.
|
|
HAVE_PHP := $(shell command -v php >/dev/null 2>&1 && echo 1)
|
|
|
|
ifeq ($(HAVE_PHP),1)
|
|
$(AUDIO_NTP): $(AUDIO_MOD) $(JOEYMOD)
|
|
@mkdir -p $(dir $@)
|
|
$(JOEYMOD) $< $@
|
|
|
|
$(AUDIO_HEADER): $(AUDIO_NTP) $(AUDIO_SFX)
|
|
@mkdir -p $(dir $@)
|
|
@echo "// Generated by make/iigs.mk -- gTestMod is .NTP, gTestSfx is raw PCM." > $@
|
|
@echo "#ifndef JOEY_AUDIO_TEST_ASSETS_H" >> $@
|
|
@echo "#define JOEY_AUDIO_TEST_ASSETS_H" >> $@
|
|
@printf "static const unsigned char gTestMod[] = {\n" >> $@
|
|
@xxd -i < $(AUDIO_NTP) >> $@
|
|
@printf "};\nstatic const unsigned int gTestMod_len = %d;\n" $$(wc -c < $(AUDIO_NTP)) >> $@
|
|
@printf "static const unsigned char gTestSfx[] = {\n" >> $@
|
|
@xxd -i < $(AUDIO_SFX) >> $@
|
|
@printf "};\nstatic const unsigned int gTestSfx_len = %d;\n" $$(wc -c < $(AUDIO_SFX)) >> $@
|
|
@echo "#endif" >> $@
|
|
|
|
AUDIO_HEADER_DEP := $(AUDIO_HEADER)
|
|
AUDIO_HEADER_FLAGS := -I $(dir $(AUDIO_HEADER))
|
|
else
|
|
$(info iigs: php-cli not installed -- AUDIO demo will embed raw .MOD bytes; install php-cli for real IIgs audio playback)
|
|
AUDIO_HEADER_DEP :=
|
|
AUDIO_HEADER_FLAGS :=
|
|
endif
|
|
|
|
$(AUDIO_BIN): $(AUDIO_SRC) $(LIB_SRCS_AUDIO) $(AUDIO_HEADER_DEP) $(IIGS_BUILD)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_BUILD) -b $(IIX_INCLUDES) $(AUDIO_HEADER_FLAGS) -I $(EXAMPLES)/audio -o $@ $(AUDIO_SRC) $(LIB_SRCS_AUDIO)
|
|
$(IIGS_IIX) chtyp -t S16 $@
|
|
|
|
# Assemble an 800KB ProDOS 2img containing the examples, ready to
|
|
# mount in GSplus alongside a GS/OS boot volume.
|
|
iigs-disk: $(DISK_IMG)
|
|
|
|
$(DISK_IMG): $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) $(NTP_BIN) $(IIGS_PACKAGE)
|
|
@mkdir -p $(dir $@)
|
|
$(IIGS_PACKAGE) $@ $(HELLO_BIN) $(PATTERN_BIN) $(KEYS_BIN) $(JOY_BIN) $(SPRITE_BIN) $(AUDIO_BIN) $(NTP_BIN)
|
|
|
|
clean-iigs:
|
|
rm -rf $(BUILD)
|