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