From 3457abe3f7a7f5ddc533a4f33759efcd5fe5a516 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 18 Feb 2009 21:24:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@786 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- ports/ARM7/rules.mk | 82 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 25 deletions(-) (limited to 'ports') diff --git a/ports/ARM7/rules.mk b/ports/ARM7/rules.mk index 884fc50e9..5748b3e21 100644 --- a/ports/ARM7/rules.mk +++ b/ports/ARM7/rules.mk @@ -1,35 +1,50 @@ -# ARM7 common makefile rules. +# ARM7 common 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 ifeq ($(USE_THUMB),yes) - TSRC += $(SRC) + TCSRC += $(CSRC) + TCPPSRC += $(CPPSRC) else - ASRC += $(SRC) + ACSRC += $(CSRC) + ACPPSRC += $(CPPSRC) endif - +ASRC = $(ACSRC)$(ACPPSRC) +TSRC = $(TCSRC)$(TCPPSRC) +SRC = $(ASRC)$(TSRC) + +# Object files groups +ACOBJS = $(ACSRC:.c=.o) +ACPPOBJS = $(ACPPSRC:.cpp=.o) +TCOBJS = $(TCSRC:.c=.o) +TCPPOBJS = $(TCPPSRC:.cpp=.o) +ASMOBJS = $(ASMSRC:.s=.o) +OBJS = $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) + +# Paths IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) + +# Macros DEFS = $(DDEFS) $(UDEFS) ADEFS = $(DADEFS) $(UADEFS) -AOBJS = $(ASRC:.c=.o) -TOBJS = $(TSRC:.c=.o) -OBJS = $(ASMOBJS) $(AOBJS) $(TOBJS) -ASMOBJS = $(ASMSRC:.s=.o) LIBS = $(DLIBS) $(ULIBS) -MCFLAGS = -mcpu=$(MCU) +# Various settings +MCFLAGS = -mcpu=$(MCU) ODFLAGS = -x --syms ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = $(MCFLAGS) $(OPT) $(WARN) -Wa,-alms=$(<:.c=.lst) $(DEFS) +CFLAGS = $(MCFLAGS) $(OPT) $(CWARN) -Wa,-alms=$(<:.c=.lst) $(DEFS) +CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(<:.cpp=.lst) $(DEFS) ifeq ($(LINK_GC),yes) LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR) else @@ -38,25 +53,30 @@ endif # Thumb interwork enabled only if needed because it kills performance. ifneq ($(TSRC),) - CPFLAGS += -DTHUMB_PRESENT + CFLAGS += -DTHUMB_PRESENT + CPPFLAGS += -DTHUMB_PRESENT ASFLAGS += -DTHUMB_PRESENT ifneq ($(ASRC),) # Mixed ARM and THUMB case. - CPFLAGS += -mthumb-interwork + CFLAGS += -mthumb-interwork + CPPFLAGS += -mthumb-interwork LDFLAGS += -mthumb-interwork else # Pure THUMB case, THUMB C code cannot be called by ARM asm code directly. - CPFLAGS += -mno-thumb-interwork -DTHUMB_NO_INTERWORKING + CFLAGS += -mno-thumb-interwork -DTHUMB_NO_INTERWORKING + CPPFLAGS += -mno-thumb-interwork -DTHUMB_NO_INTERWORKING LDFLAGS += -mno-thumb-interwork -mthumb ASFLAGS += -DTHUMB_NO_INTERWORKING endif else CPFLAGS += -mno-thumb-interwork + CPPFLAGS += -mno-thumb-interwork LDFLAGS += -mno-thumb-interwork endif # Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d +CFLAGS += -MD -MP -MF .dep/$(@F).d +CPPFLAGS += -MD -MP -MF .dep/$(@F).d # # Makefile rules @@ -64,13 +84,21 @@ CPFLAGS += -MD -MP -MF .dep/$(@F).d all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp -$(AOBJS) : %.o : %.c +$(ACPPOBJS) : %.o : %.cpp + @echo + $(CPPC) -c $(CPPFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@ + +$(TCPPOBJS) : %.o : %.cpp + @echo + $(CPPC) -c $(CPPFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@ + +$(ACOBJS) : %.o : %.c @echo - $(CC) -c $(CPFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@ + $(CC) -c $(CFLAGS) $(AOPT) -I . $(IINCDIR) $< -o $@ -$(TOBJS) : %.o : %.c +$(TCOBJS) : %.o : %.c @echo - $(CC) -c $(CPFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@ + $(CC) -c $(CFLAGS) $(TOPT) -I . $(IINCDIR) $< -o $@ $(ASMOBJS) : %.o : %.s @echo @@ -78,7 +106,7 @@ $(ASMOBJS) : %.o : %.s %elf: $(OBJS) @echo - $(CC) $(ASMOBJS) $(AOBJS) $(TOBJS) $(LDFLAGS) $(LIBS) -o $@ + $(LD) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) $(LDFLAGS) $(LIBS) -o $@ %hex: %elf $(HEX) $< $@ @@ -96,10 +124,14 @@ clean: -rm -f $(PROJECT).map -rm -f $(PROJECT).hex -rm -f $(PROJECT).bin - -rm -f $(ASRC:.c=.c.bak) - -rm -f $(ASRC:.c=.lst) - -rm -f $(TSRC:.c=.c.bak) - -rm -f $(TSRC:.c=.lst) + -rm -f $(ACSRC:.c=.c.bak) + -rm -f $(ACSRC:.c=.lst) + -rm -f $(TCSRC:.c=.c.bak) + -rm -f $(TCSRC:.c=.lst) + -rm -f $(ACPPSRC:.cpp=.c.bak) + -rm -f $(ACPPSRC:.cpp=.lst) + -rm -f $(TCPPSRC:.cpp=.c.bak) + -rm -f $(TCPPSRC:.cpp=.lst) -rm -f $(ASMSRC:.s=.s.bak) -rm -f $(ASMSRC:.s=.lst) -rm -fR .dep -- cgit v1.2.3