]> git.sur5r.net Git - cc65/blob - samples/Makefile
eaf28b7033d03e95f1bd3235c5dd61f05bfb4e07
[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 mousedemo:      $(CRT0) mousedemo.o $(CLIB)
101         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
102
103 nachtm:         $(CRT0) nachtm.o $(CLIB)
104         @$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
105
106 plasma:         $(CRT0) plasma.o $(CLIB)
107         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
108
109 sieve:          $(CRT0) sieve.o $(CLIB)
110         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
111
112 # The apple machines need the start address adjusted for the tgidemo
113 ifeq "$(SYS)" "apple2"
114 tgidemo:        $(CRT0) tgidemo.o $(CLIB)
115         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
116 else
117 ifeq "$(SYS)" "apple2enh"
118 tgidemo:        $(CRT0) tgidemo.o $(CLIB)
119         @$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
120 else
121 tgidemo:        $(CRT0) tgidemo.o $(CLIB)
122         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
123 endif
124 endif
125
126 # --------------------------------------------------------------------------
127 # Rule to make a disk with all samples. Needs the c1541 program that comes
128 # with the VICE emulator.
129
130 .PHONY: disk
131 disk:   samples.d64
132
133 samples.d64:    all
134         @$(C1541) -format samples,AA  d64 $@ > /dev/null
135         @for exe in $(EXELIST); do\
136             $(C1541) -attach $@ -write $$exe > /dev/null;\
137         done;\
138         for tgi in ../libsrc/$(SYS)*.tgi; do\
139             $(C1541) -attach $@ -write $$tgi > /dev/null;\
140         done;
141
142 # --------------------------------------------------------------------------
143 # Cleanup rules
144
145 .PHONY: clean
146 clean:
147         $(RM) *~ *.map *.o *.s *.lbl
148
149 .PHONY: zap
150 zap:    clean
151         $(RM) $(EXELIST) samples.d64
152
153
154
155