From d425f2ec12b111f01dfe854c638c18da2a279881 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 22 Feb 2009 09:56:36 +0000 Subject: Improved MSP430 makefile. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@801 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- ports/MSP430/rules.mk | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 ports/MSP430/rules.mk (limited to 'ports') diff --git a/ports/MSP430/rules.mk b/ports/MSP430/rules.mk new file mode 100644 index 000000000..7509ca662 --- /dev/null +++ b/ports/MSP430/rules.mk @@ -0,0 +1,87 @@ +# MSP430 makefile scripts and rules. + +# Automatic compiler options +OPT = $(USE_OPT) +CPPOPT = $(USE_CPPOPT) +ifeq ($(USE_CURRP_CACHING),yes) + OPT += -ffixed-r7 -DCH_CURRP_REGISTER_CACHE='"r7"' +endif +ifeq ($(USE_LINK_GC),yes) + OPT += -ffunction-sections -fdata-sections +endif + +# Source files groups +SRC = $(CSRC)$(CPPSRC) + +# Object files groups +COBJS = $(CSRC:.c=.o) +CPPOBJS = $(CPPSRC:.cpp=.o) +ASMOBJS = $(ASMSRC:.s=.o) +OBJS = $(ASMOBJS) $(COBJS) $(CPPOBJS) + +# Paths +IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) +LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) + +# Macros +DEFS = $(DDEFS) $(UDEFS) +ADEFS = $(DADEFS) $(UADEFS) + +# Libs +LIBS = $(DLIBS) $(ULIBS) + +MCFLAGS = -mmcu=$(MCU) +ODFLAGS = -x --syms +ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS) +CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS) +ifeq ($(LINK_GC),yes) + LDFLAGS = $(MCFLAGS) -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR) +else + LDFLAGS = $(MCFLAGS) -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR) +endif + +# Generate dependency information +CPFLAGS += -MD -MP -MF .dep/$(@F).d + +# +# Makefile rules +# +all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp + +$(CPPOBJS) : %.o : %.cpp + @echo + $(CPPC) -c $(CPPFLAGS) -I . $(IINCDIR) $< -o $@ + +$(COBJS) : %.o : %.c + @echo + $(CC) -c $(CPFLAGS) -I . $(IINCDIR) $< -o $@ + +$(ASMOBJS) : %.o : %.s + @echo + $(AS) -c $(ASFLAGS) -I . $(IINCDIR) $< -o $@ + +%elf: $(OBJS) + @echo + $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ + +%hex: %elf + $(HEX) $< $@ + +%bin: %elf + $(BIN) $< $@ + +%dmp: %elf + $(OD) $(ODFLAGS) $< > $@ + +clean: + -rm -f $(OBJS) + -rm -f $(ACSRC:.c=.lst) $(TCSRC:.c=.lst) $(ACPPSRC:.cpp=.lst) $(TCPPSRC:.cpp=.lst) $(ASMSRC:.s=.lst) + -rm -f $(PROJECT).elf $(PROJECT).dmp $(PROJECT).map $(PROJECT).hex $(PROJECT).bin + -rm -fR .dep + +# +# Include the dependency files, should be the last of the makefile +# +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + +# *** EOF *** -- cgit v1.2.3