# shared facts. every toolchain and port includes this via the top Makefile. NAME := cc65-Chess SRCDIR := src BUILDDIR := build OBJDIR := $(BUILDDIR)/obj # a port is a name, not a cc65 target. toolchains and availability live elsewhere. PORT_NAMES := apple2 atari atmos c64 c64.chr plus4 cx16 rp6502 spectrum term mac68k ti99 coco3 agon archie mega65 amiga # built by a bare `make` when the compiler is present. rp6502 stays off this # list even if the picocomputer fork is installed — it was never a default. # spectrum joins in when zcc is on PATH. mac68k joins when Retro68 is found. # term is host-only: `make term`. DEFAULT_PORTS := apple2 atari atmos c64 c64.chr plus4 cx16 ENGINE_C := $(sort $(wildcard $(SRCDIR)/*.c)) ENGINE_S := $(sort $(wildcard $(SRCDIR)/*.s)) # emulator homes — prefixed to the binary, so an emulator that is not on # PATH can be reached by exporting one of these. `?=`, not `:=`: a plain # assignment here would win over the environment, which is exactly what it # used to do — `export VICE_HOME=...` was silently blanked and the recipe # fell back to a bare `xplus4`. The value is a prefix, so it needs its # trailing slash: VICE_HOME=/Applications/vice-arm64-gtk3-3.10/bin/ VICE_HOME ?= CX16_HOME ?= AWIN_HOME ?= ORIC_HOME ?= ATARI_HOME ?= RP6502_HOME ?= PREEMUCMD := POSTEMUCMD := STATEFILE := $(BUILDDIR)/.options COMMA := , SPACE := $(N/A) $(N/A) define NEWLINE endef # do not remove the two empty lines above # native win32 make + cmd.exe vs everyone else. same test as the oliver # schmidt makefile this replaced: `echo` with no args is empty on sh. ifeq ($(shell echo),) MKDIR = mkdir -p $1 RMDIR = rmdir $1 RMFILES = $(RM) $1 CP = cp $1 MV = mv WHICH = command -v $1 2>/dev/null NO_CONV = else MKDIR = mkdir $(subst /,\,$1) RMDIR = rmdir $(subst /,\,$1) RMFILES = $(if $1,del /f $(subst /,\,$1)) CP = copy $(subst /,\,$1) MV = ren WHICH = where $1 NO_CONV = endif # MSYS/Git Bash rewrites /cc65.Chess as a path. cadius needs the slash. ifneq ($(findstring sh,$(SHELL)),) NO_CONV = MSYS_NO_PATHCONV=1 endif LLVM_MOS_CC := $(if $(LLVM_MOS_SDK),$(LLVM_MOS_SDK)/bin/mos-mega65-clang,$(shell $(call WHICH,mos-mega65-clang))) HAVE_LLVM_MOS := $(if $(wildcard $(LLVM_MOS_CC)),1) CL65 := $(shell $(call WHICH,cl65)) ZCC := $(shell $(call WHICH,zcc)) Z88DK_APPMAKE := $(shell $(call WHICH,z88dk-appmake)) # Retro68 is usually not on PATH. RETRO68 may be the toolchain prefix # (…/toolchain) or the CMake build tree that contains it. both are # accepted RETRO68 ?= Retro68-build ifeq ($(wildcard $(RETRO68)/bin/m68k-apple-macos-gcc),) ifneq ($(wildcard $(RETRO68)/toolchain/bin/m68k-apple-macos-gcc),) RETRO68 := $(RETRO68)/toolchain else RETRO68_ON_PATH := $(shell $(call WHICH,m68k-apple-macos-gcc)) ifneq ($(RETRO68_ON_PATH),) RETRO68 := $(patsubst %/bin/m68k-apple-macos-gcc,%,$(RETRO68_ON_PATH)) endif endif endif RETRO68_CC := $(RETRO68)/bin/m68k-apple-macos-gcc RETRO68_REZ := $(RETRO68)/bin/Rez RETRO68_REZINC := $(RETRO68)/m68k-apple-macos/RIncludes HAVE_CL65 := $(if $(CL65),1) HAVE_ZCC := $(if $(ZCC),1) HAVE_CC := $(if $(shell $(call WHICH,$(CC))),1) HAVE_RETRO68 := $(if $(wildcard $(RETRO68)/bin/m68k-apple-macos-gcc),1) # tms9900-gcc. PATH first; otherwise the install this machine already has. TMS9900_GCC := $(shell $(call WHICH,tms9900-gcc)) ifeq ($(TMS9900_GCC),) TMS9900_HOME ?= $(HOME)/.local/share/tms9900-gcc ifneq ($(wildcard $(TMS9900_HOME)/bin/tms9900-gcc),) TMS9900_GCC := $(TMS9900_HOME)/bin/tms9900-gcc endif endif HAVE_TMS9900 := $(if $(TMS9900_GCC),1) # CMOC. PATH first; otherwise the install this machine already has. CMOC := $(shell $(call WHICH,cmoc)) ifeq ($(CMOC),) CMOC_HOME ?= $(HOME)/.local/share/cmaoc-0.1.100 ifneq ($(wildcard $(CMOC_HOME)/bin/cmoc),) CMOC := $(CMOC_HOME)/bin/cmoc endif endif HAVE_CMOC := $(if $(CMOC),1) # agondev. PATH first; otherwise the install this machine already has. AGONDEV_CONFIG := $(shell $(call WHICH,agondev-config)) ifeq ($(AGONDEV_CONFIG),) AGONDEV_HOME ?= /Volumes/EXTERNAL/ext-dev/agondev ifneq ($(wildcard $(AGONDEV_HOME)/bin/agondev-config),) AGONDEV_CONFIG := $(AGONDEV_HOME)/bin/agondev-config endif endif HAVE_AGONDEV := $(if $(AGONDEV_CONFIG),1) # ArchieSDK, the ARM2 / RISC OS toolchain also used by TimePilot-Archie. ARCHIESDK ?= $(HOME)/Develop/gitlab/archiesdk ARCHIE_CC := $(ARCHIESDK)/tools/bin/arm-archie-gcc HAVE_ARCHIE := $(if $(wildcard $(ARCHIE_CC)),1) # Bartman Abyss extension. the gcc and elf2hunk are arm64; the copy of # FS-UAE next to them is not, so the run recipe uses a different emulator. AMIGA_GCC ?= $(lastword $(sort $(wildcard $(HOME)/.vscode/extensions/bartmanabyss.amiga-debug-*/bin/darwin/opt/bin/m68k-amiga-elf-gcc))) AMIGA_ELF2HUNK ?= $(lastword $(sort $(wildcard $(HOME)/.vscode/extensions/bartmanabyss.amiga-debug-*/bin/darwin/elf2hunk))) HAVE_AMIGA := $(if $(and $(wildcard $(AMIGA_GCC)),$(wildcard $(AMIGA_ELF2HUNK))),1) # Fab Agon emulator. FAE_HOME is the install root, not a PATH prefix. FAE_HOME ?= $(HOME)/.local/share/fab-agon-emulator-v1.2.5-macos-arm64 ifeq ($(HAVE_CL65),1) CL65_TARGET_PATH := $(shell $(CL65) --print-target-path 2>/dev/null) HAVE_RP6502 := $(if $(wildcard $(CL65_TARGET_PATH)/rp6502),1) endif # leftover root names from before products lived in build/. zap removes them. ROOT_LEFTOVERS := \ cc65-Chess.apple2 cc65-Chess.atari cc65-Chess.atmos \ cc65-Chess.c64 cc65-Chess.c64.chr cc65-Chess.cx16 cc65-Chess.plus4 \ cc65-Chess.rp6502 \ cc65-Chess.po cc65-Chess.dsk cc65-Chess.atr cc65-Chess.tap \ cc65-Chess.d64 cc65-Chess-c64.prg cc65-Chess-chr.prg cc65-Chess-cx16.prg \ cc65-Chess-rp6502.rp6502 \ chess.po chess.system chess.system\#FF2000 chess\#064000 \ Makefile.options