Original author: Pierre Sarrazin. Source: http://sarrazip.com/dev/color8-0.1.14.tar.gz Archive SHA-256: a98828720d91ac2b9c0939102bf5873650cd3df79323c7d6e086db9604546361
147 lines
3.7 KiB
Makefile
147 lines
3.7 KiB
Makefile
# Pass CARTRIDGE_ROM=1 to make to position the code and data for a
|
|
# ROM cartridge.
|
|
|
|
PACKAGE = color8
|
|
VERSION = 0.1.14
|
|
TARGET = coco
|
|
|
|
ifneq "$(TARGET)" "os9"
|
|
EXEEXT = .bin
|
|
endif
|
|
|
|
# Required libraries.
|
|
CARDGAME_LIB = cardgame
|
|
CARDGAME_LIB_DIR = ../cardgame
|
|
# BControl is only used by the OS-9 version.
|
|
BCONTROL_LIB = bcontrol
|
|
BCONTROL_LIB_DIR = ../bcontrol
|
|
|
|
# Main program.
|
|
SRC = $(PACKAGE).c
|
|
HEADERS =
|
|
LIBS = \
|
|
-L $(CARDGAME_LIB_DIR) -l$(CARDGAME_LIB) \
|
|
-L $(BCONTROL_LIB_DIR) -l$(BCONTROL_LIB)
|
|
DSK = $(PACKAGE)-$(VERSION)-$(TARGET).dsk
|
|
ROM = $(PACKAGE)-$(VERSION).rom
|
|
|
|
# Compilation and linking flags.
|
|
ifdef CARTRIDGE_ROM
|
|
BIN = $(ROM)
|
|
RAW = --raw # generate raw binary instead of .BIN format
|
|
ORG = --org=C000 --data=3800
|
|
CARTDEF = -DCARTRIDGE_ROM=1
|
|
NO_RELOCATE = --no-relocate
|
|
else
|
|
BIN = $(PACKAGE)$(EXEEXT)
|
|
RAW =
|
|
ifneq "$(TARGET)" "os9" # --org not permitted when targetting OS-9
|
|
ORG = --org=2800
|
|
endif
|
|
endif
|
|
|
|
INTERMEDIATE = #--intermediate
|
|
NDEBUG = -DNDEBUG
|
|
WARNINGS = -Wfor-condition-sizes
|
|
WERROR = -Werror
|
|
CFLAGS = --$(TARGET) $(WARNINGS) $(WERROR) $(NDEBUG) $(INTERMEDIATE) $(NO_RELOCATE) $(CARTDEF) \
|
|
-DVERSION=\"$(VERSION)\" \
|
|
-I $(CARDGAME_LIB_DIR) \
|
|
-I $(BCONTROL_LIB_DIR)
|
|
LDFLAGS = --$(TARGET) $(ORG) $(INTERMEDIATE) $(RAW)
|
|
|
|
OBJ = $(SRC:.c=.o)
|
|
|
|
DISTFILES = README COPYING Makefile $(SRC) $(HEADERS) autostart.c
|
|
|
|
# Tools.
|
|
CMOC = cmoc
|
|
PERL = perl
|
|
TAR = tar
|
|
WRITECOCOFILE = writecocofile
|
|
INSTALL_LOADER = install-coco-boot-loader
|
|
XROAR = xroar
|
|
OS9 = os9 # Toolshed
|
|
|
|
all: $(BIN)
|
|
|
|
# The executable only depends on libbcontrol.a if targeting OS-9.
|
|
ifeq "$(TARGET)" "os9"
|
|
BCONTROL_DEPS = $(BCONTROL_LIB_DIR)/lib$(BCONTROL_LIB).a
|
|
else
|
|
BCONTROL_DEPS =
|
|
endif
|
|
|
|
$(BIN): $(OBJ) $(CARDGAME_LIB_DIR)/lib$(CARDGAME_LIB).a $(BCONTROL_DEPS)
|
|
$(CMOC) -o $(BIN) $(LDFLAGS) $(OBJ) $(LIBS)
|
|
|
|
$(DSK): dsk
|
|
|
|
.PHONY: dsk
|
|
ifneq "$(TARGET)" "os9"
|
|
dsk: $(BIN) autostart.bin
|
|
$(PERL) -e 'print chr(255) x (35*18*256)' > $(DSK)
|
|
$(INSTALL_LOADER) $(DSK) autostart.bin
|
|
$(PERL) -Mstrict -e 'printf qq{\r0 PCLEAR4:LOADM"%s":EXEC\r}, uc("$(PACKAGE)")' > $(PACKAGE).bas
|
|
$(WRITECOCOFILE) --ascii $(DSK) $(PACKAGE).bas
|
|
rm $(PACKAGE).bas
|
|
$(WRITECOCOFILE) $(DSK) $(BIN)
|
|
else
|
|
dsk: $(BIN)
|
|
$(OS9) format $(DSK) -ds -t80 -e -9
|
|
$(OS9) copy $(BIN) $(DSK),
|
|
$(OS9) attr -q -epe $(DSK),/$(BIN)
|
|
endif
|
|
|
|
# Loader that goes on track 34 to be executed by the CoCo DOS command.
|
|
autostart.bin: autostart.c
|
|
$(CMOC) --dos -o $@ -D'COMMAND="PCLEAR4:LOADM\"$(PACKAGE)\":EXEC"' autostart.c
|
|
|
|
# Build a ROM file. This assumes a cleaned directory.
|
|
# The -f argument is the name of the current makefile.
|
|
#
|
|
# After compiling to a raw binary (not in .BIN format), we need to pad
|
|
# the binary with null bytes to make its length divisible by 256.
|
|
# This is apparently necessary to avoid a crash in XRoar (as of 0.35).
|
|
#
|
|
.PHONY: rom
|
|
rom:
|
|
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) CARTRIDGE_ROM=1 clean $(ROM)
|
|
$(PERL) -e 'print chr(0) x (256 - (-s "$(ROM)") % 256)' >> $(ROM)
|
|
|
|
# Have the XRoar CoCo 1/2 emulator run the ROM image.
|
|
.PHONY: run
|
|
run: rom
|
|
$(XROAR) -machine cocous -cart-autorun -cart $(ROM)
|
|
|
|
%.o: %.c
|
|
$(CMOC) -c $(CFLAGS) -o $@ $<
|
|
|
|
clean:
|
|
rm -f $(BIN) autostart.bin $(OBJ) $(ROM)
|
|
|
|
.PHONY: dist
|
|
dist:
|
|
$(TAR) -czf $(PACKAGE)-$(VERSION).tar.gz --transform 's,^,$(PACKAGE)-$(VERSION)/,' $(DISTFILES)
|
|
|
|
# Runs make with arguments $(RECURSION) in the library projects used by this package.
|
|
# Supports the -n (dry run) option.
|
|
# Example: make recurse RECURSION=clean
|
|
#
|
|
.PHONY: recurse
|
|
recurse:
|
|
$(MAKE) -C $(CARDGAME_LIB_DIR) TARGET=$(TARGET) $(RECURSION)
|
|
ifeq "$(TARGET)" "os9"
|
|
$(MAKE) -C $(BCONTROL_LIB_DIR) TARGET=$(TARGET) $(RECURSION)
|
|
endif
|
|
|
|
# Automatic prerequisite generation.
|
|
%.d: %.c
|
|
$(CMOC) --deps-only $(CFLAGS) $<
|
|
|
|
.PHONY: cleandeps
|
|
cleandeps:
|
|
rm -f $(SRC:.c=.d)
|
|
|
|
include $(SRC:.c=.d)
|