altos: Add telerepeat-v1.0
[fw/altos] / src / Makefile
index 8c24e6f43f31625315a13fbd3f4173dbd03d6ac9..20126de6771b336f1e54b631496e7a7ab07952c2 100644 (file)
 #
 # AltOS build
 #
-#
-CC=sdcc
 
-ifndef VERSION
-VERSION=$(shell git describe)
+vpath make-altitude util
+vpath make-altitude-pa util
+vpath make-kalman util
+vpath make-whiten util
+vpath kalman.5c kalman
+vpath kalman_filter.5c kalman
+vpath kalman_micro.5c kalman
+vpath load_csv.5c kalman
+vpath matrix.5c kalman
+
+include Version
+TOPDIR=.
+include Makedefs
+
+SDCCDIRS=\
+       telemetrum-v1.2 telemetrum-v1.1 telemetrum-v1.0 \
+       teledongle-v0.2 \
+       telemini-v1.0 telemini-v2.0 \
+       telebt-v1.0 \
+       teleterra-v0.2 teleshield-v0.1 \
+       telefire-v0.1 telefire-v0.2 \
+       telerepeat-v1.0
+
+ARMM3DIRS=\
+       easymega-v1.0 easymega-v1.0/flash-loader \
+       telemega-v0.1 telemega-v0.1/flash-loader \
+       telemega-v1.0 telemega-v1.0/flash-loader \
+       telemetrum-v2.0 telemetrum-v2.0/flash-loader \
+       megadongle-v0.1 megadongle-v0.1/flash-loader \
+       telegps-v0.3 telegps-v0.3/flash-loader \
+       telegps-v1.0 telegps-v1.0/flash-loader \
+       telelco-v0.2 telelco-v0.2/flash-loader \
+       telescience-v0.2 telescience-v0.2/flash-loader \
+       teleballoon-v2.0
+
+ARMM0DIRS=\
+       easymini-v1.0 easymini-v1.0/flash-loader
+
+AVRDIRS=\
+       telescience-v0.1 telescience-pwm micropeak nanopeak-v0.1 microkite
+
+SUBDIRS=
+
+ifeq ($(strip $(HAVE_PDCLIB)),yes)
+PDCLIB=pdclib
+CLEAN_PDCLIB=clean-pdclib
 endif
 
-CFLAGS=--model-small --debug --opt-code-speed
+ifeq ($(strip $(HAVE_SDCC)),yes)
+SUBDIRS+=$(SDCCDIRS)
+endif
 
-LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
-       --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
+ifeq ($(strip $(HAVE_ARM_M3_CC)),yes)
+SUBDIRS+=$(ARMM3DIRS)
+foo=bar
+endif
 
-INC = \
-       ao.h \
-       cc1111.h \
-       altitude.h \
-       25lc1024.h
+ifeq ($(strip $(HAVE_ARM_M0_CC)),yes)
+SUBDIRS+=$(ARMM0DIRS)
+baz=bletch
+endif
 
-#
-# Common AltOS sources
-#
-ALTOS_SRC = \
-       ao_cmd.c \
-       ao_dma.c \
-       ao_mutex.c \
-       ao_panic.c \
-       ao_task.c \
-       ao_timer.c \
-       _bp.c
+ifeq ($(strip $(HAVE_AVR_CC)),yes)
+SUBDIRS += $(AVRDIRS)
+endif
 
-#
-# Shared AltOS drivers
-#
-ALTOS_DRIVER_SRC = \
-       ao_beep.c \
-       ao_config.c \
-       ao_led.c \
-       ao_radio.c \
-       ao_stdio.c \
-       ao_usb.c
-
-TELE_COMMON_SRC = \
-       ao_gps_print.c \
-       ao_packet.c \
-       ao_packet_slave.c \
-       ao_state.c
+ALLDIRS=$(SDCCDIRS) $(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS)
 
-#
-# Receiver code
-#
-TELE_RECEIVER_SRC =\
-       ao_monitor.c \
-       ao_packet_master.c \
-       ao_rssi.c
+all: all-local all-recursive
 
