#
# Makefile for cc65 samples
#
+# This Makefile requires GNU make
+#
# Enter the target system here
SYS = c64
-CRT0 = ../lib/$(SYS).o
-CLIB = ../lib/$(SYS).lib
-CC = ../cc65/cc65
-CL = ../cl65/cl65
-AS = ../binutils/ca65/ca65
-LD = ../binutils/ld65/ld65
+CRT0 = ../libsrc/$(SYS).o
+CLIB = ../libsrc/$(SYS).lib
+CC = ../src/cc65/cc65
+CL = ../src/cl65/cl65
+AS = ../src/ca65/ca65
+LD = ../src/ld65/ld65
C1541 = c1541
+# --------------------------------------------------------------------------
+# Generic rules
+
.c.o:
@echo $<
- @$(CL) -c -Oirs -t $(SYS) -I../include/ $<
+ @$(CC) -Oirs -T --codesize 500 -g -t $(SYS) -I../include/ $<
+ @$(AS) $(basename $<).s
.s.o:
@echo $<
- @$(CL) -c $(basename $<).s
+ @$(AS) $(basename $<).s
+
+
+# --------------------------------------------------------------------------
+# Rules how to make each one of the binaries
+EXELIST=hello mousedemo nachtm plasma sieve
.PHONY: all
-all: nachtm hello sieve
+all: $(EXELIST)
+
+hello: $(CRT0) hello.o $(CLIB)
+ @$(LD) -t $(SYS) -m hello.map -Ln hello.lbl -o $@ $^
+
+mousedemo: $(CRT0) mousedemo.o $(CLIB)
+ @$(LD) -t $(SYS) -m mousedemo.map -Ln mousedemo.lbl -o $@ $^
nachtm: $(CRT0) nachtm.o $(CLIB)
@$(LD) -t $(SYS) -m nachtm.map -Ln nachtm.lbl -o $@ $^
-hello: $(CRT0) hello.o $(CLIB)
- @$(LD) -t $(SYS) -m hello.map -Ln hello.lbl -o $@ $^
+plasma: $(CRT0) plasma.o $(CLIB)
+ @$(LD) -t $(SYS) -m nachtm.map -Ln nachtm.lbl -o $@ $^
sieve: $(CRT0) sieve.o $(CLIB)
@$(LD) -t $(SYS) -m sieve.map -Ln sieve.lbl -o $@ $^
+
+# --------------------------------------------------------------------------
+# Rule to make a disk with all samples. Needs the c1541 program that comes
+# with the VICE emulator.
+
.PHONY: disk
-disk: c64.d64
+disk: samples.d64
+
+samples.d64: all
+ $(C1541) -format samples,AA d64 $@
+ for exe in $(EXELIST); do\
+ $(C1541) -attach $@ -write $$exe;\
+ done
+
-c64.d64: all
- $(C1541) < c1541.rsp
+# --------------------------------------------------------------------------
+# Cleanup rules
.PHONY: clean
clean:
.PHONY: zap
zap: clean
- rm -f nachtm hello
+ rm -f $(EXELIST) samples.d64