muart-failsafe/Makefile

92 lines
2.3 KiB
Makefile

# Makefile for msp430
#
# 'make' builds everything for the production board
# 'make clean' deletes everything except source files and Makefile
# 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
#
TARGET = muart-failsafe
MSPDEBUG = mspdebug
MSPDEBUG_DRIVER ?= tilib
MSPDEBUG_DEVICE ?= /dev/ttyACM0
SOURCES = muart-failsafe.c
# Directory containing the MSPGCC toolchain
TOOLCHAIN_DIR ?=
TOOLCHAIN_BIN := $(TOOLCHAIN_DIR)/bin
TOOLCHAIN_INCLUDES := $(TOOLCHAIN_DIR)/include
#######################################################################################
CFLAGS = -mmcu=$(MCU) -Os -g -Wall -Wunused -I$(TOOLCHAIN_INCLUDES)
ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map -L$(TOOLCHAIN_INCLUDES)
########################################################################################
CC := $(TOOLCHAIN_BIN)/msp430-elf-gcc
LD := $(TOOLCHAIN_BIN)/msp430-elf-ld
SIZE := $(TOOLCHAIN_BIN)/msp430-elf-size
OBJCOPY := $(TOOLCHAIN_BIN)/msp430-elf-objcopy
MAKETXT := srec_cat
RM := rm -f
########################################################################################
# all the object files
OBJECTS := $(SOURCES:.c=.o)
.PHONY: prod dev
prod: MCU ?= msp430fr2000
prod: all
dev: CFLAGS += -DDEV_KIT
dev: MCU ?= msp430fr2311
dev: all
all: $(TARGET).elf $(TARGET).hex $(TARGET).txt
$(TARGET).elf: $(OBJECTS)
echo "Linking $@"
$(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
echo
echo ">>>> Size of Firmware <<<<"
$(SIZE) $(TARGET).elf
echo
%.hex: %.elf
$(OBJCOPY) -O ihex $< $@
%.txt: %.hex
$(MAKETXT) -O $@ -TITXT $< -I
unix2dos $(TARGET).txt
# 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.
%.o: %.c
echo "Compiling $<"
$(CC) -c $(CFLAGS) -o $@ $<
# rule for making assembler source listing, to see the code
%.lst: %.c
$(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
.PHONY: flash
flash: $(TARGET).elf
$(MSPDEBUG) $(MSPDEBUG_DRIVER) -d $(MSPDEBUG_DEVICE) "prog $(TARGET).elf"
.SILENT:
.PHONY: clean
clean:
-$(RM) $(OBJECTS)
-$(RM) $(TARGET).elf
-$(RM) $(TARGET).hex
-$(RM) $(TARGET).txt
-$(RM) $(TARGET).map
-$(RM) $(SOURCES:.c=.lst)
-$(RM) *.log
rm -rf Log