]> git.sur5r.net Git - cc65/blobdiff - samples/Makefile
Merge pull request #283 from polluks/sp65
[cc65] / samples / Makefile
index a5bf9acefe3ae8fe2697176a87194c43e3e26a55..951706ce6a50c674e1f670b2ae8b7f5065886149 100644 (file)
@@ -30,121 +30,100 @@ LD   = ld65
 
 else
 # "samples/" is a part of a complete source tree.
-CA65_INC = ../asminc
-CC65_INC = ../include
-LD65_CFG = ../src/ld65/cfg
-LD65_LIB = ../libsrc
-LD65_OBJ = ../libsrc
-MOUS = ../libsrc/$(SYS)*.mou
-TGI  = ../libsrc/$(SYS)*.tgi
-CLIB = ../libsrc/$(SYS).lib
-CL   = ../src/cl65/cl65
-CC   = ../src/cc65/cc65
-AS   = ../src/ca65/ca65
-LD   = ../src/ld65/ld65
-
-MY_INC = --forget-inc-paths -I . -I $(CC65_INC)
-MY_ASM = --forget-inc-paths -I . -I $(CA65_INC)
+export CC65_HOME := $(abspath ..)
+MOUS = ../mou/$(SYS)*.mou
+TGI  = ../tgi/$(SYS)*.tgi
+CLIB = ../lib/$(SYS).lib
+CL   = ../bin/cl65
+CC   = ../bin/cc65
+AS   = ../bin/ca65
+LD   = ../bin/ld65
 endif
 
 # This one comes with VICE
-C1541          = c1541
+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
 
+%: %.c
+%: %.s
+
 .c.o:
        @echo $<
-       @$(CC) $(MY_INC) -Oirs --codesize 500 -T -g -t $(SYS) $<
-       @$(AS) $(basename $<).s
+       @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
+       @$(AS) $(<:.c=.s)
 
 .s.o:
        @echo $<
-       @$(AS) $(MY_ASM) -t $(SYS) $<
+       @$(AS) $(AFLAGS) -t $(SYS) $<
 
-.o:
-       @$(LD) -o $@ -t $(SYS) -m $(basename $@).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           \
-               diodemo         \
-               fire            \
-               gunzip65        \
-               hello           \
+EXELIST        =       ascii           \
+               diodemo         \
+               enumdevdir      \
+               fire            \
+               gunzip65        \
+               hello           \
                mandelbrot      \
-               mousedemo       \
-               nachtm          \
-               plasma          \
-               sieve           \
-               tgidemo
+               mousetest       \
+               multdemo        \
+               nachtm          \
+               ovrldemo        \
+               plasma          \
+               sieve           \
+               tgidemo
 
 # --------------------------------------------------------------------------
-# Rules how to make each one of the binaries
+# Rules to make the binaries
 
 .PHONY:        all
-all:           $(EXELIST)
+all:   $(EXELIST)
 
-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) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-mandelbrot:    mandelbrot.o
-       @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
-else
-mandelbrot:    mandelbrot.o
-endif
-endif
-
-# The Apple ][ needs the start address adjusted for the mousedemo
-ifeq "$(SYS)" "apple2"
-mousedemo:     mousedemo.o
-       @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
-else
-mousedemo:     mousedemo.o
-endif
-
-nachtm:                nachtm.o
-
-plasma:                plasma.o
+# --------------------------------------------------------------------------
+# Overlay rules. Overlays need special ld65 configuration files.  Also, the
+# overlay file-names are shortenned to fit the Atari's 8.3-character limit.
 
-sieve:         sieve.o
+multdemo:      multidemo.o
+       @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
 
-# The Apple machines need the start address adjusted for the tgidemo
-ifeq "$(SYS)" "apple2"
-tgidemo:       tgidemo.o
-       @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
-else
-ifeq "$(SYS)" "apple2enh"
-tgidemo:       tgidemo.o
-       @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
-else
-tgidemo:       tgidemo.o
-endif
-endif
+ovrldemo:      overlaydemo.o
+       @$(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
-disk:          samples.d64
+disk:  samples.d64
 
 samples.d64:   all
        @$(C1541) -format samples,AA  d64 $@ > /dev/null
@@ -156,7 +135,7 @@ samples.d64:        all
        done
 
 # --------------------------------------------------------------------------
-# Cleanup rules
+# Clean-up rules
 
 .PHONY:        clean
 clean:
@@ -165,5 +144,4 @@ clean:
 .PHONY:        zap
 zap:   clean
        $(RM) $(EXELIST) samples.d64
-
-
+       $(RM) multdemo.? ovrldemo.?