]> www.average.org Git - sensor-light.git/blobdiff - msp430/Makefile
Initial Makefile
[sensor-light.git] / msp430 / Makefile
diff --git a/msp430/Makefile b/msp430/Makefile
new file mode 100644 (file)
index 0000000..74948f3
--- /dev/null
@@ -0,0 +1,37 @@
+# Makefile for the MCU firmware
+
+# Must supply TOOLPATH, ARCH, MCU either in local.mk or in the make command line
+# Example (toolchain in the system default location):
+#TOOLPATH := /usr
+#ARCH     := msp430-elf
+#MCU      := msp430fr2433
+
+-include local.mk
+
+ifdef TOOLPATH
+ # OK
+else
+ $(error Must supply TOOLPATH, ARCH, MCU)
+endif
+
+BIN = $(TOOLPATH)/bin
+INC = $(TOOLPATH)/$(ARCH)/include
+LIB = $(TOOLPATH)/$(ARCH)/lib
+CC  = $(BIN)/$(ARCH)-gcc
+OBC = $(BIN)/$(ARCH)-objcopy
+CFLAGS = -mmcu=$(MCU) -g -I $(INC)
+LDFLAGS = -mmcu=$(MCU) -g
+
+.SUFFIXES: .elf .hex
+.PRECIOUS: %.o %.elf
+
+all: main.hex
+
+%.elf: %.o
+       $(CC) $(LDFLAGS) -o $@ $<
+
+%.hex: %.elf
+       $(OBC) -O ihex $< $@
+
+clean:
+       rm -f *.o *.elf