]> git.sur5r.net Git - cc65/blobdiff - samples/Makefile
Add mouse_setbox/mouse_getbox to the demo.
[cc65] / samples / Makefile
index de4814dc2ade6912a7f2aa52ffa0e63d400fea60..cd8079a2c8c6fec879249e4e357e6ae53c73b2ff 100644 (file)
@@ -7,12 +7,28 @@
 # Enter the target system here
 SYS    = c64
 
-CRT0           = ../libsrc/$(SYS).o
-CLIB   = ../libsrc/$(SYS).lib
-CC     = ../src/cc65/cc65
-CL     = ../src/cl65/cl65
-AS     = ../src/ca65/ca65
-LD     = ../src/ld65/ld65
+# Determine the path to the executables and libraries. If the samples
+# directory is part of a complete source tree, use the stuff from this
+# source tree, otherwise use the "official" directories.
+ifeq "$(wildcard ../src)" ""
+# No source tree
+CLIB = $(SYS).lib
+CL   = cl65
+CC   = cc65
+AS   = ca65
+LD   = ld65
+
+else
+# Samples is part of a complete source tree
+CLIB = ../libsrc/$(SYS).lib
+CL   = ../src/cl65/cl65
+CC   = ../src/cc65/cc65
+AS   = ../src/ca65/ca65
+LD   = ../src/ld65/ld65
+export CC65_INC = ../include
+endif
+
+# This one comes with VICE
 C1541          = c1541
 
 
@@ -21,7 +37,7 @@ C1541         = c1541
 
 .c.o:
        @echo $<
-       @$(CC) -Oirs -T --codesize 500 -g -t $(SYS) -I../include/ $<
+       @$(CC) -Oirs -T --forget-inc-paths --codesize 500 -g -t $(SYS) -I../include/ $<
        @$(AS) $(basename $<).s
 
 .s.o:
@@ -30,28 +46,86 @@ C1541       = c1541
 
 
 # --------------------------------------------------------------------------
-# Rules how to make each one of the binaries
+# List of executables. This list could be made target dependent by checking
+# $(SYS).
+
+EXELIST        =       ascii           \
+               diodemo         \
+               fire            \
+               gunzip65        \
+               hello           \
+               mousedemo       \
+               nachtm          \
+               plasma          \
+               sieve           \
+               tgidemo
 
-EXELIST=hello mousedemo nachtm plasma sieve
+# --------------------------------------------------------------------------
+# Rules how to make each one of the binaries
 
 .PHONY:        all
 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 $@ $^
-
-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 $@ $^
-
+ascii:                 ascii.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+diodemo:        diodemo.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+fire:                  fire.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+gunzip65:              gunzip65.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+hello:                 hello.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+# 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
+
+# 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:                nachtm.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
+
+plasma:                plasma.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+sieve:                 sieve.o $(CLIB)
+       @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
+
+# 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
@@ -61,22 +135,24 @@ sieve:     $(CRT0) sieve.o $(CLIB)
 disk:          samples.d64
 
 samples.d64:   all
-       $(C1541) -format samples,AA  d64 $@
-       for exe in $(EXELIST); do\
-           $(C1541) -attach $@ -write $$exe;\
-       done
-
+       @$(C1541) -format samples,AA  d64 $@ > /dev/null
+       @for exe in $(EXELIST); do\
+           $(C1541) -attach $@ -write $$exe > /dev/null;\
+       done;\
+       for tgi in ../libsrc/$(SYS)*.tgi; do\
+           $(C1541) -attach $@ -write $$tgi > /dev/null;\
+       done;
 
 # --------------------------------------------------------------------------
 # Cleanup rules
 
 .PHONY:        clean
 clean:
-       rm -f *~ *.map *.o *.s *.lbl
+       $(RM) *~ *.map *.o *.s *.lbl
 
 .PHONY:        zap
 zap:   clean
-       rm -f $(EXELIST) samples.d64
+       $(RM) $(EXELIST) samples.d64