]> git.sur5r.net Git - cc65/blob - samples/Makefile
New diodemo sample by 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 mandelbrot:             $(CRT0) mandelbrot.o $(CLIB)
87         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
88
89 mousedemo:      $(CRT0) mousedemo.o $(CLIB)
90         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
91
92 nachtm:         $(CRT0) nachtm.o $(CLIB)
93         @$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
94
95 plasma:         $(CRT0) plasma.o $(CLIB)
96         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
97
98 sieve:          $(CRT0) sieve.o $(CLIB)
99         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
100
101 tgidemo:        $(CRT0) tgidemo.o $(CLIB)
102         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
103
104
105 # --------------------------------------------------------------------------
106 # Rule to make a disk with all samples. Needs the c1541 program that comes
107 # with the VICE emulator.
108
109 .PHONY: disk
110 disk:   samples.d64
111
112 samples.d64:    all
113         @$(C1541) -format samples,AA  d64 $@ > /dev/null
114         @for exe in $(EXELIST); do\
115             $(C1541) -attach $@ -write $$exe > /dev/null;\
116         done;\
117         for tgi in ../libsrc/$(SYS)*.tgi; do\
118             $(C1541) -attach $@ -write $$tgi > /dev/null;\
119         done;
120
121 # --------------------------------------------------------------------------
122 # Cleanup rules
123
124 .PHONY: clean
125 clean:
126         $(RM) *~ *.map *.o *.s *.lbl
127
128 .PHONY: zap
129 zap:    clean
130         $(RM) $(EXELIST) samples.d64
131
132
133
134