]> git.sur5r.net Git - cc65/blob - samples/Makefile
Autodetect the location of the compiler and tools.
[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 # Rules how to make each one of the binaries
52
53 EXELIST=ascii fire gunzip65 hello mousedemo nachtm plasma sieve tgidemo
54
55 .PHONY: all
56 all:    $(EXELIST)
57
58 ascii:          $(CRT0) ascii.o $(CLIB)
59         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
60
61 fire:           $(CRT0) fire.o $(CLIB)
62         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
63
64 gunzip65:       $(CRT0) gunzip65.o $(CLIB)
65         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
66
67 hello:          $(CRT0) hello.o $(CLIB)
68         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
69
70 mandelbrot:             $(CRT0) mandelbrot.o $(CLIB)
71         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
72
73 mousedemo:      $(CRT0) mousedemo.o $(CLIB)
74         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
75
76 nachtm:         $(CRT0) nachtm.o $(CLIB)
77         @$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
78
79 plasma:         $(CRT0) plasma.o $(CLIB)
80         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
81
82 sieve:          $(CRT0) sieve.o $(CLIB)
83         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
84
85 tgidemo:        $(CRT0) tgidemo.o $(CLIB)
86         @$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
87
88
89 # --------------------------------------------------------------------------
90 # Rule to make a disk with all samples. Needs the c1541 program that comes
91 # with the VICE emulator.
92
93 .PHONY: disk
94 disk:   samples.d64
95
96 samples.d64:    all
97         @$(C1541) -format samples,AA  d64 $@ > /dev/null
98         @for exe in $(EXELIST); do\
99             $(C1541) -attach $@ -write $$exe > /dev/null;\
100         done;\
101         for tgi in ../libsrc/$(SYS)*.tgi; do\
102             $(C1541) -attach $@ -write $$tgi > /dev/null;\
103         done;
104
105 # --------------------------------------------------------------------------
106 # Cleanup rules
107
108 .PHONY: clean
109 clean:
110         $(RM) *~ *.map *.o *.s *.lbl
111
112 .PHONY: zap
113 zap:    clean
114         $(RM) $(EXELIST) samples.d64
115
116
117
118