]> git.sur5r.net Git - cc65/blobdiff - samples/Makefile
samples zip and install targets moved into samples/Makefile as agreed
[cc65] / samples / Makefile
index a17288ced8b4233dc0126a8cfa50ca01856fd953..d9b51e827a6ba3269d142839bdb921a556628a06 100644 (file)
@@ -12,16 +12,19 @@ SYS = c64
 # source tree; otherwise, use the "install" directories.
 ifeq "$(wildcard ../src)" ""
 # No source tree
-MOUS = /usr/lib/cc65/mou/$(SYS)*.mou
-TGI  = /usr/lib/cc65/tgi/$(SYS)*.tgi
+installdir = /usr/lib/cc65
 ifneq "$(wildcard /usr/local/lib/cc65)" ""
-MOUS = /usr/local/lib/cc65/mou/$(SYS)*.mou
-TGI  = /usr/local/lib/cc65/tgi/$(SYS)*.tgi
+installdir = /usr/local/lib/cc65
+endif
+ifneq "$(wildcard /opt/local/share/cc65)" ""
+installdir = /opt/local/share/cc65
 endif
 ifdef CC65_HOME
-MOUS = $(CC65_HOME)/mou/$(SYS)*.mou
-TGI  = $(CC65_HOME)/tgi/$(SYS)*.tgi
+installdir = $(CC65_HOME)
 endif
+
+MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou
+TGI  = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi
 CLIB = --lib $(SYS).lib
 CL   = cl65
 CC   = cc65
@@ -31,8 +34,8 @@ LD   = ld65
 else
 # "samples/" is a part of a complete source tree.
 export CC65_HOME := $(abspath ..)
-MOUS = ../mou/$(SYS)*.mou
-TGI  = ../tgi/$(SYS)*.tgi
+MOUS = ../target/$(SYS)/drv/mou/$(SYS)*.mou
+TGI  = ../target/$(SYS)/drv/tgi/$(SYS)*.tgi
 CLIB = ../lib/$(SYS).lib
 CL   = ../bin/cl65
 CC   = ../bin/cc65
@@ -43,6 +46,25 @@ endif
 # This one comes with VICE
 C1541  = c1541
 
+# --------------------------------------------------------------------------
+# System-dependent settings
+
+# The Apple machines need the start address adjusted when using TGI
+LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
+LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
+
+# The Apple ][ needs the start address adjusted for the mousetest
+LDFLAGS_mousetest_apple2 = --start-addr 0x4000
+
+# The atarixl target needs the start address adjusted when using TGI
+LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
+LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
+
+# The atari target needs to reserve some memory when using TGI
+LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
+LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
 
 # --------------------------------------------------------------------------
 # Generic rules
@@ -59,12 +81,13 @@ C1541       = c1541
        @echo $<
        @$(AS) $(AFLAGS) -t $(SYS) $<
 
-.o:
-       @$(LD) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
+.PRECIOUS: %.o
 
+.o:
+       @$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
 
 # --------------------------------------------------------------------------
-# List of executables. This list could be made target dependent by checking
+# List of executables. This list could be made target-dependent by checking
 # $(SYS).
 
 EXELIST        =       ascii           \
@@ -83,69 +106,26 @@ EXELIST    =       ascii           \
                tgidemo
 
 # --------------------------------------------------------------------------
-# Rules how to make each one of the binaries
+# Rules to make the binaries
 
-.PHONY:        all
-all:   $(EXELIST)
+.PHONY: all samples
+all:
 
-ascii:         ascii.o
-
-diodemo:       diodemo.o
-
-fire:          fire.o
-
-gunzip65:      gunzip65.o
-
-hello:         hello.o
-
-# The Apple machines need the start address adjusted for the mandelbrot demo
-ifeq "$(SYS)" "apple2"
-mandelbrot:    mandelbrot.o
-       @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-mandelbrot:    mandelbrot.o
-       @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-mandelbrot:    mandelbrot.o
-endif
-endif
+samples:
+       $(EXELIST)
 
-# The Apple ][ needs the start address adjusted for the mousetest
-ifeq "$(SYS)" "apple2"
-mousetest:     mousetest.o
-       @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-mousetest:     mousetest.o
-endif
+# --------------------------------------------------------------------------
+# Overlay rules. Overlays need special ld65 configuration files.  Also, the
+# overlay file-names are shortenned to fit the Atari's 8.3-character limit.
 
 multdemo:      multidemo.o
-       @$(LD) -o $@ -m $@.map -C $(SYS)-overlay.cfg $^ $(CLIB)
-
-nachtm:                nachtm.o
+       @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
 
 ovrldemo:      overlaydemo.o
-       @$(LD) -o $@ -m $@.map -C $(SYS)-overlay.cfg $^ $(CLIB)
-
-plasma:                plasma.o
-
-sieve:         sieve.o
-
-# The Apple machines need the start address adjusted for the tgidemo
-ifeq "$(SYS)" "apple2"
-tgidemo:       tgidemo.o
-       @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-tgidemo:       tgidemo.o
-       @$(LD) -o $@ -t $(SYS) -m $@.map --start-addr 0x4000 $^ $(CLIB)
-else
-tgidemo:       tgidemo.o
-endif
-endif
+       @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
 
 # --------------------------------------------------------------------------
-# Rule to make a 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.
 
 .PHONY:        disk
@@ -161,7 +141,34 @@ samples.d64:       all
        done
 
 # --------------------------------------------------------------------------
-# Cleanup rules
+# Installation rules
+
+INSTALL = install
+samplesdir = $(prefix)/share/cc65
+.PHONY:        install
+install:
+       $(if $(prefix),,$(error variable `prefix' must be set))
+       $(INSTALL) -d $(DESTDIR)$(samplesdir)
+       $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
+       $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial
+       $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir)
+       $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir)
+       $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir)
+       $(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos
+       $(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial
+
+# --------------------------------------------------------------------------
+# Packaging rules
+
+.PHONY:        zip
+zip:
+       @cd .. && zip -r cc65 samples/
+
+# --------------------------------------------------------------------------
+# Clean-up rules
+
+.PHONY:        mostlyclean
+mostlyclean:
 
 .PHONY:        clean
 clean:
@@ -170,3 +177,4 @@ clean:
 .PHONY:        zap
 zap:   clean
        $(RM) $(EXELIST) samples.d64
+       $(RM) multdemo.? ovrldemo.?