150 lines
5.8 KiB
Makefile
150 lines
5.8 KiB
Makefile
# Atari ST (m68k-atari-mint-gcc) build rules: JoeyLib's library for the ST,
|
|
# and programRules, the ST's rules for one program, which make/programs.mk
|
|
# instantiates for every program (a project reaches both through
|
|
# make/project.mk). JoeyLib's own examples and gates are at the end.
|
|
|
|
PLATFORM := atarist
|
|
include $(dir $(lastword $(MAKEFILE_LIST)))/common.mk
|
|
|
|
$(call requireTool,$(ST_CC),toolchain:atarist)
|
|
$(call requireTool,$(LIBXMP_DIR)/include/libxmp-lite/xmp.h,toolchain:atarist)
|
|
|
|
ST_SHIM := $(REPO_DIR)/make/support/atarist/include-shim
|
|
|
|
# so flag experiments never edit a tracked file (perf-hunt-2 rank 17).
|
|
CFLAGS := $(COMMON_CFLAGS) -m68000 -fomit-frame-pointer -I$(LIBXMP_DIR)/include -I$(ST_SHIM) -I$(SRC_DIR)/atarist -I$(SRC_68K) -MMD -MP
|
|
LDFLAGS :=
|
|
|
|
# libxmp-lite shared with the DOS port. Built as a static archive that
|
|
# provides the Protracker pattern decoder for the ST audio HAL; the
|
|
# 68k 4-channel mixer + YM2149 PWM output stage layer on top.
|
|
# LIBXMP_DIR comes from the installer's config.mk.
|
|
LIBXMP_SRC := $(filter-out %/win32.c, $(wildcard $(LIBXMP_DIR)/src/*.c) $(wildcard $(LIBXMP_DIR)/src/loaders/*.c))
|
|
LIBXMP_OBJDIR := $(BUILD)/obj/libxmp-lite
|
|
LIBXMP_OBJS := $(patsubst $(LIBXMP_DIR)/src/%.c,$(LIBXMP_OBJDIR)/%.o,$(LIBXMP_SRC)) $(LIBXMP_OBJDIR)/math_shim.o
|
|
LIBXMP_AR := $(LIBDIR)/libxmplite.a
|
|
# LIBXMP_CORE_DISABLE_IT skips the IT-format filter code so libxmp-lite
|
|
# doesn't reach for math.h / libm -- mintlib doesn't ship either. We
|
|
# target MOD as the authoring format anyway, so dropping IT filter
|
|
# support has no impact on JoeyLib's audio.
|
|
LIBXMP_CFLAGS := -DLIBXMP_CORE_PLAYER -DLIBXMP_CORE_DISABLE_IT -DHAVE_FNMATCH=0 -I$(LIBXMP_DIR)/include -I$(LIBXMP_DIR)/include/libxmp-lite -I$(LIBXMP_DIR)/src -Wno-error -w
|
|
|
|
PORT_C_SRCS := $(wildcard $(SRC_DIR)/atarist/*.c)
|
|
PORT_S_SRCS := $(wildcard $(SRC_DIR)/atarist/*.s)
|
|
SHARED_S := $(wildcard $(SRC_68K)/*.s)
|
|
|
|
# Sprite codegen: the ST-interleaved emitter (spriteEmitInterleaved68k.c)
|
|
# lives in src/m68k/ and builds into obj/68k/; only the CPU-independent
|
|
# dispatch stays in src/codegen.
|
|
CODEGEN_DIR := $(REPO_DIR)/src/codegen
|
|
|
|
LIB_OBJS := \
|
|
$(patsubst $(SRC_CORE)/%.c,$(BUILD)/obj/core/%.o,$(CORE_C_SRCS)) \
|
|
$(patsubst $(SRC_DIR)/generic/%.c,$(BUILD)/obj/generic/%.o,$(GENERIC_C_SRCS)) \
|
|
$(patsubst $(SRC_DIR)/atarist/%.c,$(BUILD)/obj/port/%.o,$(PORT_C_SRCS)) \
|
|
$(patsubst $(SRC_DIR)/atarist/%.s,$(BUILD)/obj/port/%.o,$(PORT_S_SRCS)) \
|
|
$(patsubst $(SRC_68K)/%.s,$(BUILD)/obj/68k/%.o,$(SHARED_S)) \
|
|
$(BUILD)/obj/68k/spriteEmitInterleaved68k.o \
|
|
$(BUILD)/obj/codegen/spriteCompile.o \
|
|
$(BUILD)/obj/codegen/spriteStage.o
|
|
|
|
LIB := $(LIBDIR)/libjoey.a
|
|
|
|
$(BUILD)/obj/core/%.o: $(SRC_CORE)/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(BUILD)/obj/generic/%.o: $(SRC_DIR)/generic/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(BUILD)/obj/port/%.o: $(SRC_DIR)/atarist/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
# Hand-written 68k assembly: GAS syntax, fed through the gcc driver
|
|
# so the bundled m68k-atari-mint-as (binutils) does the work. No vasm
|
|
# dependency on the ST path.
|
|
$(BUILD)/obj/port/%.o: $(SRC_DIR)/atarist/%.s
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(BUILD)/obj/68k/%.o: $(SRC_68K)/%.s
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
# 68k sprite emitters (spriteEmitInterleaved68k.c) live in src/m68k/;
|
|
# -I$(CODEGEN_DIR) lets them resolve spriteEmitter.h.
|
|
$(BUILD)/obj/68k/%.o: $(SRC_68K)/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -I$(CODEGEN_DIR) -c $< -o $@
|
|
|
|
$(BUILD)/obj/codegen/%.o: $(CODEGEN_DIR)/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -I$(CODEGEN_DIR) -c $< -o $@
|
|
|
|
# Archived from scratch, so the members -- and every program's layout --
|
|
# follow LIB_OBJS rather than the order earlier builds added them in.
|
|
$(LIB): $(LIB_OBJS)
|
|
@mkdir -p $(dir $@)
|
|
rm -f $@
|
|
$(ST_AR) rcs $@ $^
|
|
|
|
$(LIBXMP_OBJDIR)/%.o: $(LIBXMP_DIR)/src/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) $(LIBXMP_CFLAGS) -c $< -o $@
|
|
|
|
$(LIBXMP_OBJDIR)/math_shim.o: $(ST_SHIM)/math_shim.c
|
|
@mkdir -p $(dir $@)
|
|
$(ST_CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(LIBXMP_AR): $(LIBXMP_OBJS)
|
|
@mkdir -p $(dir $@)
|
|
rm -f $@
|
|
$(ST_AR) rcs $@ $^
|
|
|
|
# Pull in per-object header-dependency files generated by gcc -MMD/-MP.
|
|
# Without this, editing a header (e.g. surfaceInternal.h) doesn't rebuild
|
|
# the .c files that include it, leaving a frankenstein binary where
|
|
# different TUs see different struct layouts.
|
|
-include $(LIB_OBJS:.o=.d)
|
|
|
|
# ---- programs -----------------------------------------------------------------
|
|
# A program is NAME.PRG, in bin/ or in its own bin/NAME/ with its DATA beside
|
|
# it, where Hatari's GEMDOS drive (bin/ or the folder as C:) finds both.
|
|
PROGRAM_EXT := .PRG
|
|
PROGRAM_FOLDERS := yes
|
|
|
|
# One program, $(1) its id: compiled and linked in one step with the library
|
|
# and libxmp-lite. gcc's -MMD leaves NAME.d beside it, for header edits.
|
|
define programRules
|
|
$(call programBin,$(1)): $(call programVar,$(1),SRCS) $(LIB) $(LIBXMP_AR)
|
|
@mkdir -p $$(dir $$@)
|
|
$(ST_CC) $(CFLAGS) $(call programVar,$(1),CFLAGS) $(call programVar,$(1),SRCS) $(LIB) $(LIBXMP_AR) -o $$@ $(LDFLAGS) $(call programVar,$(1),LDFLAGS)
|
|
-include $(basename $(call programBin,$(1))).d
|
|
endef
|
|
|
|
# ---- JoeyLib's own build: its examples and the ST gates -------------------------
|
|
ifndef JOEY_PROJECT
|
|
|
|
include $(REPO_DIR)/make/examples.mk
|
|
include $(REPO_DIR)/make/programs.mk
|
|
|
|
.DEFAULT_GOAL := all
|
|
.PHONY: all atarist clean-atarist clean atarist-dirtymark atarist-verify-dirtymark
|
|
all atarist: $(LIB) $(LIBXMP_AR) programs
|
|
|
|
atarist-dirtymark: $(call programBin,DIRTYMRK)
|
|
|
|
atarist-verify-dirtymark: $(call programBin,DIRTYMRK)
|
|
$(REPO_DIR)/scripts/verify-atarist-dirtymark.sh
|
|
|
|
clean-atarist:
|
|
rm -rf $(BUILD)
|
|
|
|
# `clean` as an alias for `clean-atarist`. Without it a bare
|
|
# `make -f make/atarist.mk clean` FAILS -- and with stderr discarded that
|
|
# looks like success while leaving stale objects the next build links.
|
|
clean: clean-atarist
|
|
|
|
endif
|