altos: Move common build definitions to src/Makefile.defs
[fw/altos] / src / Makefile.defs
diff --git a/src/Makefile.defs b/src/Makefile.defs
new file mode 100644 (file)
index 0000000..6df0c3f
--- /dev/null
@@ -0,0 +1,56 @@
+include $(TOPDIR)/Makedefs
+
+AO_VPATH=$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/kernel:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR)/aes:$(TOPDIR)/math:$(TOPDIR)/draw:$(TOPDIR)
+vpath make-altitude $(TOPDIR)/util
+vpath make-kalman $(TOPDIR)/util
+vpath kalman.5c $(TOPDIR)/kalman
+vpath kalman_filter.5c $(TOPDIR)/kalman
+vpath load_csv.5c $(TOPDIR)/kalman
+vpath matrix.5c $(TOPDIR)/kalman
+vpath ao-make-product.5c $(TOPDIR)/util
+
+WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align \
+       -Wpointer-arith \
+       -Wstrict-prototypes \
+       -Wmissing-prototypes \
+       -Wmissing-declarations \
+       -Wnested-externs \
+       -Wshadow \
+       -Warray-bounds=2
+
+OPT=-Os
+
+NEWLIB_CFLAGS= \
+       -ffreestanding -nostdlib \
+       -DNEWLIB_INTEGER_PRINTF_SCANF \
+       -isystem $(NEWLIB_NANO)/arm-none-eabi/include
+
+AO_CFLAGS=\
+       -std=gnu99 \
+       -I. -I$(TOPDIR) -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \
+       -I$(TOPDIR)/math -I$(TOPDIR)/draw -I$(TOPDIR)/product $(WARN_FLAGS) $(OPT) -g
+
+NICKLE=nickle
+ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex
+
+.SUFFIXES: .elf .ihx
+
+.elf.ihx:
+       $(ELFTOHEX) --output=$@ $*.elf
+
+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)
+
+.c.o:
+       $(call quiet,CC) -c $(CFLAGS) -o $@ $<
+
+.DEFAULT_GOAL=all
+
+ao_product.h: ao-make-product.5c $(TOPDIR)/Makedefs
+       $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+