75 lines
3.7 KiB
Makefile
75 lines
3.7 KiB
Makefile
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# Host-side tools for the JoeyLib asset pipeline.
|
|
#
|
|
# These build with the host's default `cc` (no cross-toolchain) into
|
|
# build/tools/ (JOEY_BUILD's, make/common.mk). Currently:
|
|
# modloopend -- inject an E8FF stop-marker pattern into a .MOD so
|
|
# the Amiga audio HAL can honor PlayMod(loop=false).
|
|
# joeymod invokes this transparently for Amiga output.
|
|
# spritebake -- the sprite pre-compiler, one per target (below).
|
|
#
|
|
# Asset baking (PNG -> .tbk / .spr) is handled by tools/assetbake/
|
|
# assetbake.py (Python). It is invoked directly from each platform's
|
|
# Makefile and does not need a C build step.
|
|
|
|
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
|
|
|
|
BUILD_DIR := $(JOEY_BUILD)/tools
|
|
TOOLS_DIR := $(REPO_DIR)/tools
|
|
|
|
MODLOOPEND_SRC := $(TOOLS_DIR)/modloopend/modloopend.c
|
|
MODLOOPEND_BIN := $(BUILD_DIR)/modloopend
|
|
|
|
# spritebake -- offline sprite pre-compiler. Built ONCE PER TARGET on the
|
|
# host: it links the shared staging (spriteStage.c) + that target's emitter,
|
|
# compiled with -DJOEYLIB_PLATFORM_<port> so JOEY_SPRITE_SHIFT_COUNT and the
|
|
# emitted machine code match the target while running on the host. Because
|
|
# the emitters use only fixed/gated compile-time constants, host output is
|
|
# byte-identical to the target JIT (see tools/spritebake/spritebake.c).
|
|
SPRITEBAKE_SRC := $(TOOLS_DIR)/spritebake/spritebake.c $(SRC_CG)/spriteStage.c
|
|
SPRITEBAKE_INC := -I$(INCLUDE_DIR) -I$(SRC_CORE) -I$(SRC_CG)
|
|
# The headers that carry the .spc format and the emitted-code ABI (a bump of
|
|
# SPC_MAGIC must rebuild every baker, or its .spc files would be refused).
|
|
SPRITEBAKE_HDRS := $(wildcard $(INCLUDE_DIR)/joey/*.h $(SRC_CORE)/*.h $(SRC_CG)/*.h)
|
|
|
|
.PHONY: all tools clean-tools modloopend \
|
|
spritebake-dos spritebake-amiga spritebake-atarist spritebake-iigs spritebake-x68000
|
|
all tools: $(MODLOOPEND_BIN)
|
|
modloopend: $(MODLOOPEND_BIN)
|
|
spritebake-dos: $(BUILD_DIR)/spritebake-dos
|
|
spritebake-amiga: $(BUILD_DIR)/spritebake-amiga
|
|
spritebake-atarist: $(BUILD_DIR)/spritebake-atarist
|
|
spritebake-iigs: $(BUILD_DIR)/spritebake-iigs
|
|
spritebake-x68000: $(BUILD_DIR)/spritebake-x68000
|
|
|
|
$(MODLOOPEND_BIN): $(MODLOOPEND_SRC)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) $< -o $@
|
|
|
|
$(BUILD_DIR)/spritebake-dos: $(SPRITEBAKE_SRC) $(SRC_X86)/spriteEmitX86.c $(SPRITEBAKE_HDRS)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) -DJOEYLIB_PLATFORM_DOS $(SPRITEBAKE_INC) -I$(SRC_X86) $(filter %.c,$^) -o $@
|
|
|
|
$(BUILD_DIR)/spritebake-amiga: $(SPRITEBAKE_SRC) $(SRC_68K)/spriteEmitPlanar68k.c $(SPRITEBAKE_HDRS)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) -DJOEYLIB_PLATFORM_AMIGA $(SPRITEBAKE_INC) -I$(SRC_DIR)/amiga -I$(SRC_68K) $(filter %.c,$^) -o $@
|
|
|
|
# The X68000 runs the Amiga's planar 68k emitter unchanged (see
|
|
# make/x68000.mk), so its bake is the same source under its own target byte.
|
|
$(BUILD_DIR)/spritebake-x68000: $(SPRITEBAKE_SRC) $(SRC_68K)/spriteEmitPlanar68k.c $(SPRITEBAKE_HDRS)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) -DJOEYLIB_PLATFORM_X68000 $(SPRITEBAKE_INC) -I$(SRC_DIR)/x68000 -I$(SRC_68K) $(filter %.c,$^) -o $@
|
|
|
|
$(BUILD_DIR)/spritebake-atarist: $(SPRITEBAKE_SRC) $(SRC_68K)/spriteEmitInterleaved68k.c $(SPRITEBAKE_HDRS)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) -DJOEYLIB_PLATFORM_ATARIST $(SPRITEBAKE_INC) -I$(SRC_DIR)/atarist -I$(SRC_68K) $(filter %.c,$^) -o $@
|
|
|
|
$(BUILD_DIR)/spritebake-iigs: $(SPRITEBAKE_SRC) $(SRC_DIR)/iigs/spriteEmitIigs.c $(SPRITEBAKE_HDRS)
|
|
@mkdir -p $(dir $@)
|
|
$(HOST_CC) $(HOST_CFLAGS) -DJOEYLIB_PLATFORM_IIGS $(SPRITEBAKE_INC) $(filter %.c,$^) -o $@
|
|
|
|
clean-tools:
|
|
rm -rf $(BUILD_DIR)
|