2012-09-13 14:06:32 +00:00
|
|
|
# PPC makefile scripts and rules.
|
|
|
|
|
|
|
|
# Output directory and files
|
|
|
|
ifeq ($(BUILDDIR),)
|
|
|
|
BUILDDIR = build
|
|
|
|
endif
|
|
|
|
ifeq ($(BUILDDIR),.)
|
|
|
|
BUILDDIR = build
|
|
|
|
endif
|
|
|
|
OUTFILES = $(BUILDDIR)/$(PROJECT).elf $(BUILDDIR)/$(PROJECT).hex \
|
2013-11-18 10:18:28 +00:00
|
|
|
$(BUILDDIR)/$(PROJECT).mot $(BUILDDIR)/$(PROJECT).bin \
|
|
|
|
$(BUILDDIR)/$(PROJECT).dmp
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
# Automatic compiler options
|
|
|
|
OPT = $(USE_OPT)
|
2011-11-02 20:39:26 +00:00
|
|
|
COPT = $(USE_COPT)
|
2010-02-19 18:19:00 +00:00
|
|
|
CPPOPT = $(USE_CPPOPT)
|
|
|
|
ifeq ($(USE_LINK_GC),yes)
|
|
|
|
OPT += -ffunction-sections -fdata-sections
|
|
|
|
endif
|
|
|
|
|
2012-09-13 12:45:07 +00:00
|
|
|
# VLE option handling.
|
|
|
|
ifeq ($(USE_VLE),yes)
|
|
|
|
DDEFS += -DPPC_USE_VLE=1
|
|
|
|
DADEFS += -DPPC_USE_VLE=1
|
|
|
|
MCU += -mvle
|
2012-10-04 08:23:45 +00:00
|
|
|
else
|
|
|
|
DDEFS += -DPPC_USE_VLE=0
|
|
|
|
DADEFS += -DPPC_USE_VLE=0
|
2012-09-13 12:45:07 +00:00
|
|
|
endif
|
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
# Source files groups and paths
|
|
|
|
SRC = $(CSRC)$(CPPSRC)
|
|
|
|
SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(SRC)))
|
|
|
|
|
|
|
|
# Various directories
|
|
|
|
OBJDIR = $(BUILDDIR)/obj
|
|
|
|
LSTDIR = $(BUILDDIR)/lst
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
# Object files groups
|
2012-09-13 14:06:32 +00:00
|
|
|
COBJS = $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o)))
|
|
|
|
CPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o)))
|
|
|
|
ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
|
|
|
|
ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
|
|
|
|
OBJS = $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS)
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
# Paths
|
|
|
|
IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
|
|
|
|
LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
|
|
|
|
|
|
|
# Macros
|
|
|
|
DEFS = $(DDEFS) $(UDEFS)
|
|
|
|
ADEFS = $(DADEFS) $(UADEFS)
|
|
|
|
|
|
|
|
# Libs
|
|
|
|
LIBS = $(DLIBS) $(ULIBS)
|
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
# Various settings
|
|
|
|
MCFLAGS = -mcpu=$(MCU)
|
|
|
|
ODFLAGS = -x --syms
|
|
|
|
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
|
|
|
ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
|
|
|
|
CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
|
|
|
|
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
|
|
|
|
ifeq ($(USE_LINK_GC),yes)
|
2013-04-02 10:42:41 +00:00
|
|
|
GCLDFLAGS = ,--gc-sections
|
2010-02-19 18:19:00 +00:00
|
|
|
else
|
2013-04-02 10:42:41 +00:00
|
|
|
GCLDFLAGS =
|
2010-02-19 18:19:00 +00:00
|
|
|
endif
|
2013-04-02 10:42:41 +00:00
|
|
|
ifneq ($(USE_LDOPT),)
|
|
|
|
XLDFLAGS =,$(USE_LDOPT)
|
|
|
|
else
|
|
|
|
XLDFLAGS =
|
|
|
|
endif
|
|
|
|
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch$(GCLDFLAGS)$(XLDFLAGS) $(LLIBDIR)
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
# Generate dependency information
|
2012-09-13 14:06:32 +00:00
|
|
|
CFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
|
|
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
|
|
|
|
|
|
# Paths where to search for sources
|
|
|
|
VPATH = $(SRCPATHS)
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Makefile rules
|
|
|
|
#
|
2012-09-13 14:06:32 +00:00
|
|
|
|
|
|
|
all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
|
2011-07-13 19:26:41 +00:00
|
|
|
|
|
|
|
MAKE_ALL_RULE_HOOK:
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
$(OBJS): | $(BUILDDIR)
|
|
|
|
|
|
|
|
$(BUILDDIR) $(OBJDIR) $(LSTDIR):
|
|
|
|
ifneq ($(USE_VERBOSE_COMPILE),yes)
|
|
|
|
@echo Compiler Options
|
|
|
|
@echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o
|
2010-02-19 18:19:00 +00:00
|
|
|
@echo
|
2012-09-13 14:06:32 +00:00
|
|
|
endif
|
|
|
|
mkdir -p $(OBJDIR)
|
|
|
|
mkdir -p $(LSTDIR)
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
@echo
|
2012-09-13 14:06:32 +00:00
|
|
|
$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
else
|
2012-11-05 14:52:50 +00:00
|
|
|
@echo Compiling $(<F)
|
2012-09-13 14:06:32 +00:00
|
|
|
@$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(COBJS) : $(OBJDIR)/%.o : %.c Makefile
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
|
|
@echo
|
|
|
|
$(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
else
|
2012-11-05 14:52:50 +00:00
|
|
|
@echo Compiling $(<F)
|
2012-09-13 14:06:32 +00:00
|
|
|
@$(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
$(ASMOBJS) : $(OBJDIR)/%.o : %.s Makefile
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
@echo
|
2012-09-13 14:06:32 +00:00
|
|
|
$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
else
|
2012-11-05 14:52:50 +00:00
|
|
|
@echo Compiling $(<F)
|
2012-09-13 14:06:32 +00:00
|
|
|
@$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
$(ASMXOBJS) : $(OBJDIR)/%.o : %.S Makefile
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
|
|
@echo
|
|
|
|
$(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
else
|
2012-11-05 14:52:50 +00:00
|
|
|
@echo Compiling $(<F)
|
2012-09-13 14:06:32 +00:00
|
|
|
@$(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
|
|
|
|
endif
|
|
|
|
|
|
|
|
%.elf: $(OBJS) $(LDSCRIPT)
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
@echo
|
|
|
|
$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
2012-09-13 14:06:32 +00:00
|
|
|
else
|
|
|
|
@echo Linking $@
|
|
|
|
@$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
%.hex: %.elf $(LDSCRIPT)
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
$(HEX) $< $@
|
2012-09-13 14:06:32 +00:00
|
|
|
else
|
|
|
|
@echo Creating $@
|
|
|
|
@$(HEX) $< $@
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2013-11-18 10:18:28 +00:00
|
|
|
%.mot: %.elf $(LDSCRIPT)
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
|
|
$(MOT) $< $@
|
|
|
|
else
|
|
|
|
@echo Creating $@
|
|
|
|
@$(MOT) $< $@
|
|
|
|
endif
|
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
%.bin: %.elf $(LDSCRIPT)
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
$(BIN) $< $@
|
2012-09-13 14:06:32 +00:00
|
|
|
else
|
|
|
|
@echo Creating $@
|
|
|
|
@$(BIN) $< $@
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
2012-09-13 14:06:32 +00:00
|
|
|
%.dmp: %.elf $(LDSCRIPT)
|
|
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
2010-02-19 18:19:00 +00:00
|
|
|
$(OD) $(ODFLAGS) $< > $@
|
2012-09-13 14:06:32 +00:00
|
|
|
else
|
|
|
|
@echo Creating $@
|
|
|
|
@$(OD) $(ODFLAGS) $< > $@
|
2013-11-18 10:18:28 +00:00
|
|
|
@echo
|
|
|
|
@$(SZ) $<
|
|
|
|
@echo
|
2012-09-13 14:06:32 +00:00
|
|
|
@echo Done
|
|
|
|
endif
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
clean:
|
2012-09-13 14:06:32 +00:00
|
|
|
@echo Cleaning
|
|
|
|
-rm -fR .dep $(BUILDDIR)
|
2013-11-18 10:18:28 +00:00
|
|
|
@echo
|
2012-09-13 14:06:32 +00:00
|
|
|
@echo Done
|
2010-02-19 18:19:00 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Include the dependency files, should be the last of the makefile
|
|
|
|
#
|
|
|
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
|
|
|
|
|
|
|
# *** EOF ***
|