Merge branch 'master' of git://git.gag.com/fw/altos
[fw/altos] / src / Makefile.proto
1 #
2 # AltOS build
3 #
4 #
5 vpath %.c ..
6 vpath %.h ..
7 vpath make-altitude ..
8 vpath ao-make-product.5c ..
9
10 CC=sdcc
11
12 ifndef VERSION
13 include ../Version
14 endif
15
16 CFLAGS=--model-small --debug --opt-code-speed
17
18 LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
19         --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
20
21 INC = \
22         ao.h \
23         ao_pins.h \
24         cc1111.h \
25         altitude.h \
26         25lc1024.h
27
28 #
29 # Common AltOS sources
30 #
31 ALTOS_SRC = \
32         ao_cmd.c \
33         ao_dma.c \
34         ao_mutex.c \
35         ao_panic.c \
36         ao_task.c \
37         ao_timer.c \
38         ao_romconfig.c \
39         _bp.c
40
41 #
42 # Shared AltOS drivers
43 #
44 ALTOS_DRIVER_SRC = \
45         ao_beep.c \
46         ao_config.c \
47         ao_led.c \
48         ao_radio.c \
49         ao_stdio.c \
50         ao_usb.c
51
52 TELE_COMMON_SRC = \
53         ao_packet.c \
54         ao_packet_slave.c \
55         ao_state.c
56
57 #
58 # Receiver code
59 #
60 TELE_RECEIVER_SRC =\
61         ao_monitor.c \
62         ao_gps_print.c \
63         ao_packet_master.c \
64         ao_rssi.c
65
66 #
67 # Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
68 #
69
70 TELE_DRIVER_SRC = \
71         ao_convert.c \
72         ao_serial.c
73
74 #
75 # Debug dongle driver (only on TI)
76 #
77 DBG_SRC = \
78         ao_dbg.c
79
80 #
81 # Drivers only on TeleMetrum
82 #
83 TM_DRIVER_SRC = \
84         ao_adc.c \
85         ao_gps_report.c \
86         ao_ignite.c
87
88 #
89 # 25LC1024 driver source
90 EE_DRIVER_SRC = \
91         ao_ee.c
92
93 #
94 # AT45DB161D driver source
95
96 FLASH_DRIVER_SRC = \
97         ao_flash.c
98
99 #
100 # SiRF driver source
101 #
102 SIRF_DRIVER_SRC = \
103         ao_gps_sirf.c
104 #
105 # Skytraq driver source
106 #
107 SKY_DRIVER_SRC = \
108         ao_gps_skytraq.c
109
110 #
111 # Tasks run on TeleMetrum
112 #
113 TM_TASK_SRC = \
114         ao_flight.c \
115         ao_log.c \
116         ao_report.c \
117         ao_telemetry.c
118
119 TM_MAIN_SRC = \
120         ao_telemetrum.c
121
122 #
123 # Base sources for TeleMetrum
124 #
125 TM_BASE_SRC = \
126         $(ALTOS_SRC) \
127         $(ALTOS_DRIVER_SRC) \
128         $(TELE_DRIVER_SRC) \
129         $(TELE_COMMON_SRC) \
130         $(TM_DRIVER_SRC) \
131         $(TM_TASK_SRC) \
132         $(TM_MAIN_SRC)
133
134 TI_MAIN_SRC = \
135         ao_tidongle.c
136
137 #
138 # All sources for the TI debug dongle
139 #
140 TI_SRC = \
141         $(ALTOS_SRC) \
142         $(ALTOS_DRIVER_SRC) \
143         $(TELE_RECEIVER_SRC) \
144         $(TELE_COMMON_SRC) \
145         $(TI_MAIN_SRC) \
146         $(DBG_SRC)
147
148 TT_MAIN_SRC = \
149         ao_teleterra.c
150 #
151 # All sources for TeleTerra
152 #
153 TT_SRC = \
154         $(ALTOS_SRC) \
155         $(ALTOS_DRIVER_SRC) \
156         $(TELE_RECEIVER_SRC) \
157         $(TELE_DRIVER_SRC) \
158         $(TELE_COMMON_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         $(TD_MAIN_SRC)
175
176 include Makefile.defs
177
178 CFLAGS += $(PRODUCT_DEF) -I.
179
180 NICKLE=nickle
181 CHECK_STACK=sh ../check-stack
182
183 REL=$(SRC:.c=.rel) ao_product.rel
184 ADB=$(REL:.rel=.adb)
185 ASM=$(REL:.rel=.asm)
186 LNK=$(REL:.rel=.lnk)
187 LST=$(REL:.rel=.lst)
188 RST=$(REL:.rel=.rst)
189 SYM=$(REL:.rel=.sym)
190
191 PCDB=$(PROG:.ihx=.cdb)
192 PLNK=$(PROG:.ihx=.lnk)
193 PMAP=$(PROG:.ihx=.map)
194 PMEM=$(PROG:.ihx=.mem)
195 PAOM=$(PROG:.ihx=)
196
197 V=0
198 # The user has explicitly enabled quiet compilation.
199 ifeq ($(V),0)
200 quiet = @printf "  $1 $2 $@\n"; $($1)
201 endif
202 # Otherwise, print the full command line.
203 quiet ?= $($1)
204
205 %.rel : %.c $(INC)
206         $(call quiet,CC,$(PRODUCT_DEF)) $(CFLAGS) -c -o$@ $<
207
208 all: ../$(PROG)
209
210 ../$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
211         $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) ..
212         $(call quiet,CHECK_STACK) ../ao.h $(PMEM)
213
214 ../altitude.h: make-altitude
215         nickle $< > $@
216
217 ao_product.h: ao-make-product.5c ../Version
218         $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
219
220 ao_product.rel: ao_product.c ao_product.h
221         $(call quiet,CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"ao_product.h\"' -o$@ $<
222
223 distclean:      clean
224
225 clean:
226         rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
227         rm -f $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
228         rm -f ao_product.h
229         rm -f ../$(PROG)
230
231 install:
232
233 uninstall: