2 # Makefile for cc65 samples
4 # This Makefile requires GNU make
7 # Enter the target system here
10 ifneq ($(shell echo),)
22 # Determine the path to the executables and libraries. If the samples
23 # directory is part of a complete source tree, use the stuff from that
24 # source tree; otherwise, use the "install" directories.
25 ifeq "$(wildcard ../src)" ""
27 installdir = /usr/lib/cc65
28 ifneq "$(wildcard /usr/local/lib/cc65)" ""
29 installdir = /usr/local/lib/cc65
31 ifneq "$(wildcard /opt/local/share/cc65)" ""
32 installdir = /opt/local/share/cc65
35 installdir = $(CC65_HOME)
38 MOUS := $(wildcard $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou)
39 TGI := $(wildcard $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi)
40 CLIB = --lib $(SYS).lib
47 # "samples/" is a part of a complete source tree.
48 export CC65_HOME := $(abspath ..)
49 MOUS := $(wildcard ../target/$(SYS)/drv/mou/$(SYS)*.mou)
50 TGI := $(wildcard ../target/$(SYS)/drv/tgi/$(SYS)*.tgi)
51 CLIB = ../lib/$(SYS).lib
58 # This one comes with VICE
61 # --------------------------------------------------------------------------
62 # System-dependent settings
64 # The Apple machines need the start address adjusted when using TGI
65 LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
66 LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
67 LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
68 LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
70 # The Apple ][ needs the start address adjusted for the mousetest
71 LDFLAGS_mousetest_apple2 = --start-addr 0x4000
73 # The atarixl target needs the start address adjusted when using TGI
74 LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
75 LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
77 # The atari target needs to reserve some memory when using TGI
78 LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
79 LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
81 # --------------------------------------------------------------------------
84 .PHONY: all mostlyclean clean install zip samples d64
90 $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
94 $(AS) $(AFLAGS) -t $(SYS) $<
99 $(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
101 # --------------------------------------------------------------------------
102 # List of executables. This list could be made target-dependent by checking
120 # --------------------------------------------------------------------------
121 # Rules to make the binaries
127 # --------------------------------------------------------------------------
128 # Overlay rules. Overlays need special ld65 configuration files. Also, the
129 # overlay file-names are shortenned to fit the Atari's 8.3-character limit.
131 multdemo: multidemo.o
132 $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
134 ovrldemo: overlaydemo.o
135 $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
137 OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I)
139 # --------------------------------------------------------------------------
140 # Rule to make a CBM disk with all samples. Needs the c1541 program that comes
141 # with the VICE emulator.
145 define D64_WRITE_recipe
147 $(C1541) -attach $@ -write $(file) $(notdir $(file)) >$(NULLDEV)
149 endef # D64_WRITE_recipe
152 @$(C1541) -format samples,AA d64 $@ >$(NULLDEV)
153 $(foreach file,$(EXELIST),$(D64_WRITE_recipe))
154 $(foreach file,$(OVERLAYLIST),$(D64_WRITE_recipe))
155 $(foreach file,$(TGI) $(MOUS),$(D64_WRITE_recipe))
157 # --------------------------------------------------------------------------
161 samplesdir = $(prefix)/share/cc65
164 $(if $(prefix),,$(error variable `prefix' must be set))
165 $(INSTALL) -d $(DESTDIR)$(samplesdir)
166 $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
167 $(INSTALL) -d $$(DESTDIR)$(samplesdir)/tutorial
168 $(INSTALL) -m0644 *.* $(DESTDIR)$(samplesdir)
169 $(INSTALL) -m0644 README $(DESTDIR)$(samplesdir)
170 $(INSTALL) -m0644 Makefile $(DESTDIR)$(samplesdir)
171 $(INSTALL) -m0644 geos/*.* $(DESTDIR)$(samplesdir)/geos
172 $(INSTALL) -m0644 tutorial/*.* $(DESTDIR)$(samplesdir)/tutorial
174 # --------------------------------------------------------------------------
178 @cd .. && zip -r cc65 samples/
180 # --------------------------------------------------------------------------
184 @$(DEL) *.map *.o *.s 2>$(NULLDEV)
187 @$(DEL) $(EXELIST) samples.d64 2>$(NULLDEV)
188 @$(DEL) multdemo.? ovrldemo.? 2>$(NULLDEV)