dcd41718e984113c72d90c7d5dc0521e2d3ab748
[fw/altos] / src / Makefile
1 #
2 # AltOS build
3 #
4 #
5 CC=sdcc
6
7 ifndef VERSION
8 VERSION=$(shell git describe)
9 endif
10
11 CFLAGS=--model-small --debug --opt-code-speed
12
13 LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
14         --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
15
16 INC = \
17         ao.h \
18         cc1111.h \
19         altitude.h \
20         25lc1024.h
21
22 #
23 # Common AltOS sources
24 #
25 ALTOS_SRC = \
26         ao_cmd.c \
27         ao_dma.c \
28         ao_mutex.c \
29         ao_panic.c \
30         ao_task.c \
31         ao_timer.c \
32         _bp.c
33
34 #
35 # Shared AltOS drivers
36 #
37 ALTOS_DRIVER_SRC = \
38         ao_beep.c \
39         ao_config.c \
40         ao_led.c \
41         ao_radio.c \
42         ao_stdio.c \
43         ao_usb.c
44
45 TELE_COMMON_SRC = \
46         ao_packet.c \
47         ao_packet_slave.c \
48         ao_state.c
49
50 #
51 # Receiver code
52 #
53 TELE_RECEIVER_SRC =\
54         ao_monitor.c \
55         ao_gps_print.c \
56         ao_packet_master.c \
57         ao_rssi.c
58
59 #
60 # Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
61 #
62
63 TELE_DRIVER_SRC = \
64         ao_convert.c \
65         ao_serial.c
66
67 #
68 # Drivers for partially-flled boards (TT, TD and TI)
69 #
70 TELE_FAKE_SRC = \
71         ao_adc_fake.c \
72         ao_ee_fake.c
73
74 #
75 # Debug dongle driver (only on TI)
76 #
77 DBG_DONGLE_SRC = \
78         ao_dbg.c
79
80 #
81 # Drivers only on TeleMetrum
82 #
83 TM_DRIVER_SRC = \
84         ao_adc.c \
85         ao_flash.c \
86         ao_gps_report.c \
87         ao_ignite.c
88
89 #
90 # Drivers only on TeleMetrum
91 #
92 TM_SIRF_DRIVER_SRC = \
93         ao_gps_sirf.c
94 #
95 # Drivers only on TeleMetrum
96 #
97 TM_SKY_DRIVER_SRC = \
98         ao_gps_skytraq.c
99
100 #
101 # Tasks run on TeleMetrum
102 #
103 TM_TASK_SRC = \
104         ao_flight.c \
105         ao_log.c \
106         ao_report.c \
107         ao_telemetry.c
108
109 TM_MAIN_SRC = \
110         ao_telemetrum.c
111
112 #
113 # All sources for TeleMetrum
114 #
115 TM_SRC = \
116         $(ALTOS_SRC) \
117         $(ALTOS_DRIVER_SRC) \
118         $(TELE_DRIVER_SRC) \
119         $(TELE_COMMON_SRC) \
120         $(TM_DRIVER_SRC) \
121         $(TM_TASK_SRC) \
122         $(TM_MAIN_SRC)
123
124 TM_SIRF_SRC = \
125         $(TM_SRC) \
126         $(TM_SIRF_DRIVER_SRC)
127
128 TM_SKY_SRC = \
129         $(TM_SRC) \
130         $(TM_SKY_DRIVER_SRC)
131
132 TI_MAIN_SRC = \
133         ao_tidongle.c
134
135 #
136 # All sources for the TI debug dongle
137 #
138 TI_SRC = \
139         $(ALTOS_SRC) \
140         $(ALTOS_DRIVER_SRC) \
141         $(TELE_RECEIVER_SRC) \
142         $(TELE_COMMON_SRC) \
143         $(TELE_FAKE_SRC) \
144         $(TI_MAIN_SRC) \
145         $(DBG_DONGLE_SRC)
146
147 TT_MAIN_SRC = \
148         ao_teleterra.c
149 #
150 # All sources for TeleTerra
151 #
152 TT_SRC = \
153         $(ALTOS_SRC) \
154         $(ALTOS_DRIVER_SRC) \
155         $(TELE_RECEIVER_SRC) \
156         $(TELE_DRIVER_SRC) \
157         $(TELE_COMMON_SRC) \
158         $(TELE_FAKE_SRC) \
159         $(TT_MAIN_SRC)
160
161
162 #
163 # Sources for TeleDongle
164 #
165
166 TD_MAIN_SRC = \
167         ao_teledongle.c
168
169 TD_SRC = \
170         $(ALTOS_SRC) \
171         $(ALTOS_DRIVER_SRC) \
172         $(TELE_RECEIVER_SRC) \
173         $(TELE_COMMON_SRC) \
174         $(TELE_FAKE_SRC) \
175         $(TD_MAIN_SRC)
176
177 SRC = \
178         $(ALTOS_SRC) \
179         $(ALTOS_DRIVER_SRC) \
180         $(TELE_DRIVER_SRC) \
181         $(TELE_RECEIVER_SRC) \
182         $(TELE_COMMON_SRC) \
183         $(TELE_FAKE_SRC) \
184         $(TM_DRIVER_SRC) \
185         $(TM_SIRF_DRIVER_SRC) \
186         $(TM_SKY_DRIVER_SRC) \
187         $(TM_TASK_SRC) \
188         $(TM_MAIN_SRC) \
189         $(TI_MAIN_SRC) \
190         $(TD_MAIN_SRC) \
191         $(TT_MAIN_SRC)
192
193 TM_SIRF_REL=$(TM_SIRF_SRC:.c=.rel) ao_product-telemetrum.rel
194 TM_SKY_REL=$(TM_SKY_SRC:.c=.rel) ao_product-telemetrum.rel
195 TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle.rel
196 TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra.rel
197 TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle.rel
198
199 PROD_REL=\
200         ao_product-telemetrum.rel \
201         ao_product-tidongle.rel \
202         ao_product-teleterra.rel \
203         ao_product-teledongle.rel
204
205 REL=$(SRC:.c=.rel) $(PROD_REL)
206 ADB=$(REL:.rel=.adb)
207 ASM=$(REL:.rel=.asm)
208 LNK=$(REL:.rel=.lnk)
209 LST=$(REL:.rel=.lst)
210 RST=$(REL:.rel=.rst)
211 SYM=$(REL:.rel=.sym)
212
213 PROGS=  telemetrum-sirf.ihx telemetrum-sky.ihx tidongle.ihx \
214         teleterra.ihx teledongle.ihx
215
216 HOST_PROGS=ao_flight_test ao_gps_test ao_gps_test_skytraq
217
218 PCDB=$(PROGS:.ihx=.cdb)
219 PLNK=$(PROGS:.ihx=.lnk)
220 PMAP=$(PROGS:.ihx=.map)
221 PMEM=$(PROGS:.ihx=.mem)
222 PAOM=$(PROGS:.ihx=)
223
224 %.rel : %.c $(INC)
225         $(CC) -c $(CFLAGS) -o$*.rel $*.c
226
227 all: $(PROGS) $(HOST_PROGS)
228
229 telemetrum-sirf.ihx: $(TM_SIRF_REL) Makefile
230         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SIRF_REL)
231         sh check-stack ao.h telemetrum-sirf.mem
232
233 telemetrum-sky.ihx: $(TM_SKY_REL) Makefile
234         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SKY_REL)
235         sh check-stack ao.h telemetrum-sky.mem
236
237 telemetrum-sky.ihx: telemetrum-sirf.ihx
238
239 tidongle.ihx: $(TI_REL) Makefile
240         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL)
241         sh check-stack ao.h tidongle.mem
242
243 tidongle.ihx: telemetrum-sky.ihx
244
245 teleterra.ihx: $(TT_REL) Makefile
246         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL)
247         sh check-stack ao.h teleterra.mem
248
249 teleterra.ihx: tidongle.ihx
250
251 teledongle.ihx: $(TD_REL) Makefile
252         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL)
253         sh check-stack ao.h teledongle.mem
254
255 teledongle.ihx: teleterra.ihx
256
257 altitude.h: make-altitude
258         nickle make-altitude > altitude.h
259
260 TELEMETRUM_DEFS=ao-telemetrum.h
261 TELETERRA_DEFS=ao-teleterra.h
262 TELEDONGLE_DEFS=ao-teledongle.h
263 TIDONGLE_DEFS=ao-tidongle.h
264
265 ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \
266         $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
267 ao_product-telemetrum.rel: ao_product.c $(TELEMETRUM_DEFS)
268         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c
269
270 ao_product-teleterra.rel: ao_product.c $(TELETERRA_DEFS)
271         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c
272
273 ao_product-teledongle.rel: ao_product.c $(TELEDONGLE_DEFS)
274         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c
275
276 ao_product-tidongle.rel: ao_product.c $(TIDONGLE_DEFS)
277         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
278
279 $(TELEMETRUM_DEFS): ao-make-product.5c
280         nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -v $(VERSION) > $@
281
282 $(TELETERRA_DEFS): ao-make-product.5c
283         nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -v $(VERSION) > $@
284
285 $(TELEDONGLE_DEFS): ao-make-product.5c
286         nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -v $(VERSION) > $@
287
288 $(TIDONGLE_DEFS): ao-make-product.5c
289         nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -v $(VERSION) > $@
290
291 distclean:      clean
292
293 clean:
294         rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
295         rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
296         rm -f $(ALL_DEFS) $(HOST_PROGS)
297         rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
298
299 install:
300
301 uninstall:
302
303 ao_flight_test: ao_flight.c ao_flight_test.c ao_host.h
304         cc -g -o $@ ao_flight_test.c
305
306 ao_gps_test: ao_gps_sirf.c ao_gps_test.c ao_gps_print.c ao_host.h
307         cc -g -o $@ ao_gps_test.c
308
309 ao_gps_test_skytraq: ao_gps_skytraq.c ao_gps_test_skytraq.c ao_gps_print.c ao_host.h
310         cc -g -o $@ ao_gps_test_skytraq.c