2 # Makefile for cc65 samples
4 # This Makefile requires GNU make
7 # Enter the target system here
10 # Determine the path to the executables and libraries. If the samples
11 # directory is part of a complete source tree, use the stuff from that
12 # source tree; otherwise, use the "install" directories.
13 ifeq "$(wildcard ../src)" ""
15 installdir = /usr/lib/cc65
16 ifneq "$(wildcard /usr/local/lib/cc65)" ""
17 installdir = /usr/local/lib/cc65
19 ifneq "$(wildcard /opt/local/share/cc65)" ""
20 installdir = /opt/local/share/cc65
23 installdir = $(CC65_HOME)
26 MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou
27 TGI = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi
28 CLIB = --lib $(SYS).lib
35 # "samples/" is a part of a complete source tree.
36 export CC65_HOME := $(abspath ..)
37 MOUS = ../target/$(SYS)/drv/mou/$(SYS)*.mou
38 TGI = ../target/$(SYS)/drv/tgi/$(SYS)*.tgi
39 CLIB = ../lib/$(SYS).lib
46 # This one comes with VICE
49 # --------------------------------------------------------------------------
50 # System-dependent settings
52 # The Apple machines need the start address adjusted when using TGI
53 LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
54 LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
55 LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
56 LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
58 # The Apple ][ needs the start address adjusted for the mousetest
59 LDFLAGS_mousetest_apple2 = --start-addr 0x4000
61 # The atarixl target needs the start address adjusted when using TGI
62 LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
63 LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
65 # The atari target needs to reserve some memory when using TGI
66 LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
67 LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
69 # --------------------------------------------------------------------------
77 @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
82 @$(AS) $(AFLAGS) -t $(SYS) $<
87 @$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
89 # --------------------------------------------------------------------------
90 # List of executables. This list could be made target-dependent by checking
108 # --------------------------------------------------------------------------
109 # Rules to make the binaries
116 # --------------------------------------------------------------------------
117 # Overlay rules. Overlays need special ld65 configuration files. Also, the
118 # overlay file-names are shortenned to fit the Atari's 8.3-character limit.
120 multdemo: multidemo.o
121 @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
123 ovrldemo: overlaydemo.o
124 @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
126 # --------------------------------------------------------------------------
127 # Rule to make a CBM disk with all samples. Needs the c1541 program that comes
128 # with the VICE emulator.
134 @$(C1541) -format samples,AA d64 $@ > /dev/null
135 @for exe in $(EXELIST); do\
136 $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\
138 @for mod in $(TGI) $(MOUS); do\
139 $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\
142 # --------------------------------------------------------------------------
146 samplesdir = $(prefix)/share/cc65
149 $(if $(prefix),,$(error variable `prefix' must be set))
150 $(INSTALL) -d $(DESTDIR)$(samplesdir)
151 $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
152 $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial
153 $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir)
154 $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir)
155 $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir)
156 $(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos
157 $(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial
159 # --------------------------------------------------------------------------
164 @cd .. && zip -r cc65 samples/
166 # --------------------------------------------------------------------------
174 $(RM) *.map *.o *.s *.lbl
178 $(RM) $(EXELIST) samples.d64
179 $(RM) multdemo.? ovrldemo.?