2010-02-19 10:19:00 -08:00
|
|
|
# PPC e200Z makefile scripts and rules.
|
|
|
|
|
|
|
|
# Automatic compiler options
|
|
|
|
OPT = $(USE_OPT)
|
2011-11-02 13:39:26 -07:00
|
|
|
COPT = $(USE_COPT)
|
2010-02-19 10:19:00 -08:00
|
|
|
CPPOPT = $(USE_CPPOPT)
|
|
|
|
ifeq ($(USE_LINK_GC),yes)
|
|
|
|
OPT += -ffunction-sections -fdata-sections
|
|
|
|
endif
|
|
|
|
|
2012-09-13 05:45:07 -07:00
|
|
|
# VLE option handling.
|
|
|
|
ifeq ($(USE_VLE),yes)
|
|
|
|
DDEFS += -DPPC_USE_VLE=1
|
|
|
|
DADEFS += -DPPC_USE_VLE=1
|
|
|
|
MCU += -mvle
|
|
|
|
endif
|
|
|
|
|
2010-02-19 10:19:00 -08:00
|
|
|
# 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 = -mcpu=$(MCU)
|
|
|
|
ODFLAGS = -x --syms
|
|
|
|
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
2011-11-02 13:39:26 -07:00
|
|
|
CPFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
|
2010-02-19 10:19:00 -08:00
|
|
|
ifeq ($(LINK_GC),yes)
|
|
|
|
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
|
|
|
|
else
|
|
|
|
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Generate dependency information
|
|
|
|
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
|
|
|
|
|
|
#
|
|
|
|
# Makefile rules
|
|
|
|
#
|
2011-07-13 12:26:41 -07:00
|
|
|
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp MAKE_ALL_RULE_HOOK
|
|
|
|
|
|
|
|
MAKE_ALL_RULE_HOOK:
|
2010-02-19 10:19:00 -08:00
|
|
|
|
|
|
|
$(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 $(CSRC:.c=.lst) $(CPPSRC:.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 ***
|