joeylib2/make/tools.mk

56 lines
2.1 KiB
Makefile

# Host-side tools for the JoeyLib asset pipeline.
#
# These build with the host's default `cc` (no cross-toolchain) into
# build/tools/. Currently:
# joeyasset -- PPM (P6) -> .jas converter
# 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.
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
BUILD_DIR := $(REPO_DIR)/build/tools
TOOLS_DIR := $(REPO_DIR)/tools
HOST_CC ?= cc
HOST_CFLAGS := -std=c99 -Wall -Wextra -O2
JOEYASSET_SRC := $(TOOLS_DIR)/joeyasset/joeyasset.c
JOEYASSET_BIN := $(BUILD_DIR)/joeyasset
MODLOOPEND_SRC := $(TOOLS_DIR)/modloopend/modloopend.c
MODLOOPEND_BIN := $(BUILD_DIR)/modloopend
# joeysprite: pre-compiles tile data into a target-native .spr file
# at build time. Links all three per-CPU emitters and dispatches by
# --target argument. Same emitter source files the runtime uses, so
# the output bytes are identical to runtime spriteCompile output.
JOEYSPRITE_SRCS := \
$(TOOLS_DIR)/joeysprite/joeysprite.c \
$(REPO_DIR)/src/codegen/spriteEmitX86.c \
$(REPO_DIR)/src/codegen/spriteEmit68k.c \
$(REPO_DIR)/src/codegen/spriteEmitIigs.c
JOEYSPRITE_BIN := $(BUILD_DIR)/joeysprite
JOEYSPRITE_INC := -I$(REPO_DIR)/include -I$(REPO_DIR)/src/core -I$(REPO_DIR)/src/codegen
# The host tool doesn't have a real "target" -- it dispatches on
# --target at runtime. Define one of the platforms just to satisfy
# joey/platform.h's "exactly one defined" check; the choice doesn't
# affect output (JOEY_SPRITE_SHIFT_COUNT is 2 everywhere).
JOEYSPRITE_DEFS := -DJOEYLIB_PLATFORM_DOS
.PHONY: all tools clean-tools
all tools: $(JOEYASSET_BIN) $(MODLOOPEND_BIN) $(JOEYSPRITE_BIN)
$(JOEYASSET_BIN): $(JOEYASSET_SRC)
@mkdir -p $(dir $@)
$(HOST_CC) $(HOST_CFLAGS) $< -o $@
$(MODLOOPEND_BIN): $(MODLOOPEND_SRC)
@mkdir -p $(dir $@)
$(HOST_CC) $(HOST_CFLAGS) $< -o $@
$(JOEYSPRITE_BIN): $(JOEYSPRITE_SRCS)
@mkdir -p $(dir $@)
$(HOST_CC) $(HOST_CFLAGS) $(JOEYSPRITE_INC) $(JOEYSPRITE_DEFS) $^ -o $@
clean-tools:
rm -rf $(BUILD_DIR)