6fda8965dd2a3c6c7d4e0a467eeb8bfb0ee52dbc
[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 SERIAL=1
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_dbg.c \
28         ao_dma.c \
29         ao_mutex.c \
30         ao_panic.c \
31         ao_task.c \
32         ao_timer.c \
33         _bp.c
34
35 #
36 # Shared AltOS drivers
37 #
38 ALTOS_DRIVER_SRC = \
39         ao_beep.c \
40         ao_config.c \
41         ao_led.c \
42         ao_radio.c \
43         ao_stdio.c \
44         ao_usb.c
45
46 TELE_COMMON_SRC = \
47         ao_gps_print.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_gps.c \
64         ao_serial.c
65
66 #
67 # Drivers for partially-flled boards (TT, TD and TI)
68 #
69 TELE_FAKE_SRC = \
70         ao_adc_fake.c \
71         ao_ee_fake.c
72
73
74 # Drivers only on TeleMetrum
75 #
76 TM_DRIVER_SRC = \
77         ao_adc.c \
78         ao_ee.c \
79         ao_gps_report.c \
80         ao_ignite.c
81
82 #
83 # Tasks run on TeleMetrum
84 #
85 TM_TASK_SRC = \
86         ao_flight.c \
87         ao_log.c \
88         ao_report.c \
89         ao_telemetry.c
90
91 TM_MAIN_SRC = \
92         ao_telemetrum.c
93
94 #
95 # All sources for TeleMetrum
96 #
97 TM_SRC = \
98         $(ALTOS_SRC) \
99         $(ALTOS_DRIVER_SRC) \
100         $(TELE_DRIVER_SRC) \
101         $(TELE_RECEIVER_SRC) \
102         $(TELE_COMMON_SRC) \
103         $(TM_DRIVER_SRC) \
104         $(TM_TASK_SRC) \
105         $(TM_MAIN_SRC)
106
107 TI_MAIN_SRC = \
108         ao_tidongle.c
109
110 #
111 # All sources for the TI debug dongle
112 #
113 TI_SRC = \
114         $(ALTOS_SRC) \
115         $(ALTOS_DRIVER_SRC) \
116         $(TELE_RECEIVER_SRC) \
117         $(TELE_COMMON_SRC) \
118         $(TELE_FAKE_SRC) \
119         $(TI_MAIN_SRC)
120         
121 TT_MAIN_SRC = \
122         ao_teleterra.c
123 #
124 # All sources for TeleTerra
125 #
126 TT_SRC = \
127         $(ALTOS_SRC) \
128         $(ALTOS_DRIVER_SRC) \
129         $(TELE_RECEIVER_SRC) \
130         $(TELE_DRIVER_SRC) \
131         $(TELE_COMMON_SRC) \
132         $(TELE_FAKE_SRC) \
133         $(TT_MAIN_SRC)
134         
135         
136 #
137 # Sources for TeleDongle
138 #
139
140 TD_MAIN_SRC = \
141         ao_teledongle.c
142
143 TD_SRC = \
144         $(ALTOS_SRC) \
145         $(ALTOS_DRIVER_SRC) \
146         $(TELE_RECEIVER_SRC) \
147         $(TELE_COMMON_SRC) \
148         $(TELE_FAKE_SRC) \
149         $(TD_MAIN_SRC)
150
151 SRC = \
152         $(ALTOS_SRC) \
153         $(ALTOS_DRIVER_SRC) \
154         $(TELE_DRIVER_SRC) \
155         $(TELE_RECEIVER_SRC) \
156         $(TELE_COMMON_SRC) \
157         $(TELE_FAKE_SRC) \
158         $(TM_DRIVER_SRC) \
159         $(TM_TASK_SRC) \
160         $(TM_MAIN_SRC) \
161         $(TI_MAIN_SRC) \
162         $(TD_MAIN_SRC) \
163         $(TT_MAIN_SRC)
164
165 TM_REL=$(TM_SRC:.c=.rel) ao_product-telemetrum-$(SERIAL).rel
166 TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle-$(SERIAL).rel
167 TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra-$(SERIAL).rel
168 TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle-$(SERIAL).rel
169
170 PROD_REL=\
171         ao_product-telemetrum-$(SERIAL).rel \
172         ao_product-tidongle-$(SERIAL).rel \
173         ao_product-teleterra-$(SERIAL).rel \
174         ao_product-teledongle-$(SERIAL).rel
175
176 REL=$(SRC:.c=.rel) $(PROD_REL)
177 ADB=$(REL:.rel=.adb)
178 ASM=$(REL:.rel=.asm)
179 LNK=$(REL:.rel=.lnk)
180 LST=$(REL:.rel=.lst)
181 RST=$(REL:.rel=.rst)
182 SYM=$(REL:.rel=.sym)
183
184 PROGS=  telemetrum-$(SERIAL).ihx tidongle-$(SERIAL).ihx \
185         teleterra-$(SERIAL).ihx teledongle-$(SERIAL).ihx
186
187 HOST_PROGS=ao_flight_test
188
189 PCDB=$(PROGS:.ihx=.cdb)
190 PLNK=$(PROGS:.ihx=.lnk)
191 PMAP=$(PROGS:.ihx=.map)
192 PMEM=$(PROGS:.ihx=.mem)
193 PAOM=$(PROGS:.ihx=)
194
195 %.rel : %.c $(INC)
196         $(CC) -c $(CFLAGS) -o$*.rel $*.c
197
198 all: $(PROGS) $(HOST_PROGS)
199
200 telemetrum-$(SERIAL).ihx: $(TM_REL) Makefile
201         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_REL)
202         sh check-stack ao.h telemetrum-$(SERIAL).mem
203
204 tidongle-$(SERIAL).ihx: $(TI_REL) Makefile
205         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL)
206         sh check-stack ao.h tidongle-$(SERIAL).mem
207
208 tidongle-$(SERIAL).ihx: telemetrum-$(SERIAL).ihx
209
210 teleterra-$(SERIAL).ihx: $(TT_REL) Makefile
211         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL)
212         sh check-stack ao.h teleterra-$(SERIAL).mem
213
214 teleterra-$(SERIAL).ihx: tidongle-$(SERIAL).ihx
215
216 teledongle-$(SERIAL).ihx: $(TD_REL) Makefile
217         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL)
218         sh check-stack ao.h teledongle-$(SERIAL).mem
219
220 teledongle-$(SERIAL).ihx: teleterra-$(SERIAL).ihx
221
222 altitude.h: make-altitude
223         nickle make-altitude > altitude.h
224
225 TELEMETRUM_DEFS=ao-telemetrum-$(SERIAL).h
226 TELETERRA_DEFS=ao-teleterra-$(SERIAL).h
227 TELEDONGLE_DEFS=ao-teledongle-$(SERIAL).h
228 TIDONGLE_DEFS=ao-tidongle-$(SERIAL).h
229
230 ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \
231         $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
232 ao_product-telemetrum-$(SERIAL).rel: ao_product.c $(TELEMETRUM_DEFS)
233         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c
234
235 ao_product-teleterra-$(SERIAL).rel: ao_product.c $(TELETERRA_DEFS)
236         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c
237
238 ao_product-teledongle-$(SERIAL).rel: ao_product.c $(TELEDONGLE_DEFS)
239         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c
240
241 ao_product-tidongle-$(SERIAL).rel: ao_product.c $(TIDONGLE_DEFS)
242         $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
243
244 $(TELEMETRUM_DEFS): ao-make-product.5c
245         nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -s $(SERIAL) -v $(VERSION) > $@
246
247 $(TELETERRA_DEFS): ao-make-product.5c
248         nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -s $(SERIAL) -v $(VERSION) > $@
249
250 $(TELEDONGLE_DEFS): ao-make-product.5c
251         nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -s $(SERIAL) -v $(VERSION) > $@
252
253 $(TIDONGLE_DEFS): ao-make-product.5c
254         nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -s $(SERIAL) -v $(VERSION) > $@
255
256 clean:
257         rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
258         rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
259         rm -f $(ALL_DEFS) $(HOST_PROGS)
260         rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
261
262 install:
263
264 ao_flight_test: ao_flight.c ao_flight_test.c
265         cc -g -o $@ ao_flight_test.c