+# 'make' builds everything
+# 'make clean' deletes everything except source files and Makefile
+# 'make install' builds everything, and programs the MSP430 using MSPFLASHER
+# You need to set TARGET, MCU and SOURCES for your project.
+# TARGET is the name of the executable file to be produced
+# $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.
+# The TXT file is used for BSL loading, the ELF can be used for JTAG use
+MSPFLASHER = MSP430Flasher
+# List all the source files here
+# eg if you have a source file foo.c then list it here
+SOURCES = main.c delay.c
+# Include are located in the Include directory
+# Add or subtract whatever MSPGCC flags you want. There are plenty more
+#######################################################################################
+CFLAGS = -mmcu=$(MCU) -g -Os -Wall -Wunused $(INCLUDES)
+ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
+LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map
+########################################################################################
+OBJCOPY = msp430-elf-objcopy
+RANLIB = msp430-elf-ranlib
+STRIP = msp430-elf-strip
+READELF = msp430-elf-readelf
+########################################################################################
+# the file which will include dependencies
+DEPEND = $(SOURCES:.c=.d)
+OBJECTS = $(SOURCES:.c=.o)
+all: $(TARGET).elf $(TARGET).hex $(TARGET).txt
+$(TARGET).elf: $(OBJECTS)
+ $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
+ echo ">>>> Size of Firmware <<<<"
+ $(OBJCOPY) -O ihex $< $@
+ $(MAKETXT) -O $@ -TITXT $< -I
+# The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems.
+ $(CC) -c $(CFLAGS) -o $@ $<
+# rule for making assembler source listing, to see the code
+ $(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
+# include the dependencies unless we're going to clean, then forget about them.
+ifneq ($(MAKECMDGOALS), clean)
+# includes also considered, since some of these are our own
+# (otherwise use -MM instead of -M)
+ echo "Generating dependencies $@ from $<"
+ $(CC) -M ${CFLAGS} $< >$@
+ -$(RM) $(SOURCES:.c=.lst)
+ $(MSPFLASHER) -n $(MCU) -w "$(TARGET).txt" -v -z [VCC]