]> git.sur5r.net Git - cc65/blob - samples/Makefile
corrected all samples and samples.d64 targets
[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 %: %.c
73 %: %.s
74
75 .c.o:
76         @echo $<
77         @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
78         @$(AS) $(<:.c=.s)
79
80 .s.o:
81         @echo $<
82         @$(AS) $(AFLAGS) -t $(SYS) $<
83
84 .PRECIOUS: %.o
85
86 .o:
87         @$(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
88
89 # --------------------------------------------------------------------------
90 # List of executables. This list could be made target-dependent by checking
91 # $(SYS).
92
93 EXELIST =       ascii           \
94                 diodemo         \
95                 enumdevdir      \
96                 fire            \
97                 gunzip65        \
98                 hello           \
99                 mandelbrot      \
100                 mousetest       \
101                 multdemo        \
102                 nachtm          \
103                 ovrldemo        \
104                 plasma          \
105                 sieve           \
106                 tgidemo
107
108 # --------------------------------------------------------------------------
109 # Rules to make the binaries
110
111 .PHONY: all samples
112 all:
113
114 samples:        $(EXELIST)
115
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.
119
120 multdemo:       multidemo.o
121         @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
122
123 ovrldemo:       overlaydemo.o
124         @$(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(CLIB)
125
126 # --------------------------------------------------------------------------
127 # Rule to make a CBM disk with all samples. Needs the c1541 program that comes
128 # with the VICE emulator.
129
130 .PHONY: disk
131 disk:   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 .PHONY: install
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 .PHONY: zip
163 zip:
164         @cd .. && zip -r cc65 samples/
165
166 # --------------------------------------------------------------------------
167 # Clean-up rules
168
169 .PHONY: mostlyclean
170 mostlyclean:
171
172 .PHONY: clean
173 clean:
174         $(RM) *~ *.map *.o *.s *.lbl
175
176 .PHONY: zap
177 zap:    clean
178         $(RM) $(EXELIST) samples.d64
179         $(RM) multdemo.? ovrldemo.?