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