# source tree, otherwise use the "official" directories.
ifeq "$(wildcard ../src)" ""
# No source tree
-CRT0 = $(SYS).o
CLIB = $(SYS).lib
CL = cl65
CC = cc65
-AS = as65
+AS = ca65
LD = ld65
else
# Samples is part of a complete source tree
-CRT0 = ../libsrc/$(SYS).o
CLIB = ../libsrc/$(SYS).lib
CL = ../src/cl65/cl65
CC = ../src/cc65/cc65
# $(SYS).
EXELIST = ascii \
- diodemo \
- fire \
- gunzip65 \
- hello \
- mousedemo \
- nachtm \
- plasma \
- sieve \
- tgidemo
+ diodemo \
+ fire \
+ gunzip65 \
+ hello \
+ mousedemo \
+ nachtm \
+ plasma \
+ sieve \
+ tgidemo
# --------------------------------------------------------------------------
# Rules how to make each one of the binaries
.PHONY: all
all: $(EXELIST)
-ascii: $(CRT0) ascii.o $(CLIB)
+ascii: ascii.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-diodemo: $(CRT0) diodemo.o $(CLIB)
+diodemo: diodemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-fire: $(CRT0) fire.o $(CLIB)
+fire: fire.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-gunzip65: $(CRT0) gunzip65.o $(CLIB)
+gunzip65: gunzip65.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-hello: $(CRT0) hello.o $(CLIB)
+hello: hello.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-mandelbrot: $(CRT0) mandelbrot.o $(CLIB)
+# The Apple machines need the start address adjusted for the mandelbrot demo
+ifeq "$(SYS)" "apple2"
+mandelbrot: mandelbrot.o $(CLIB)
+ @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
+else
+ifeq "$(SYS)" "apple2enh"
+mandelbrot: mandelbrot.o $(CLIB)
+ @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
+else
+mandelbrot: mandelbrot.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+endif
+endif
-mousedemo: $(CRT0) mousedemo.o $(CLIB)
+# The Apple ][ needs the start address adjusted for the mousedemo
+ifeq "$(SYS)" "apple2"
+mousedemo: mousedemo.o $(CLIB)
+ @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
+else
+mousedemo: mousedemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+endif
-nachtm: $(CRT0) nachtm.o $(CLIB)
+nachtm: nachtm.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
-plasma: $(CRT0) plasma.o $(CLIB)
+plasma: plasma.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-sieve: $(CRT0) sieve.o $(CLIB)
+sieve: sieve.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-tgidemo: $(CRT0) tgidemo.o $(CLIB)
+# The Apple machines need the start address adjusted for the tgidemo
+ifeq "$(SYS)" "apple2"
+tgidemo: tgidemo.o $(CLIB)
+ @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
+else
+ifeq "$(SYS)" "apple2enh"
+tgidemo: tgidemo.o $(CLIB)
+ @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
+else
+tgidemo: tgidemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
-
+endif
+endif
# --------------------------------------------------------------------------
# Rule to make a disk with all samples. Needs the c1541 program that comes