9891cdadf708947bf838bd43b2cabe83e9908aa0
[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_gps_print.c \
47         ao_state.c
48
49 #
50 # Receiver code
51 #
52 TELE_RECEIVER_SRC =\
53         ao_monitor.c \
54         ao_rssi.c
55
56 #
57 # Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
58 #
59
60 TELE_DRIVER_SRC = \
61         ao_convert.c \
62         ao_serial.c
63
64 #
65 # Drivers for partially-flled boards (TT, TD and TI)
66 #
67 TELE_FAKE_SRC = \
68         ao_adc_fake.c \
69         ao_ee_fake.c
70
71 #
72 # Debug dongle driver (only on TI)
73 #
74 DBG_DONGLE_SRC = \
75         ao_dbg.c
76
77 #
78 # Drivers only on TeleMetrum
79 #
80 TM_DRIVER_SRC = \
81         ao_adc.c \
82         ao_ee.c \
83         ao_gps_report.c \
84         ao_ignite.c
85
86 #
87 # Drivers only on TeleMetrum
88 #
89 TM_SIRF_DRIVER_SRC = \
90         ao_gps_sirf.c
91 #
92 # Drivers only on TeleMetrum
93 #
94 TM_SKY_DRIVER_SRC = \
95         ao_gps_skytraq.c
96
97 #
98 # Tasks run on TeleMetrum
99 #
100 TM_TASK_SRC = \
101         ao_flight.c \
102         ao_log.c \
103         ao_report.c \
104         ao_telemetry.c
105
106 TM_MAIN_SRC = \
107         ao_telemetrum.c
108
109 #
110 # All sources for TeleMetrum
111 #
112 TM_SRC = \
113         $(ALTOS_SRC) \
114         $(ALTOS_DRIVER_SRC) \
115         $(TELE_DRIVER_SRC) \
116         $(TELE_COMMON_SRC) \
117         $(TM_DRIVER_SRC) \
118         $(TM_TASK_SRC) \
119         $(TM_MAIN_SRC)
120
121 TM_SIRF_SRC = \
122         $(TM_SRC) \
123         $(TM_SIRF_DRIVER_SRC)
124
125 TM_SKY_SRC = \
126         $(TM_SRC) \
127         $(TM_SKY_DRIVER_SRC)
128
129 TI_MAIN_SRC = \
130         ao_tidongle.c
131
132 #
133 # All sources for the TI debug dongle
134 #
135 TI_SRC = \
136         $(ALTOS_SRC) \
137         $(ALTOS_DRIVER_SRC) \
138         $(TELE_RECEIVER_SRC) \
139         $(TELE_COMMON_SRC) \
140         $(TELE_FAKE_SRC) \
141         $(TI_MAIN_SRC) \
142         $(DBG_DONGLE_SRC)
143
144 TT_MAIN_SRC = \
145         ao_teleterra.c
146 #
147 # All sources for TeleTerra
148 #
149 TT_SRC = \
150         $(ALTOS_SRC) \
151         $(ALTOS_DRIVER_SRC) \
152         $(TELE_RECEIVER_SRC) \
153         $(TELE_DRIVER_SRC) \
154         $(TELE_COMMON_SRC) \
155         $(TELE_FAKE_SRC) \
156         $(TT_MAIN_SRC)
157
158
159 #
160 # Sources for TeleDongle
161 #
162
163 TD_MAIN_SRC = \
164         ao_teledongle.c
165
166 TD_SRC = \
167         $(ALTOS_SRC) \
168         $(ALTOS_DRIVER_SRC) \
169         $(TELE_RECEIVER_SRC) \
170         $(TELE_COMMON_SRC) \
171         $(TELE_FAKE_SRC) \
172         $(TD_MAIN_SRC)
173
174 SRC = \
175         $(ALTOS_SRC) \
176         $(ALTOS_DRIVER_SRC) \
177         $(TELE_DRIVER_SRC) \
178         $(TELE_RECEIVER_SRC) \
179         $(TELE_COMMON_SRC) \
180         $(TELE_FAKE_SRC) \
181         $(TM_DRIVER_SRC) \
182         $(TM_SIRF_DRIVER_SRC) \
183         $(TM_SKY_DRIVER_SRC) \
184         $(TM_TASK_SRC) \
185         $(TM_MAIN_SRC) \
186         $(TI_MAIN_SRC) \
187         $(TD_MAIN_SRC) \
188         $(TT_MAIN_SRC)
189
190 TM_SIRF_REL=$(TM_SIRF_SRC:.c=.rel) ao_product-telemetrum.rel
191 TM_SKY_REL=$(TM_SKY_SRC:.c=.rel) ao_product-telemetrum.rel
192 TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle.rel
193 TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra.rel
194 TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle.rel
195
196 PROD_REL=\
197         ao_product-telemetrum.rel \
198         ao_product-tidongle.rel \
199         ao_product-teleterra.rel \
200         ao_product-teledongle.rel
201
202 REL=$(SRC:.c=.rel) $(PROD_REL)
203 ADB=$(REL:.rel=.adb)
204 ASM=$(REL:.rel=.asm)
205 LNK=$(REL:.rel=.lnk)
206 LST=$(REL:.rel=.lst)
207 RST=$(REL:.rel=.rst)
208 SYM=$(REL:.rel=.sym)
209
210 PROGS=  telemetrum-sirf.ihx telemetrum-sky.ihx tidongle.ihx \
211         teleterra.ihx teledongle.ihx
212
213 HOST_PROGS=ao_flight_test ao_gps_test ao_gps_test_skytraq
214
215 PCDB=$(PROGS:.ihx=.cdb)
216 PLNK=$(PROGS:.ihx=.lnk)
217 PMAP=$(PROGS:.ihx=.map)
218 PMEM=$(PROGS:.ihx=.mem)
219 PAOM=$(PROGS:.ihx=)
220
221 %.rel : %.c $(INC)
222         $(CC) -c $(CFLAGS) -o$*.rel $*.c
223
224 all: $(PROGS) $(HOST_PROGS)
225
226 telemetrum-sirf.ihx: $(TM_SIRF_REL) Makefile
227         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SIRF_REL)
228         sh check-stack ao.h telemetrum-sirf.mem
229
230 telemetrum-sky.ihx: $(TM_SKY_REL) Makefile
231         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SKY_REL)
232         sh check-stack ao.h telemetrum-sky.mem
233
234 telemetrum-sky.ihx: telemetrum-sirf.ihx
235
236 tidongle.ihx: $(TI_REL) Makefile
237         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL)
238         sh check-stack ao.h tidongle.mem
239
240 tidongle.ihx: telemetrum-sky.ihx
241
242 teleterra.ihx: $(TT_REL) Makefile
243         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL)
244         sh check-stack ao.h teleterra.mem
245
246 teleterra.ihx: tidongle.ihx
247
248 teledongle.ihx: $(TD_REL) Makefile
249         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL)
250         sh check-stack ao.h teledongle.mem
251
252 teledongle.ihx: teleterra.ihx
253
254 altitude.h: make-altitude
255         nickle make-altitude > altitude.h
256
257 TELEMETRUM_DEFS=ao-telemetrum.h
258 TELETERRA_DEFS=ao-teleterra.h
259 TELEDONGLE_DEFS=ao-teledongle.h
260 TIDONGLE_DEFS=ao-tidongle.h
261
262 ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \
263         $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
264 ao_product-telemetrum.rel: ao_product.c $(TELEMETRUM_DEFS)
265         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c
266
267 ao_product-teleterra.rel: ao_product.c $(TELETERRA_DEFS)
268         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c
269
270 ao_product-teledongle.rel: ao_product.c $(TELEDONGLE_DEFS)
271         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c
272
273 ao_product-tidongle.rel: ao_product.c $(TIDONGLE_DEFS)
274         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
275
276 $(TELEMETRUM_DEFS): ao-make-product.5c
277         nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -v $(VERSION) > $@
278
279 $(TELETERRA_DEFS): ao-make-product.5c
280         nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -v $(VERSION) > $@
281
282 $(TELEDONGLE_DEFS): ao-make-product.5c
283         nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -v $(VERSION) > $@
284
285 $(TIDONGLE_DEFS): ao-make-product.5c
286         nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -v $(VERSION) > $@
287
288 distclean:      clean
289
290 clean:
291         rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
292         rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
293         rm -f $(ALL_DEFS) $(HOST_PROGS)
294         rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
295
296 install:
297
298 ao_flight_test: ao_flight.c ao_flight_test.c ao_host.h
299         cc -g -o $@ ao_flight_test.c
300
301 ao_gps_test: ao_gps_sirf.c ao_gps_test.c ao_gps_print.c ao_host.h
302         cc -g -o $@ ao_gps_test.c
303
304 ao_gps_test_skytraq: ao_gps_skytraq.c ao_gps_test_skytraq.c ao_gps_print.c ao_host.h
305         cc -g -o $@ ao_gps_test_skytraq.c