]> git.sur5r.net Git - cc65/blob - samples/Makefile
Fixed a bug: The floppies do not like ,R (for read mode) when opening the
[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 MOUS = /usr/lib/cc65/mou/$(SYS)*.mou
16 TGI  = /usr/lib/cc65/tgi/$(SYS)*.tgi
17 ifneq "$(wildcard /usr/local/lib/cc65)" ""
18 MOUS = /usr/local/lib/cc65/mou/$(SYS)*.mou
19 TGI  = /usr/local/lib/cc65/tgi/$(SYS)*.tgi
20 endif
21 ifdef CC65_HOME
22 MOUS = $(CC65_HOME)/mou/$(SYS)*.mou
23 TGI  = $(CC65_HOME)/tgi/$(SYS)*.tgi
24 endif
25 CLIB = --lib $(SYS).lib
26 CL   = cl65
27 CC   = cc65
28 AS   = ca65
29 LD   = ld65
30
31 else
32 # "samples/" is a part of a complete source tree.
33 CA65_INC = ../asminc
34 CC65_INC = ../include
35 LD65_CFG = ../src/ld65/cfg
36 LD65_LIB = ../libsrc
37 LD65_OBJ = ../libsrc
38 MOUS = ../libsrc/$(SYS)*.mou
39 TGI  = ../libsrc/$(SYS)*.tgi
40 CLIB = ../libsrc/$(SYS).lib
41 CL   = ../src/cl65/cl65
42 CC   = ../src/cc65/cc65
43 AS   = ../src/ca65/ca65
44 LD   = ../src/ld65/ld65
45
46 MY_INC = --forget-inc-paths -I . -I $(CC65_INC)
47 MY_ASM = --forget-inc-paths -I . -I $(CA65_INC)
48 endif
49
50 # This one comes with VICE
51 C1541   = c1541
52
53
54 # --------------------------------------------------------------------------
55 # Generic rules
56
57 .c.o:
58         @echo $<
59         @$(CC) $(MY_INC) -Oirs --codesize 500 -T -g -t $(SYS) $<
60         @$(AS) $(basename $<).s
61
62 .s.o:
63         @echo $<
64         @$(AS) $(MY_ASM) -t $(SYS) $<
65
66 .o:
67         @$(LD) -o $@ -t $(SYS) -m $(basename $@).map $^ $(CLIB)
68
69
70 # --------------------------------------------------------------------------
71 # List of executables. This list could be made target dependent by checking
72 # $(SYS).
73
74 EXELIST =       ascii           \
75                 diodemo         \
76                 fire            \
77                 gunzip65        \
78                 hello           \
79                 mandelbrot      \
80                 mousedemo       \
81                 nachtm          \
82                 ovrldemo        \
83                 plasma          \
84                 sieve           \
85                 tgidemo
86
87 # --------------------------------------------------------------------------
88 # Rules how to make each one of the binaries
89
90 .PHONY: all
91 all:    $(EXELIST)
92
93 ascii:          ascii.o
94
95 diodemo:        diodemo.o
96
97 fire:           fire.o
98
99 gunzip65:       gunzip65.o
100
101 hello:          hello.o
102
103 # The Apple machines need the start address adjusted for the mandelbrot demo
104 ifeq "$(SYS)" "apple2"
105 mandelbrot:     mandelbrot.o
106         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
107 else
108 ifeq "$(SYS)" "apple2enh"
109 mandelbrot:     mandelbrot.o
110         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
111 else
112 mandelbrot:     mandelbrot.o
113 endif
114 endif
115
116 # The Apple ][ needs the start address adjusted for the mousedemo
117 ifeq "$(SYS)" "apple2"
118 mousedemo:      mousedemo.o
119         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
120 else
121 mousedemo:      mousedemo.o
122 endif
123
124 nachtm:         nachtm.o
125
126 ovrldemo:       overlaydemo.o
127         @$(LD) -t $(SYS) -m $(basename $@).map -C $(SYS)-overlay.cfg -o $@ $^ $(CLIB)
128
129 plasma:         plasma.o
130
131 sieve:          sieve.o
132
133 # The Apple machines need the start address adjusted for the tgidemo
134 ifeq "$(SYS)" "apple2"
135 tgidemo:        tgidemo.o
136         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
137 else
138 ifeq "$(SYS)" "apple2enh"
139 tgidemo:        tgidemo.o
140         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
141 else
142 tgidemo:        tgidemo.o
143 endif
144 endif
145
146 # --------------------------------------------------------------------------
147 # Rule to make a disk with all samples. Needs the c1541 program that comes
148 # with the VICE emulator.
149
150 .PHONY: disk
151 disk:   samples.d64
152
153 samples.d64:    all
154         @$(C1541) -format samples,AA  d64 $@ > /dev/null
155         @for exe in $(EXELIST); do\
156             $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\
157         done
158         @for mod in $(TGI) $(MOUS); do\
159             $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\
160         done
161
162 # --------------------------------------------------------------------------
163 # Cleanup rules
164
165 .PHONY: clean
166 clean:
167         $(RM) *~ *.map *.o *.s *.lbl
168
169 .PHONY: zap
170 zap:    clean
171         $(RM) $(EXELIST) samples.d64