-#
-# Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
-#
+RECURSIVE_TARGETS = all-recursive install-recursive
 
-TELE_DRIVER_SRC = \
-       ao_convert.c \
-       ao_serial.c
+$(RECURSIVE_TARGETS):
+       @target=`echo $@ | sed 's/-recursive//'`; \
+       for subdir in $(SUBDIRS); do \
+               echo "Making $$target in $$subdir"; \
+               (cd $$subdir && $(MAKE) $$target) || exit 1; \
+       done
 
-#
-# Drivers for partially-flled boards (TT, TD and TI)
-#
-TELE_FAKE_SRC = \
-       ao_adc_fake.c \
-       ao_ee_fake.c
-
-#
-# Debug dongle driver (only on TI)
-#
-DBG_DONGLE_SRC = \
-       ao_dbg.c
-
-#
-# Drivers only on TeleMetrum
-#
-TM_DRIVER_SRC = \
-       ao_adc.c \
-       ao_ee.c \
-       ao_gps_report.c \
-       ao_ignite.c
+ALL_RECURSIVE_TARGETS = clean-recursive
 
-#
-# Drivers only on TeleMetrum
-#
-TM_SIRF_DRIVER_SRC = \
-       ao_gps_sirf.c
-#
-# Drivers only on TeleMetrum
-#
-TM_SKY_DRIVER_SRC = \
-       ao_gps_skytraq.c
+$(ALL_RECURSIVE_TARGETS):
+       @target=`echo $@ | sed 's/-recursive//'`; \
+       for subdir in $(ALLDIRS); do \
+               echo "Making $$target in $$subdir"; \
+               (cd $$subdir && $(MAKE) $$target) || exit 1; \
+       done
 
-#
-# 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
+distclean:     clean
 
-#
-# All sources for TeleMetrum
-#
-TM_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_DRIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TM_DRIVER_SRC) \
-       $(TM_TASK_SRC) \
-       $(TM_MAIN_SRC)
-
-TM_SIRF_SRC = \
-       $(TM_SRC) \
-       $(TM_SIRF_DRIVER_SRC)
-
-TM_SKY_SRC = \
-       $(TM_SRC) \
-       $(TM_SKY_DRIVER_SRC)
-
-TI_MAIN_SRC = \
-       ao_tidongle.c
+clean: clean-local clean-recursive
 
-#
-# All sources for the TI debug dongle
-#
-TI_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TI_MAIN_SRC) \
-       $(DBG_DONGLE_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) \
-       $(TELE_FAKE_SRC) \
-       $(TT_MAIN_SRC)
+install: install-recursive
 
+uninstall:
 
-#
-# Sources for TeleDongle
-#
+all-recursive: all-local
 
