summaryrefslogtreecommitdiff
path: root/src/Makefile.proto
blob: ee3b4d6c60a3a23027447125be341ee3a2aaba66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#
# AltOS build
#
#
vpath %.c ..
vpath %.h ..
vpath make-altitude ..
vpath ao-make-product.5c ..

CC=sdcc

ifndef VERSION
include ../Version
endif

CFLAGS=--model-small --debug --opt-code-speed -DCODESIZE=$(CODESIZE)

CODESIZE ?= 0x8000

LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size $(CODESIZE) \
	--xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff

INC = \
	ao.h \
	ao_pins.h \
	cc1111.h \
	altitude.h \
	25lc1024.h

#
# Common AltOS sources
#
ALTOS_SRC = \
	ao_cmd.c \
	ao_dma.c \
	ao_mutex.c \
	ao_panic.c \
	ao_task.c \
	ao_timer.c \
	ao_romconfig.c \
	_bp.c

#
# Shared AltOS drivers
#
ALTOS_DRIVER_SRC = \
	ao_config.c \
	ao_led.c \
	ao_radio.c \
	ao_stdio.c

BEEP_DRIVER_SRC = \
	ao_beep.c

USB_DRIVER_SRC = \
	ao_usb.c

TELE_COMMON_SRC = \
	ao_packet.c \
	ao_packet_slave.c \
	ao_state.c

#
# Receiver code
#
TELE_RECEIVER_SRC =\
	ao_monitor.c \
	ao_gps_print.c \
	ao_packet_master.c \
	ao_rssi.c

#
# Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
#

TELE_DRIVER_SRC = \
	ao_convert.c

#
# Serial port driver
#
SERIAL_DRIVER_SRC = \
	ao_serial.c

#
# Spi bus driver
#
SPI_DRIVER_SRC = \
	ao_spi.c

#
# Debug dongle driver (only on TI)
#
DBG_SRC = \
	ao_dbg.c

#
# Drivers only on TeleMetrum
#
TM_DRIVER_SRC = \
	ao_adc.c \
	ao_gps_report.c \
	ao_ignite.c \
	$(BEEP_DRIVER_SRC) \
	$(USB_DRIVER_SRC)

#
# 25LC1024 driver source
EE_DRIVER_SRC = \
	ao_storage.c \
	ao_ee.c

#
# AT45DB161D driver source

FLASH_DRIVER_SRC = \
	ao_storage.c \
	ao_flash.c

#
# Numonyx M25P80 driver source
#

M25_DRIVER_SRC = \
	ao_storage.c \
	ao_m25.c

#
# SiRF driver source
#
SIRF_DRIVER_SRC = \
	ao_gps_sirf.c
#
# Skytraq driver source
#
SKY_DRIVER_SRC = \
	ao_gps_skytraq.c

#
# Tasks run on TeleMetrum
#
TM_TASK_SRC = \
	ao_flight.c \
	ao_log.c \
	ao_report.c \
	ao_telemetry.c

TM_MAIN_SRC = \
	ao_telemetrum.c

#
# Base sources for TeleMetrum
#
TM_BASE_SRC = \
	$(ALTOS_SRC) \
	$(ALTOS_DRIVER_SRC) \
	$(TELE_DRIVER_SRC) \
	$(SERIAL_DRIVER_SRC) \
	$(TELE_COMMON_SRC) \
	$(TM_DRIVER_SRC) \
	$(TM_TASK_SRC) \
	$(TM_MAIN_SRC)

#
# Sources for TeleMini
TMINI_DRIVER_SRC = \
	ao_adc.c \
	ao_ignite.c \
	ao_config.c \
	ao_storage.c \
	ao_intflash.c

TMINI_TASK_SRC = \
	ao_flight.c \
	ao_log.c \
	ao_report.c \
	ao_telemetry.c

TMINI_MAIN_SRC = \
	ao_telemini.c

TMINI_BASE_SRC = \
	$(ALTOS_SRC) \
	$(ALTOS_DRIVER_SRC) \
	$(TELE_DRIVER_SRC) \
	$(TELE_COMMON_SRC) \
	$(TMINI_DRIVER_SRC) \
	$(TMINI_TASK_SRC) \
	$(TMINI_MAIN_SRC)

TI_MAIN_SRC = \
	ao_tidongle.c

#
# All sources for the TI debug dongle
#
TI_SRC = \
	$(ALTOS_SRC) \
	$(ALTOS_DRIVER_SRC) \
	$(TELE_RECEIVER_SRC) \
	$(TELE_COMMON_SRC) \
	$(USB_DRIVER_SRC) \
	$(TI_MAIN_SRC) \
	$(DBG_SRC)

TT_MAIN_SRC = \
	ao_teleterra.c
#
# All sources for TeleTerra
#
TT_SRC = \
	$(ALTOS_SRC) \
	$(ALTOS_DRIVER_SRC) \
	$(TELE_RECEIVER_SRC) \
	$(TELE_DRIVER_SRC) \
	$(TELE_COMMON_SRC) \
	$(USB_DRIVER_SRC) \
	$(TT_MAIN_SRC)


#
# Sources for TeleDongle
#

TD_MAIN_SRC = \
	ao_teledongle.c

TD_SRC = \
	$(ALTOS_SRC) \
	$(ALTOS_DRIVER_SRC) \
	$(TELE_RECEIVER_SRC) \
	$(TELE_COMMON_SRC) \
	$(USB_DRIVER_SRC) \
	$(TD_MAIN_SRC)

include Makefile.defs

CFLAGS += $(PRODUCT_DEF) -I.

NICKLE=nickle
CHECK_STACK=sh ../check-stack

REL=$(SRC:.c=.rel) ao_product.rel
ADB=$(REL:.rel=.adb)
ASM=$(REL:.rel=.asm)
LNK=$(REL:.rel=.lnk)
LST=$(REL:.rel=.lst)
RST=$(REL:.rel=.rst)
SYM=$(REL:.rel=.sym)

PCDB=$(PROG:.ihx=.cdb)
PLNK=$(PROG:.ihx=.lnk)
PMAP=$(PROG:.ihx=.map)
PMEM=$(PROG:.ihx=.mem)
PAOM=$(PROG:.ihx=)

V=0
# The user has explicitly enabled quiet compilation.
ifeq ($(V),0)
quiet = @printf "  $1 $2 $@\n"; $($1)
endif
# Otherwise, print the full command line.
quiet ?= $($1)

%.rel : %.c $(INC)
	$(call quiet,CC,$(PRODUCT_DEF)) $(CFLAGS) -c -o$@ $<

all: ../$(PROG)

../$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
	$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) ..
	$(call quiet,CHECK_STACK) ../ao.h $(PMEM)

../altitude.h: make-altitude
	nickle $< > $@

ao_product.h: ao-make-product.5c ../Version
	$(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@

ao_product.rel: ao_product.c ao_product.h
	$(call quiet,CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"ao_product.h\"' -o$@ $<

distclean:	clean

clean:
	rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
	rm -f $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
	rm -f ao_product.h
	rm -f ../$(PROG)

install:

uninstall: