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