123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- # e200z common makefile scripts and rules.
- ##############################################################################
- # Processing options coming from the upper Makefile.
- #
- # Compiler options
- OPT = $(USE_OPT)
- COPT = $(USE_COPT)
- CPPOPT = $(USE_CPPOPT)
- # Garbage collection
- ifeq ($(USE_LINK_GC),yes)
- OPT += --no_commons
- LDOPT := -delete
- endif
- # Linker extra options
- ifneq ($(USE_LDOPT),)
- LDOPT := $(LDOPT) $(USE_LDOPT)
- endif
- # Link time optimizations
- ifeq ($(USE_LTO),yes)
- OPT += -Owholeprogram
- endif
- # VLE option handling.
- ifeq ($(USE_VLE),yes)
- DDEFS += -DPPC_USE_VLE=1
- DADEFS += -DPPC_USE_VLE=1
- OPT += -vle
- COPT += -vle
- else
- DDEFS += -DPPC_USE_VLE=0
- DADEFS += -DPPC_USE_VLE=0
- endif
- # Process stack size
- ifeq ($(USE_PROCESS_STACKSIZE),)
- LDOPT := $(LDOPT) -C__process_stack_size__=0x400 #,--defsym=__process_stack_size__=0x400
- else
- LDOPT := $(LDOPT) -C__process_stack_size__=$(USE_PROCESS_STACKSIZE) #,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE)
- endif
- # Exceptions stack size
- ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
- LDOPT := $(LDOPT) -C__irq_stack_size__=0x400 #,--defsym=__irq_stack_size__=0x400
- else
- LDOPT := $(LDOPT) -C__irq_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) #,--defsym=__irq_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
- endif
- # Output directory and files
- ifeq ($(BUILDDIR),)
- BUILDDIR = build
- endif
- ifeq ($(BUILDDIR),.)
- BUILDDIR = build
- endif
- OUTFILES = $(BUILDDIR)/$(PROJECT).elf $(BUILDDIR)/$(PROJECT).hex \
- $(BUILDDIR)/$(PROJECT).mot $(BUILDDIR)/$(PROJECT).bin \
- $(BUILDDIR)/$(PROJECT).dmp
- # Source files groups and paths
- SRC = $(CSRC)$(CPPSRC)
- SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(SRC)))
- # Various directories
- OBJDIR = $(BUILDDIR)/obj
- LSTDIR = $(BUILDDIR)/lst
- # Object files groups
- 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)
- # Paths
- IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
- LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
- # Macros
- DEFS = $(DDEFS) $(UDEFS)
- ADEFS = $(DADEFS) $(UADEFS)
- # Libs
- LIBS = $(DLIBS) $(ULIBS)
- # Various settings
- WARN = --incorrect_pragma_warnings --unknown_pragma_warnings --prototype_warnings --diag_error 236
- LIST = -list -tmp=$(OBJDIR)
- MCFLAGS = -cpu=$(MCU)
- ODFLAGS = -ysec -full
- ASFLAGS = $(MCFLAGS) $(OPT) $(LIST) -list=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS) $(WARN) -preprocess_assembly_files
- ASXFLAGS = $(MCFLAGS) $(OPT) $(LIST) -list=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS) $(WARN) -preprocess_assembly_files
- CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) $(LIST) -list=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
- CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) $(LIST) -list=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
- LDFLAGS := $(MCFLAGS) $(OPT) -nostartfiles $(LLIBDIR)
- LDFLAGS += -map=$(BUILDDIR)/$(PROJECT).map
- LDFLAGS += -Mx
- LDFLAGS += $(LDOPT)
- LDFLAGS += $(LDSCRIPT)
- # Generate dependency information
- ASFLAGS += -MD
- ASXFLAGS += -MD
- CFLAGS += -MD
- CPPFLAGS += -MD
- # Paths where to search for sources
- VPATH = $(SRCPATHS)
- #
- # Makefile rules
- #
- all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK
- PRE_MAKE_ALL_RULE_HOOK:
- POST_MAKE_ALL_RULE_HOOK:
- $(OBJS): | PRE_MAKE_ALL_RULE_HOOK $(BUILDDIR) $(OBJDIR) $(LSTDIR) $(DEPDIR)
- $(BUILDDIR):
- ifneq ($(USE_VERBOSE_COMPILE),yes)
- @echo Compiler Options
- @echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o
- @echo
- endif
- @mkdir -p $(BUILDDIR)
- $(OBJDIR):
- @mkdir -p $(OBJDIR)
- $(LSTDIR):
- @mkdir -p $(LSTDIR)
- $(DEPDIR):
- @mkdir -p $(DEPDIR)
- $(CPPOBJS) : $(OBJDIR)/%.o : %.cpp $(MAKEFILE_LIST)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
- else
- @echo Compiling $(<F)
- @$(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) $< -o $@
- endif
- $(COBJS) : $(OBJDIR)/%.o : %.c $(MAKEFILE_LIST)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
- else
- @echo Compiling $(<F)
- @$(CC) -c $(CFLAGS) -I. $(IINCDIR) $< -o $@
- endif
- $(ASMOBJS) : $(OBJDIR)/%.o : %.s $(MAKEFILE_LIST)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
- else
- @echo Compiling $(<F)
- @$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
- endif
- $(ASMXOBJS) : $(OBJDIR)/%.o : %.S $(MAKEFILE_LIST)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
- else
- @echo Compiling $(<F)
- @$(CC) -c $(ASXFLAGS) -I. $(IINCDIR) $< -o $@
- endif
- %.elf: $(OBJS) $(LDSCRIPT)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
- else
- @echo Linking $@
- @$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
- endif
- %.hex: %.elf $(LDSCRIPT)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- $(HEX) $< -o $@
- else
- @echo Creating $@
- @$(HEX) $< -o $@
- endif
- %.mot: %.elf $(LDSCRIPT)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- $(MOT) $< -o $@
- else
- @echo Creating $@
- @$(MOT) $< -o $@
- endif
- %.bin: %.elf $(LDSCRIPT)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- $(BIN) $< -o $@
- else
- @echo Creating $@
- @$(BIN) $< -o $@
- endif
- %.dmp: %.elf $(LDSCRIPT)
- ifeq ($(USE_VERBOSE_COMPILE),yes)
- $(OD) $(ODFLAGS) $< > $@
- else
- @echo Creating $@
- @$(OD) $(ODFLAGS) $< > $@
- @echo
- # @$(SZ) -addr -file -hex $<
- # @echo
- @echo Done
- endif
- lib: $(OBJS) $(BUILDDIR)/lib$(PROJECT).a
- $(BUILDDIR)/lib$(PROJECT).a: $(OBJS)
- @$(AR) -r $@ $^
- @echo
- @echo Done
- clean: CLEAN_RULE_HOOK
- @echo Cleaning
- @echo - $(DEPDIR)
- @-rm -fR $(DEPDIR)/* $(BUILDDIR)/* 2>/dev/null
- @-if [ -d "$(DEPDIR)" ]; then rmdir -p --ignore-fail-on-non-empty $(subst ./,,$(DEPDIR)) 2>/dev/null; fi
- @echo - $(BUILDDIR)
- @-if [ -d "$(BUILDDIR)" ]; then rmdir -p --ignore-fail-on-non-empty $(subst ./,,$(BUILDDIR)) 2>/dev/null; fi
- @echo
- @echo Done
- CLEAN_RULE_HOOK:
- #
- # Include the dependency files, should be the last of the makefile
- #
- -include $(wildcard $(DEPDIR)/*)
- # *** EOF ***
|