]> git.sur5r.net Git - cc65/blob - samples/Makefile
Minor change.
[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                 multdemo        \
82                 nachtm          \
83                 ovrldemo        \
84                 plasma          \
85                 sieve           \
86                 tgidemo
87
88 # --------------------------------------------------------------------------
89 # Rules how to make each one of the binaries
90
91 .PHONY: all
92 all:    $(EXELIST)
93
94 ascii:          ascii.o
95
96 diodemo:        diodemo.o
97
98 fire:           fire.o
99
100 gunzip65:       gunzip65.o
101
102 hello:          hello.o
103
104 # The Apple machines need the start address adjusted for the mandelbrot demo
105 ifeq "$(SYS)" "apple2"
106 mandelbrot:     mandelbrot.o
107         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
108 else
109 ifeq "$(SYS)" "apple2enh"
110 mandelbrot:     mandelbrot.o
111         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
112 else
113 mandelbrot:     mandelbrot.o
114 endif
115 endif
116
117 # The Apple ][ needs the start address adjusted for the mousedemo
118 ifeq "$(SYS)" "apple2"
119 mousedemo:      mousedemo.o
120         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
121 else
122 mousedemo:      mousedemo.o
123 endif
124
125 multdemo:       multidemo.o
126         @$(LD) -t $(SYS) -m $(basename $@).map -C $(SYS)-overlay.cfg -o $@ $^ $(CLIB)
127
128 nachtm:         nachtm.o
129
130 ovrldemo:       overlaydemo.o
131         @$(LD) -t $(SYS) -m $(basename $@).map -C $(SYS)-overlay.cfg -o $@ $^ $(CLIB)
132
133 plasma:         plasma.o
134
135 sieve:          sieve.o
136
137 # The Apple machines need the start address adjusted for the tgidemo
138 ifeq "$(SYS)" "apple2"
139 tgidemo:        tgidemo.o
140         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
141 else
142 ifeq "$(SYS)" "apple2enh"
143 tgidemo:        tgidemo.o
144         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^ $(CLIB)
145 else
146 tgidemo:        tgidemo.o
147 endif
148 endif
149
150 # --------------------------------------------------------------------------
151 # Rule to make a disk with all samples. Needs the c1541 program that comes
152 # with the VICE emulator.
153
154 .PHONY: disk
155 disk:   samples.d64
156
157 samples.d64:    all
158         @$(C1541) -format samples,AA  d64 $@ > /dev/null
159         @for exe in $(EXELIST); do\
160             $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\
161         done
162         @for mod in $(TGI) $(MOUS); do\
163             $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\
164         done
165
166 # --------------------------------------------------------------------------
167 # Cleanup rules
168
169 .PHONY: clean
170 clean:
171         $(RM) *~ *.map *.o *.s *.lbl
172
173 .PHONY: zap
174 zap:    clean
175         $(RM) $(EXELIST) samples.d64