Made Makefile actually work.
Supported target systems: * c64 (default) * apple2 * apple2enh * atari * atarixl
This commit is contained in:
177
samples/Makefile
177
samples/Makefile
@@ -4,7 +4,7 @@
|
|||||||
# This Makefile requires GNU make
|
# This Makefile requires GNU make
|
||||||
#
|
#
|
||||||
|
|
||||||
# Enter the target system here
|
# Run 'make samples SYS=<target>' to build for another target system
|
||||||
SYS = c64
|
SYS = c64
|
||||||
|
|
||||||
ifneq ($(shell echo),)
|
ifneq ($(shell echo),)
|
||||||
@@ -14,74 +14,74 @@ endif
|
|||||||
ifdef CMD_EXE
|
ifdef CMD_EXE
|
||||||
NULLDEV = nul:
|
NULLDEV = nul:
|
||||||
DEL = -del /f
|
DEL = -del /f
|
||||||
|
RMDIR = rmdir /s /q
|
||||||
else
|
else
|
||||||
NULLDEV = /dev/null
|
NULLDEV = /dev/null
|
||||||
DEL = $(RM)
|
DEL = $(RM)
|
||||||
|
RMDIR = $(RM) -r
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Determine the path to the executables and libraries. If the samples
|
|
||||||
# directory is part of a complete source tree, use the stuff from that
|
|
||||||
# source tree; otherwise, use the "install" directories.
|
|
||||||
ifeq "$(wildcard ../src)" ""
|
|
||||||
# No source tree
|
|
||||||
installdir = /usr/lib/cc65
|
|
||||||
ifneq "$(wildcard /usr/local/lib/cc65)" ""
|
|
||||||
installdir = /usr/local/lib/cc65
|
|
||||||
endif
|
|
||||||
ifneq "$(wildcard /opt/local/share/cc65)" ""
|
|
||||||
installdir = /opt/local/share/cc65
|
|
||||||
endif
|
|
||||||
ifdef CC65_HOME
|
ifdef CC65_HOME
|
||||||
installdir = $(CC65_HOME)
|
AS = $(CC65_HOME)/bin/ca65
|
||||||
endif
|
CC = $(CC65_HOME)/bin/cc65
|
||||||
|
CL = $(CC65_HOME)/bin/cl65
|
||||||
MOUS := $(wildcard $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou)
|
LD = $(CC65_HOME)/bin/ld65
|
||||||
TGI := $(wildcard $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi)
|
|
||||||
CLIB = --lib $(SYS).lib
|
|
||||||
CL = cl65
|
|
||||||
CC = cc65
|
|
||||||
AS = ca65
|
|
||||||
LD = ld65
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# "samples/" is a part of a complete source tree.
|
AS := $(if $(wildcard ../bin/ca65*),../bin/ca65,ca65)
|
||||||
export CC65_HOME := $(abspath ..)
|
CC := $(if $(wildcard ../bin/cc65*),../bin/cc65,cc65)
|
||||||
MOUS := $(wildcard ../target/$(SYS)/drv/mou/$(SYS)*.mou)
|
CL := $(if $(wildcard ../bin/cl65*),../bin/cl65,cl65)
|
||||||
TGI := $(wildcard ../target/$(SYS)/drv/tgi/$(SYS)*.tgi)
|
LD := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65)
|
||||||
CLIB = ../lib/$(SYS).lib
|
|
||||||
CL = ../bin/cl65
|
|
||||||
CC = ../bin/cc65
|
|
||||||
AS = ../bin/ca65
|
|
||||||
LD = ../bin/ld65
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
TARGET_PATH := $(shell $(CL) --print-target-path)
|
||||||
|
|
||||||
|
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
|
||||||
|
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
|
||||||
|
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
|
||||||
|
|
||||||
# This one comes with VICE
|
# This one comes with VICE
|
||||||
C1541 ?= c1541
|
C1541 ?= c1541
|
||||||
|
|
||||||
|
# For this one see http://applecommander.sourceforge.net/
|
||||||
|
AC ?= ac.jar
|
||||||
|
|
||||||
|
# For this one see http://www.horus.com/~hias/atari/
|
||||||
|
DIR2ATR ?= dir2atr
|
||||||
|
|
||||||
|
DISK_c64 = samples.d64
|
||||||
|
DISK_apple2 = samples.dsk
|
||||||
|
DISK_apple2enh = samples.dsk
|
||||||
|
DISK_atari = samples.atr
|
||||||
|
DISK_atarixl = samples.atr
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# System-dependent settings
|
# System-dependent settings
|
||||||
|
|
||||||
# The Apple machines need the start address adjusted when using TGI
|
# The Apple machines need the start address adjusted when using TGI
|
||||||
LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
|
LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
|
||||||
LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
|
|
||||||
LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
|
LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
|
||||||
|
LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
|
||||||
LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
|
LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
|
||||||
|
|
||||||
# The Apple ][ needs the start address adjusted for the mousetest
|
# The Apple ][ needs the start address adjusted for the mousetest
|
||||||
LDFLAGS_mousetest_apple2 = --start-addr 0x4000
|
LDFLAGS_mousetest_apple2 = --start-addr 0x4000
|
||||||
|
|
||||||
# The atarixl target needs the start address adjusted when using TGI
|
# The Apple machines need the end address adjusted for large programs
|
||||||
LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
|
LDFLAGS_gunzip65_apple2 = -D __HIMEM__=0xBF00
|
||||||
LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
|
LDFLAGS_gunzip65_apple2enh = -D __HIMEM__=0xBF00
|
||||||
|
|
||||||
# The atari target needs to reserve some memory when using TGI
|
# The atari target needs to reserve some memory when using TGI
|
||||||
LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
|
LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
|
||||||
LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
|
LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
|
||||||
|
|
||||||
|
# The atarixl target needs the start address adjusted when using TGI
|
||||||
|
LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
|
||||||
|
LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Generic rules
|
# Generic rules
|
||||||
|
|
||||||
.PHONY: all mostlyclean clean install zip samples d64
|
.PHONY: all mostlyclean clean install zip samples disk
|
||||||
|
|
||||||
%: %.c
|
%: %.c
|
||||||
%: %.s
|
%: %.s
|
||||||
@@ -96,14 +96,13 @@ LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
|
|||||||
.PRECIOUS: %.o
|
.PRECIOUS: %.o
|
||||||
|
|
||||||
.o:
|
.o:
|
||||||
$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
|
$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# List of executables. This list could be made target-dependent by checking
|
# List of executables
|
||||||
# $(SYS).
|
|
||||||
|
|
||||||
EXELIST = ascii \
|
EXELIST_c64 = \
|
||||||
diodemo \
|
ascii \
|
||||||
enumdevdir \
|
enumdevdir \
|
||||||
fire \
|
fire \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
@@ -117,22 +116,52 @@ EXELIST = ascii \
|
|||||||
sieve \
|
sieve \
|
||||||
tgidemo
|
tgidemo
|
||||||
|
|
||||||
|
EXELIST_apple2 = \
|
||||||
|
ascii \
|
||||||
|
diodemo \
|
||||||
|
enumdevdir \
|
||||||
|
gunzip65 \
|
||||||
|
hello \
|
||||||
|
mandelbrot \
|
||||||
|
mousetest \
|
||||||
|
multdemo \
|
||||||
|
ovrldemo \
|
||||||
|
sieve \
|
||||||
|
tgidemo
|
||||||
|
|
||||||
|
EXELIST_apple2enh = $(EXELIST_apple2)
|
||||||
|
|
||||||
|
EXELIST_atari = \
|
||||||
|
ascii \
|
||||||
|
gunzip65 \
|
||||||
|
hello \
|
||||||
|
mandelbrot \
|
||||||
|
mousetest \
|
||||||
|
multdemo \
|
||||||
|
ovrldemo \
|
||||||
|
sieve \
|
||||||
|
tgidemo
|
||||||
|
|
||||||
|
EXELIST_atarixl = $(EXELIST_atari)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Rules to make the binaries
|
# Rules to make the binaries and the disk
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
samples: $(EXELIST)
|
samples: $(EXELIST_$(SYS))
|
||||||
|
|
||||||
|
disk: $(DISK_$(SYS))
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Overlay rules. Overlays need special ld65 configuration files. Also, the
|
# Overlay rules. Overlays need special ld65 configuration files. Also, the
|
||||||
# overlay file-names are shortenned to fit the Atari's 8.3-character limit.
|
# overlay file-names are shortenned to fit the Atari's 8.3-character limit.
|
||||||
|
|
||||||
multdemo: multidemo.o
|
multdemo: multidemo.o
|
||||||
$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
|
$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib
|
||||||
|
|
||||||
ovrldemo: overlaydemo.o
|
ovrldemo: overlaydemo.o
|
||||||
$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
|
$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib
|
||||||
|
|
||||||
OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I)
|
OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I)
|
||||||
|
|
||||||
@@ -140,8 +169,6 @@ OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I)
|
|||||||
# Rule to make a CBM disk with all samples. Needs the c1541 program that comes
|
# Rule to make a CBM disk with all samples. Needs the c1541 program that comes
|
||||||
# with the VICE emulator.
|
# with the VICE emulator.
|
||||||
|
|
||||||
d64: samples.d64
|
|
||||||
|
|
||||||
define D64_WRITE_recipe
|
define D64_WRITE_recipe
|
||||||
|
|
||||||
$(C1541) -attach $@ -write $(file) $(notdir $(file)) >$(NULLDEV)
|
$(C1541) -attach $@ -write $(file) $(notdir $(file)) >$(NULLDEV)
|
||||||
@@ -150,9 +177,55 @@ endef # D64_WRITE_recipe
|
|||||||
|
|
||||||
samples.d64: samples
|
samples.d64: samples
|
||||||
@$(C1541) -format samples,AA d64 $@ >$(NULLDEV)
|
@$(C1541) -format samples,AA d64 $@ >$(NULLDEV)
|
||||||
$(foreach file,$(EXELIST),$(D64_WRITE_recipe))
|
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_recipe))
|
||||||
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_recipe))
|
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_recipe))
|
||||||
$(foreach file,$(TGI) $(MOUS),$(D64_WRITE_recipe))
|
$(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_recipe))
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Rule to make an Apple II disk with all samples. Needs the Apple Commander
|
||||||
|
# program available at http://applecommander.sourceforge.net/ and a template
|
||||||
|
# disk named 'prodos.dsk'.
|
||||||
|
|
||||||
|
define DSK_WRITE_BIN_recipe
|
||||||
|
|
||||||
|
$(if $(findstring BF00,$(LDFLAGS_$(notdir $(file))_$(SYS))), \
|
||||||
|
java -jar $(AC) -p $@ $(notdir $(file)).system sys <$(TARGET_PATH)/$(SYS)/util/loader.system)
|
||||||
|
java -jar $(AC) -cc65 $@ $(notdir $(file)) bin <$(file)
|
||||||
|
|
||||||
|
endef # DSK_WRITE_BIN_recipe
|
||||||
|
|
||||||
|
define DSK_WRITE_REL_recipe
|
||||||
|
|
||||||
|
java -jar $(AC) -p $@ $(notdir $(file)) rel 0 <$(file)
|
||||||
|
|
||||||
|
endef # DSK_WRITE_REL_recipe
|
||||||
|
|
||||||
|
samples.dsk: samples
|
||||||
|
cp prodos.dsk $@
|
||||||
|
$(foreach file,$(EXELIST_$(SYS)),$(DSK_WRITE_BIN_recipe))
|
||||||
|
$(foreach file,$(OVERLAYLIST),$(DSK_WRITE_REL_recipe))
|
||||||
|
$(foreach file,$(EMD) $(MOU) $(TGI),$(DSK_WRITE_REL_recipe))
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Rule to make an Atari disk with all samples. Needs the dir2atr program
|
||||||
|
# available at http://www.horus.com/~hias/atari/ and the MyDos4534 variant
|
||||||
|
# of dos.sys and dup.sys.
|
||||||
|
|
||||||
|
define ATR_WRITE_recipe
|
||||||
|
|
||||||
|
cp $(file) atr/$(notdir $(file))
|
||||||
|
|
||||||
|
endef # ATR_WRITE_recipe
|
||||||
|
|
||||||
|
samples.atr: samples
|
||||||
|
@mkdir atr
|
||||||
|
cp dos.sys atr/dos.sys
|
||||||
|
cp dup.sys atr/dup.sys
|
||||||
|
@$(foreach file,$(EXELIST_$(SYS)),$(ATR_WRITE_recipe))
|
||||||
|
@$(foreach file,$(OVERLAYLIST),$(ATR_WRITE_recipe))
|
||||||
|
@$(foreach file,$(EMD) $(MOU) $(TGI),$(ATR_WRITE_recipe))
|
||||||
|
$(DIR2ATR) -d -b MyDos4534 3200 $@ atr
|
||||||
|
@$(RMDIR) atr
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Installation rules
|
# Installation rules
|
||||||
@@ -184,5 +257,5 @@ mostlyclean:
|
|||||||
@$(DEL) *.map *.o *.s 2>$(NULLDEV)
|
@$(DEL) *.map *.o *.s 2>$(NULLDEV)
|
||||||
|
|
||||||
clean: mostlyclean
|
clean: mostlyclean
|
||||||
@$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV)
|
@$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV)
|
||||||
@$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV)
|
@$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV)
|
||||||
|
|||||||
Reference in New Issue
Block a user