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