-TD_MAIN_SRC = \
-       ao_teledongle.c
-
-TD_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TD_MAIN_SRC)
-
-SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TM_DRIVER_SRC) \
-       $(TM_SIRF_DRIVER_SRC) \
-       $(TM_SKY_DRIVER_SRC) \
-       $(TM_TASK_SRC) \
-       $(TM_MAIN_SRC) \
-       $(TI_MAIN_SRC) \
-       $(TD_MAIN_SRC) \
-       $(TT_MAIN_SRC)
-
-TM_SIRF_REL=$(TM_SIRF_SRC:.c=.rel) ao_product-telemetrum.rel
-TM_SKY_REL=$(TM_SKY_SRC:.c=.rel) ao_product-telemetrum.rel
-TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle.rel
-TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra.rel
-TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle.rel
-
-PROD_REL=\
-       ao_product-telemetrum.rel \
-       ao_product-tidongle.rel \
-       ao_product-teleterra.rel \
-       ao_product-teledongle.rel
-
-REL=$(SRC:.c=.rel) $(PROD_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)
-
-PROGS= telemetrum-sirf.ihx telemetrum-sky.ihx tidongle.ihx \
-       teleterra.ihx teledongle.ihx
-
-HOST_PROGS=ao_flight_test ao_gps_test ao_gps_test_skytraq
-
-PCDB=$(PROGS:.ihx=.cdb)
-PLNK=$(PROGS:.ihx=.lnk)
-PMAP=$(PROGS:.ihx=.map)
-PMEM=$(PROGS:.ihx=.mem)
-PAOM=$(PROGS:.ihx=)
-
-%.rel : %.c $(INC)
-       $(CC) -c $(CFLAGS) -o$*.rel $*.c
-
-all: $(PROGS) $(HOST_PROGS)
-
-telemetrum-sirf.ihx: $(TM_SIRF_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SIRF_REL)
-       sh check-stack ao.h telemetrum-sirf.mem
-
-telemetrum-sky.ihx: $(TM_SKY_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SKY_REL)
-       sh check-stack ao.h telemetrum-sky.mem
-
-telemetrum-sky.ihx: telemetrum-sirf.ihx
-
-tidongle.ihx: $(TI_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL)
-       sh check-stack ao.h tidongle.mem
-
-tidongle.ihx: telemetrum-sky.ihx
-
-teleterra.ihx: $(TT_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL)
-       sh check-stack ao.h teleterra.mem
-
-teleterra.ihx: tidongle.ihx
-
-teledongle.ihx: $(TD_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL)
-       sh check-stack ao.h teledongle.mem
-
-teledongle.ihx: teleterra.ihx
+all-local: altitude.h altitude-pa.h altitude-pa-small.h ao_kalman.h ao_whiten.h $(PDCLIB)
 
 altitude.h: make-altitude
-       nickle make-altitude > altitude.h
-
-TELEMETRUM_DEFS=ao-telemetrum.h
-TELETERRA_DEFS=ao-teleterra.h
-TELEDONGLE_DEFS=ao-teledongle.h
-TIDONGLE_DEFS=ao-tidongle.h
-
-ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \
-       $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
-ao_product-telemetrum.rel: ao_product.c $(TELEMETRUM_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c
-
-ao_product-teleterra.rel: ao_product.c $(TELETERRA_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c
-
-ao_product-teledongle.rel: ao_product.c $(TELEDONGLE_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c
-
-ao_product-tidongle.rel: ao_product.c $(TIDONGLE_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
+       nickle $< > $@
 
-$(TELEMETRUM_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -v $(VERSION) > $@
+altitude-pa.h: make-altitude-pa
+       nickle $< > $@
 
-$(TELETERRA_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -v $(VERSION) > $@
+altitude-pa-small.h: make-altitude-pa
+       nickle $< --sample 3 > $@
 
-$(TELEDONGLE_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -v $(VERSION) > $@
+ao_kalman.h: make-kalman kalman.5c kalman_micro.5c kalman_filter.5c load_csv.5c matrix.5c
+       bash $< kalman > $@
 
-$(TIDONGLE_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -v $(VERSION) > $@
-
-distclean:     clean
-
-clean:
-       rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
-       rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
-       rm -f $(ALL_DEFS) $(HOST_PROGS)
-       rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
-
-install:
-
-uninstall:
+ao_whiten.h: make-whiten
+       nickle $< > $@
 
-ao_flight_test: ao_flight.c ao_flight_test.c ao_host.h
-       cc -g -o $@ ao_flight_test.c
+clean-local: $(CLEAN_PDCLIB)
+       rm -f altitude.h ao_kalman.h
 
-ao_gps_test: ao_gps_sirf.c ao_gps_test.c ao_gps_print.c ao_host.h
-       cc -g -o $@ ao_gps_test.c
+pdclib:
+       mkdir -p $(PDCLIB_ROOT)/include $(PDCLIB_ROOT)/lib 
+       cd ../pdclib && make && make prefix=`pwd`/../pdclib-root install
 
-ao_gps_test_skytraq: ao_gps_skytraq.c ao_gps_test_skytraq.c ao_gps_print.c ao_host.h
-       cc -g -o $@ ao_gps_test_skytraq.c
+clean-pdclib:
+       rm -rf $(PDCLIB_ROOT)
+       cd ../pdclib && make clean