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