📄 makefile
字号:
# Regular objects are created as # $(OBJ_ROOT_DIR)/<path>/<filename>.o# where the path structure is maintained under the obj directory. This# applies for both absolute and relative paths; in the absolute path# case this means the entire source path will be recreated under the obj# directory. This is done to allow two source files with the same name# to be included as part of the project.## Note: On Cygwin, the path recreated under the obj directory will be # the cygpath -u output path.## Relative-path objects that begin with "../" cause problems under this # scheme, as $(OBJ_ROOT_DIR)/../<rest of path>/ can potentially put the object# files anywhere in the system, creating clutter and polluting the source tree.# As such, their paths are flattened - the object file created will be # $(OBJ_ROOT_DIR)/<filename>.o. Due to this, two files specified with # "../" in the beginning cannot have the same name in the project. VPATH # will be set for these sources to allow make to relocate the source file # via %.o rules.## The following lines separate the object list into the flatten and regular# lists, and then handles them as appropriate.FLATTEN_OBJ_LIST += $(strip $(foreach s,$(OBJ_LIST),$(if $(filter ../%,$s),$s)))REGULAR_OBJ_LIST += $(filter-out $(FLATTEN_OBJ_LIST),$(OBJ_LIST))FLATTEN_APP_OBJS := $(addprefix $(OBJ_ROOT_DIR)/, \ $(foreach s,$(FLATTEN_OBJ_LIST),$(notdir $s)))VPATH := $(sort $(dir $(FLATTEN_OBJ_LIST)))APP_OBJS := $(addprefix $(OBJ_ROOT_DIR)/, \ $(foreach s,$(REGULAR_OBJ_LIST),$(call adjust-path,$s))) \ $(FLATTEN_APP_OBJS)# Add any extra user-provided object files.APP_OBJS += $(OBJS)# Create list of dependancy files for each object file.APP_DEPS := $(APP_OBJS:.o=.d)#------------------------------------------------------------------------------# BUILD PRE/POST PROCESS#------------------------------------------------------------------------------build_pre_process : $(BUILD_PRE_PROCESS)build_post_process : $(BUILD_POST_PROCESS).PHONY: build_pre_process build_post_process#------------------------------------------------------------------------------# PATTERN RULES TO BUILD OBJECTS#------------------------------------------------------------------------------$(OBJ_ROOT_DIR)/%.o: %.c @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CC) -MD -c $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $< $(CC_POST_PROCESS)$(OBJ_ROOT_DIR)/%.o: %.cpp @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -MD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $< $(CXX_POST_PROCESS)$(OBJ_ROOT_DIR)/%.o: %.cc @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -MD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $< $(CXX_POST_PROCESS)$(OBJ_ROOT_DIR)/%.o: %.cxx @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -MD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $< $(CXX_POST_PROCESS)$(OBJ_ROOT_DIR)/%.o: %.S @echo Info: Assembling $< to $@ @mkdir -p $(dir $@) $(AS) -MD -c $(APP_CPPFLAGS) $(APP_CFLAGS) $(APP_ASFLAGS) -o $@ $< $(AS_POST_PROCESS)$(OBJ_ROOT_DIR)/%.o: %.s @echo Info: Assembling $< to $@ @mkdir -p $(dir $@) $(AS) -MD -c $(APP_CFLAGS) $(APP_ASFLAGS) -o $@ $< $(AS_POST_PROCESS)#------------------------------------------------------------------------------# PATTERN RULES TO INTERMEDIATE FILES#------------------------------------------------------------------------------$(OBJ_ROOT_DIR)/%.s: %.c @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CC) -S $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.s: %.cpp @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.s: %.cc @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.s: %.cxx @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.i: %.c @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CC) -E $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.i: %.cpp @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.i: %.cc @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<$(OBJ_ROOT_DIR)/%.i: %.cxx @echo Info: Compiling $< to $@ @mkdir -p $(dir $@) $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<#------------------------------------------------------------------------------# TARGET RULES#------------------------------------------------------------------------------.PHONY : helphelp : @echo 'Summary of Makefile targets' @echo ' Build targets:' @echo ' all (default) - Application and all libraries (including BSP)' @echo ' bsp - Just the BSP' @echo ' libs - All libraries (including BSP)' @echo ' flash - All flash files' @echo ' mem_init_install - All memory initialization files' @echo ' Clean targets:' @echo ' clean_all - Application and all libraries (including BSP)' @echo ' clean - Just the application' @echo ' clean_bsp - Just the BSP' @echo ' clean_libs - All libraries (including BSP)' @echo ' Run targets:' @echo ' download-elf - Download and run your elf executable' @echo ' program-flash - Program flash contents to the board'# Handy rule to skip making libraries and just make application..PHONY : appapp : $(ELF)ifeq ($(CREATE_OBJDUMP), 1)app : $(OBJDUMP_NAME)endififeq ($(CREATE_ELF_DERIVED_FILES),1)app : elf_derived_filesendif# Handy rule for making just the BSP..PHONY : bspbsp : $(BSP_ROOT_DIR) @echo Info: Building $< @$(MAKE) --no-print-directory -C $<# Make sure all makeable libraries (including the BSP) are up-to-date..PHONY : libslibs : @for library_dir in $(MAKEABLE_LIBRARY_ROOT_DIRS); do \ echo Info: Building $$library_dir; \ $(MAKE) --no-print-directory -C $$library_dir; \ done$(APP_LDDEPS): libs @true# Clean just the application..PHONY : cleanifeq ($(CREATE_ELF_DERIVED_FILES),1)clean : clean_elf_derived_fileselseclean :endif @echo Info: Cleaning application @$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR)# Clean just the BSP..PHONY : clean_bspclean_bsp : @echo Info: Cleaning $(BSP_ROOT_DIR) @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR) clean# Clean all makeable libraries including the BSP..PHONY : clean_libsclean_libs : @for library_dir in $(MAKEABLE_LIBRARY_ROOT_DIRS); do \ echo Info: Cleaning $$library_dir; \ $(MAKE) --no-print-directory -C $$library_dir clean; \ done# Clean application and all makeable libraries including the BSP..PHONY : clean_allclean_all : clean mem_init_clean @for library_dir in $(MAKEABLE_LIBRARY_ROOT_DIRS); do \ echo Info: Cleaning $$library_dir; \ $(MAKE) --no-print-directory -C $$library_dir clean; \ done# Include the dependency files unless the make goal is performing a clean# of the application.ifneq ($(firstword $(MAKECMDGOALS)),clean)ifneq ($(firstword $(MAKECMDGOALS)),clean_all)-include $(APP_DEPS)endifendif.PHONY : download-elfdownload-elf : $(ELF) @echo Info: Downloading $(ELF) $(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(SOPC_SYSID_FLAG) $(WRITE_GMON_OPTION) $(ELF)# Delete the target of a rule if it has changed and its commands exit # with a nonzero exit status..DELETE_ON_ERROR:# Rules for flash programming commandsPROGRAM_FLASH_SUFFIX := -programPROGRAM_FLASH_TARGET := $(addsuffix $(PROGRAM_FLASH_SUFFIX), $(FLASH_FILES)).PHONY : program-flashprogram-flash : $(PROGRAM_FLASH_TARGET).PHONY : $(PROGRAM_FLASH_TARGET)$(PROGRAM_FLASH_TARGET) : flash @echo Info: Programming $(basename $@).flash @if [ -z "$($(basename $@)_EPCS_FLAGS)" ]; \ then \ echo $(FLASHPROG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \ $(FLASHPROG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \ else \ echo $(FLASHPROG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \ $(FLASHPROG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \ fi#------------------------------------------------------------------------------# ELF TARGET RULE#------------------------------------------------------------------------------# Rule for constructing the executable elf file.$(ELF) : $(APP_OBJS) $(LINKER_SCRIPT) $(APP_LDDEPS) @echo Info: Linking $@ $(LD) -T'$(LINKER_SCRIPT)' $(APP_LDFLAGS) $(APP_CFLAGS) -o $@ $(filter-out $(CRT0),$(APP_OBJS)) $(APP_LIBS) $(APP_BSP_DEP_LIBS) @$(STACKREPORT) $@$(OBJDUMP_NAME) : $(ELF) @echo Info: Creating $@ $(OBJDUMP) $(OBJDUMP_FLAGS) $< >$@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -