]> git.sur5r.net Git - cc65/blob - samples/Makefile
Adjusted to the cc65 Makefile style.
[cc65] / samples / Makefile
1 #
2 # Makefile for cc65 samples
3 #
4 # This Makefile requires GNU make
5 #
6
7 # Enter the target system here
8 SYS = c64
9
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)" ""
14 # No source tree
15 installdir = /usr/lib/cc65
16 ifneq "$(wildcard /usr/local/lib/cc65)" ""
17 installdir = /usr/local/lib/cc65
18 endif
19 ifneq "$(wildcard /opt/local/share/cc65)" ""
20 installdir = /opt/local/share/cc65
21 endif
22 ifdef CC65_HOME
23 installdir = $(CC65_HOME)
24 endif
25
26 MOUS = $(installdir)/target/$(SYS)/drv/mou/$(SYS)*.mou
27 TGI  = $(installdir)/target/$(SYS)/drv/tgi/$(SYS)*.tgi
28 CLIB = --lib $(SYS).lib
29 CL   = cl65
30 CC   = cc65
31 AS   = ca65
32 LD   = ld65
33
34 else
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
40 CL   = ../bin/cl65
41 CC   = ../bin/cc65
42 AS   = ../bin/ca65
43 LD   = ../bin/ld65
44 endif
45
46 # This one comes with VICE
47 C1541 = c1541
48
49 # --------------------------------------------------------------------------
50 # System-dependent settings
51
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
57
58 # The Apple ][ needs the start address adjusted for the mousetest
59 LDFLAGS_mousetest_apple2 = --start-addr 0x4000
60
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
64
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
68
69 # --------------------------------------------------------------------------
70 # Generic rules
71
72 .PHONY: all mostlyclean clean install zip samples d64 zap
73
74 %: %.c
75 %: %.s
76
77 .c.o:
78         @echo $<
79         @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
80         @$(AS) $(<:.c=.s)
81
82 .s.o:
83         @echo $<
84         @$(AS) $(AFLAGS) -t $(SYS) $<
85
86 .PRECIOUS: %.o
87
88 .o:
89         @$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
90
91 # --------------------------------------------------------------------------
92 # List of executables. This list could be made target-dependent by checking
93 # $(SYS).
94
95 EXELIST = ascii      \
96           diodemo    \
97           enumdevdir \
98           fire       \
99           gunzip65   \
100           hello      \
101           mandelbrot \
102           mousetest  \
103           multdemo   \
104           nachtm     \
105           ovrldemo   \
106           plasma     \
107           sieve      \
108           tgidemo
109
110 # --------------------------------------------------------------------------
111 # Rules to make the binaries
112
113 all:
114
115 samples: $(EXELIST)
116
117 # --------------------------------------------------------------------------
118 # Overlay rules. Overlays need special ld65 configuration files.  Also, the
119 # overlay file-names are shortenned to fit the Atari's 8.3-character limit.
120
121 multdemo: multidemo.o
122         @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
123
124 ovrldemo: overlaydemo.o
125         @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
126
127 # --------------------------------------------------------------------------
128 # Rule to make a CBM disk with all samples. Needs the c1541 program that comes
129 # with the VICE emulator.
130
131 d64: samples.d64
132
133 samples.d64: samples
134         @$(C1541) -format samples,AA  d64 $@ > /dev/null
135         @for exe in $(EXELIST); do\
136             $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\
137         done
138         @for mod in $(TGI) $(MOUS); do\
139             $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\
140         done
141
142 # --------------------------------------------------------------------------
143 # Installation rules
144
145 INSTALL = install
146 samplesdir = $(prefix)/share/cc65
147
148 install:
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
158
159 # --------------------------------------------------------------------------
160 # Packaging rules
161
162 zip:
163         @cd .. && zip -r cc65 samples/
164
165 # --------------------------------------------------------------------------
166 # Clean-up rules
167
168 mostlyclean:
169
170 clean:
171         $(RM) *.map *.o *.s *.lbl
172
173 zap: clean
174         $(RM) $(EXELIST) samples.d64
175         $(RM) multdemo.? ovrldemo.?