]> git.sur5r.net Git - cc65/blob - samples/Makefile
Merge pull request #97 from groessler/something_to_pull
[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 # System dependent settings
48
49 # The Apple machines need the start address adjusted when using TGI
50 LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
51 LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
52 LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
53 LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
54
55 # The Apple ][ needs the start address adjusted for the mousetest
56 LDFLAGS_mousetest_apple2 = --start-addr 0x4000
57
58 # The atarixl target needs the start address adjusted when using TGI
59 LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
60 LDFLAGS_tgidemo_atarixl = --start-addr 0x4000
61
62 # The atari target needs to reserve some memory when using TGI
63 LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
64 LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
65
66 # --------------------------------------------------------------------------
67 # Generic rules
68
69 %: %.c
70 %: %.s
71
72 .c.o:
73         @echo $<
74         @$(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
75         @$(AS) $(<:.c=.s)
76
77 .s.o:
78         @echo $<
79         @$(AS) $(AFLAGS) -t $(SYS) $<
80
81 .PRECIOUS: %.o
82
83 .o:
84         $(LD) $(LDFLAGS_$(basename $@)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(CLIB)
85
86 # --------------------------------------------------------------------------
87 # List of executables. This list could be made target dependent by checking
88 # $(SYS).
89
90 EXELIST =       ascii           \
91                 diodemo         \
92                 enumdevdir      \
93                 fire            \
94                 gunzip65        \
95                 hello           \
96                 mandelbrot      \
97                 mousetest       \
98                 multdemo        \
99                 nachtm          \
100                 ovrldemo        \
101                 plasma          \
102                 sieve           \
103                 tgidemo
104
105 # --------------------------------------------------------------------------
106 # Rules how to make each one of the binaries
107
108 .PHONY: all
109 all:    $(EXELIST)
110
111 # --------------------------------------------------------------------------
112 # Rule to make a disk with all samples. Needs the c1541 program that comes
113 # with the VICE emulator.
114
115 .PHONY: disk
116 disk:   samples.d64
117
118 samples.d64:    all
119         @$(C1541) -format samples,AA  d64 $@ > /dev/null
120         @for exe in $(EXELIST); do\
121             $(C1541) -attach $@ -write $$exe > /dev/null || exit $$?;\
122         done
123         @for mod in $(TGI) $(MOUS); do\
124             $(C1541) -attach $@ -write $$mod > /dev/null || exit $$?;\
125         done
126
127 # --------------------------------------------------------------------------
128 # Cleanup rules
129
130 .PHONY: clean
131 clean:
132         $(RM) *~ *.map *.o *.s *.lbl
133
134 .PHONY: zap
135 zap:    clean
136         $(RM) $(EXELIST) samples.d64