📄 makefile
字号:
# Limit for image (look in link/link.xn for current value)MAX_ADDRESS = 9fc78000endif # ifeq ($(ENDIAN,EB))else # ifdef ENDIAN# If ENDIAN is not defined, this makefile was called from the command prompt# (i.e. "make"). # We will first make the boot vector code that determines endianness, then# make the little- and big-endian images, then concatenate them.# Setup the definitions required to make the boot vector code that # determines endianness (from bin directory).# Root directory of YAMON source code.ROOT = ./..# Directory where make is supposed to be invoked.MAKEDIR = .# Directory where linker scripts reside.LINKDIR = $(MAKEDIR)/link# The boot vector code is arbitrarily compiled for big endian.ENDIAN = EB# Only one directory holds the source files for the boot vector code.SRCDIR = $(ROOT)/arch/reset/bootvector# Linker script.ifdef SIMULATELD_SCRIPT = $(LINKDIR)/link_sim.xnelseLD_SCRIPT = $(LINKDIR)/link.xnendif# The reset code.IMAGE_ELF = ./$(RESET).elfIMAGE_SREC = ./$(RESET).recIMAGE_MAP = ./$(RESET).mapIMAGE_DIS = ./$(RESET).dis# The concatenated srecord fileIMAGE_SREC_CONCAT = ./$(IMAGENAME).rec# The final flash image.IMAGE_FLASH = ./$(IMAGENAME).fl# Paths for making the little- and big-endian images.EL_PATH = ./ELEB_PATH = ./EBendif # ifdef ENDIAN# Workaround for 25Kf with Bonito - arch/pci/platform/core/pci_core.c# WORKAROUND_BONITO = -DBONITO_DEVID_HACK# Workaround in case caches don't work# WORKAROUND_NO_CACHE = -DNO_CACHE# Option in case we want KSEG0 to be uncached# KSEG0_UNCACHED = -DKSEG0_UNCACHED# Difference between WORKAROUND_NO_CACHE and KSEG0_UNCACHED is :# # * If WORKAROUND_NO_CACHE is defined, NO cacheops are used, and KSEG0 is # configured as uncached.# * If KSEG0_UNCACHED is defined (and WORKAROUND_NO_CACHE is not defined), # caches are still initialised (using indexed cacheops), but otherwise # no cacheops are used, and KSEG0 is configured as uncached.BUILD_DEFS = $(WORKAROUND_BONITO) $(WORKAROUND_NO_CACHE) $(KSEG0_UNCACHED)# ********************************************************************# Definitions common to start, little- and big-endian images.# ********************************************************************ifeq ($(TOOLCHAIN),sde)AS_OPTS = -no-traditional-cppTEST_SIZE = test_sizeendifTOOLDIR = $(MAKEDIR)/tools# Converter tool.# Converts from srecord file to flash and binary files.# The srecord file used is actually the concatenation of 3 files : # 1) The srecord file holding the reset code.# 2) The srecord file holding the little endian code.# 3) The srecord file holding the big endian code.SRECCONV = $(PERL) $(TOOLDIR)/srecconv.pl# Options for srecconv tool# -ES B is overwritten by "!B" or "!E" inserted in file to be converted.# -EB B is required by the SEAD and SEAD-2 platforms.SRECCONV_OPTS = -ES B -EB B -A 29# Path to include directory.INCLUDE = -I$(ROOT)/include -I$(ROOT)/arch/include# Options to compiler.## Define DEBUG if you whish debug output on debug serial port.# DEBUG = -D_DEBUG_## Define SIMULATE if building image for simulation.# SIMULATE = -D_SIMULATE_W_OPTS = -Wimplicit -WformatREV_OPTS = '-D_REVMAJ_="$(REVMAJ)"' '-D_REVMIN_="$(REVMIN)"'CC_OPTS = -mips2 -g -mcpu=r4000 -D_32_ -O2 -G0 -fno-builtin $(W_OPTS) $(REV_OPTS) $(INCLUDE) $(DEBUG) $(SIMULATE) $(BUILD_DEFS) -$(ENDIAN) -D$(ENDIAN)ifeq ($(BSS_OLD),0)CC_OPTS_A = $(CC_OPTS) $(AS_OPTS) -D_ASSEMBLER_elseCC_OPTS_A = $(CC_OPTS) $(AS_OPTS) -D_ASSEMBLER_ -D_BSS_OLD_endif# This makefile.MAKEFILE = $(MAKEDIR)/Makefile# Options to linker (currently none).LD_OPTS =# Linker output format.ifeq ($(ENDIAN),EB)OFORMAT = elf32-bigmipselseOFORMAT = elf32-littlemipsendif# Options to objdumpOBJDUMP_OPTS = -S --disassemble-all# Search path for source files.VPATH = $(SRCDIR)# Source files (C and Assembler).SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c))SRC_S = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.S))SRC_H = $(foreach dir, $(INCLUDE), $(wildcard $(dir)/*.h))SRC = $(SRC_C) $(SRC_S)# Object files.OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))OBJ_S = $(notdir $(patsubst %.S, %.o, $(SRC_S)))OBJ = $(OBJ_C) $(OBJ_S) $(FPUEMUL)# ********************************************************************# Targets# ********************************************************************.PHONY : all install test_install srec_el srec_eb release set_time clean depend dep all : test_install set_time fpuemul $(IMAGE_FLASH)install : $(CD) $(ROOT)/fpuemul; $(MAKE) install -$(MKDIR) -p EL -$(MKDIR) -p EBtest_install : @$(PERL) $(TOOLDIR)/test_install.plfpuemul : $(CD) $(ROOT)/fpuemul; $(MAKE) TOOLCHAIN=$(TOOLCHAIN)test_size : @space=`$(OBJDUMP) -h $(IMAGE_ELF) | \ awk '/dat/ { \ $$5=substr($$5, length($$5)-7, 8); \ print "16 i ",$$3,$$5,"+ $(MAX_ADDRESS) - p" \ }' | \ tr '[a-f]' '[A-F]' | dc` ;\ if test $$space -gt 0; then \ echo "" ;\ echo "" ;\ echo "$(IMAGE_ELF) $$space bytes too big!!!" ;\ echo "" ;\ exit 1 ;\ fidis : $(IMAGE_DIS) dis_el dis_ebdis_el : $(CD) $(EL_PATH); $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EL $(DIS_EL)dis_eb : $(CD) $(EB_PATH); $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EB $(DIS_EB)$(IMAGE_DIS) : $(IMAGE_ELF) $(OBJDUMP) $(OBJDUMP_OPTS) $(IMAGE_ELF) > $(IMAGE_DIS)release : $(MAKE) clean $(MAKE) all $(MAKE) disset_time : $(RM) -f $(EL_PATH)/comptime.o $(EB_PATH)/comptime.o# Build the final flash and binary images :# 1) Concatenate srecord files for the reset code, big- and little-endian code.# 2) Apply SRECCONV tool.$(IMAGE_FLASH) : $(IMAGE_SREC) srec_el srec_eb $(ECHO) "!L" > ./tmp_little $(ECHO) "!B" > ./tmp_bigifeq ($(ENDIAN),EB) $(CAT) ./tmp_big $(IMAGE_SREC)\ ./tmp_little $(EL_PATH)/$(SREC_EL)\ ./tmp_big $(EB_PATH)/$(SREC_EB)\ > $(IMAGE_SREC_CONCAT)else $(CAT) ./tmp_little $(IMAGE_SREC)\ ./tmp_little $(EL_PATH)/$(SREC_EL)\ ./tmp_big $(EB_PATH)/$(SREC_EB)\ > $(IMAGE_SREC_CONCAT)endif $(RM) ./tmp_little $(RM) ./tmp_big $(SRECCONV) $(SRECCONV_OPTS) ./$(IMAGENAME)$(IMAGE_SREC) : $(IMAGE_ELF) $(OBJCOPY) -O srec $(IMAGE_ELF) $(IMAGE_SREC)$(IMAGE_ELF) : $(OBJ) $(LD_SCRIPT) $(LD) $(LD_OPTS) -T $(LD_SCRIPT) -o $(IMAGE_ELF) -Map $(IMAGE_MAP) -oformat $(OFORMAT) $(OBJ)$(OBJ_C) : %.o : %.c $(CC) -c $(CC_OPTS) -o $@ $<$(OBJ_S) : %.o : %.S $(CC) -c $(CC_OPTS_A) -o $@ $<$(OBJ) : $(MAKEFILE)srec_el : $(CD) $(EL_PATH); \ $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EL $(SREC_EL) $(TEST_SIZE)srec_eb : $(CD) $(EB_PATH); \ $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EB $(SREC_EB) $(TEST_SIZE)CLEAN_FILES = ../TAGS ./*.o ./*.bin ./*.elf ./*.rec ./*.map ./*.dis ./bcfg.fl ./$(RESET).fl ./$(IMAGE_BASENAME)*.fl ./depend.mkclean : -$(RM) -f $(CLEAN_FILES) -$(CD) $(EL_PATH); $(RM) -f $(CLEAN_FILES) -$(CD) $(EB_PATH); $(RM) -f $(CLEAN_FILES) -$(CD) $(ROOT)/fpuemul; $(MAKE) cleandepend: test_install dep $(CD) $(EL_PATH); $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EL dep $(CD) $(EB_PATH); $(MAKE) -f ./../$(MAKEFILE) ENDIAN=EB dep $(CD) $(ROOT)/fpuemul; $(MAKE) TOOLCHAIN=$(TOOLCHAIN) dependTAGS: (cd ..; rm -f TAGS; find . -name "*.[chS]" | xargs $(TAGS) --append -t )dep: $(CC) $(INCLUDE) -M $(SRC) > ./depend.mk-include ./depend.mk
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -