zoukankan      html  css  js  c++  java
  • make 实例 二 V56

    #########################################################################
    #
    # Makefile used for building application.
    #
    # The default target (all) builds application in three formats :
    #   *.rec : Image in S-record format.
    #   *.bin : Image in binary format.
    #   *.elf : Image in ELF format.
    #   *.map : Linker generated map file.
    #   *.dis : Disassembly of image.
    #   *.sym : Symbols.
    #
    # Other targets are :
    #   clean :    Deletes all files generated by makefile.
    #
    #########################################################################
    
    CONFIG_FILE ?= .config
    
    -include $(CONFIG_FILE)
    
    PROJ   ?= S7L
    PARA   ?= 0
    # **********************************************
    # Build Options
    # **********************************************
    # Version: Debug or Retail
    VERSION  ?= Retail
    
    # Makefile for DVB system
    TV_SYSTEM = DVB
    
    # Image name
    AP_NAME = AP
    BL_NAME = BL
    AP_COMPRESS_NAME = AP_C
    MERGE_NAME = VIDEOCON
    RES_NAME = RES
    
    # **********************************************
    # Tool Chain
    # **********************************************
    CROSSCOMPILE = aeon-
    CORSSCOMPILE_VER =
    AEON_FLAG    = -march=$(AEON_TYPE) -mhard-div -mhard-mul -EL -mredzone-size=4
    
    # AEON_FLAG   = -march=aeon1 -mhard-div -mhard-mul -fno-delayed-branch -minsert-nop-before-branch
    
    CC    = $(CROSSCOMPILE)gcc $(CROSSCOMPILE_VER)
    CPP     = $(CROSSCOMPILE)cpp
    LD    = $(CROSSCOMPILE)ld
    
    OBJCOPY = $(CROSSCOMPILE)objcopy
    OBJDUMP = $(CROSSCOMPILE)objdump
    SIZE    = $(CROSSCOMPILE)size
    AR    = $(CROSSCOMPILE)ar
    NM    = $(CROSSCOMPILE)nm
    AWK     = /bin/gawk
    FLINT   = scripts/flint
    REALPATH= echo
    
    
    # **********************************************
    # Directories
    # **********************************************
    PREFIXDIR?=
    ROOT    = .
    BINDIR    = ./$(PREFIXDIR)/Bin_$(PROJ)
    BINPATH = $(BINDIR)
    OBJDIR    = ./$(PREFIXDIR)/Obj_$(PROJ)
    OBJPATH = $(OBJDIR)
    LZSSDIR = ./scripts/lzss
    MSCOMPDIR = ./scripts/util
    COREDIR ?= ./core
    
    CC_TVOPTS += -DORGINAL_ALL_MERGE=1
    CC_TVOPTS += -DBLOADER=0
    CC_TVOPTS += -DSECURE_BOOT=0
    
    # Source files
    
    SRC_FILE = ./core/api/utl/NoOS.c
    
    
    # Add "Header (include) file" directories here ...
    INC_DIR   = 
            -I$(ROOT)/include                                   
            -I$(BOOTDIR)                                        
            -I$(COREDIR)/api/utl                                
            -I$(COREDIR)/api/closedcaption/atsc/include            
            -I$(COREDIR)/middleware/closedcaption/include        
            -I$(COREDIR)/bin/vdec/mvd                            
            -I$(COREDIR)/api/include                            
            -I$(COREDIR)/api/Arabic_Parser/include              
            -I$(COREDIR)/api/Thai_Parser/include                
            -I$(COREDIR)/driver/sys/include                     
        -I$(DRV_BSP_INC)                                    
        -I$(DRV_LEGACY_INC)                     
            -I$(ROOT)/project/image/atsc/binitem                
            -I$(ROOT)/project/image/dvbt/binitem                
            -I$(ROOT)/project/image/u3/binitem                    
            -I$(ROOT)/project/image/s7/binitem                    
            -I$(ROOT)/project/image/s7ld/binitem
    
    INC_DIR += -I$(ROOT)/include/std
    
    CC_TVOPTS += -DENABLE_MSTV_UART_DEBUG=1 -DUSE_SW_I2C=1 -DCOMB_3D -DBOOTLOADER_BANK_NUM
    WARN_FLAGS = -Wall -Wextra -Wcast-align -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Wno-format -Wshadow
    YOGA_GLOBAL_CFLAGS = -pipe -fno-exceptions -ffunction-sections $(WARN_FLAGS)
    
    include project/build/FILES_$(PROJ).mk
    
    
    #This is a patch, move to here
    IMGINFO_OFFSET = 70016
    BOOTLOADER ?= project/loader/bootloader_M12_R2.ld
    DRV_BSP_INC = $(COREDIR)/drv_bsp/m12_nos_r2m/include
    
    
    # -D__CREATE_TIMER_WITH_INTERVAL_0__
    # **********************************************
    # Image file names
    # **********************************************
    AP_BIN = $(BINPATH)/$(AP_NAME).bin
    ###AP_BIN2= $(BINPATH)/$(AP_NAME)_2.bin
    APC_BIN = $(BINPATH)/$(AP_COMPRESS_NAME).bin
    AP_ELF = $(BINPATH)/$(AP_NAME).elf
    AP_MAP = $(BINPATH)/$(AP_NAME).map
    AP_DIS = $(BINPATH)/$(AP_NAME).dis
    AP_SYM = $(BINPATH)/$(AP_NAME).sym
    AP_OBJ = $(OBJPATH)/$(AP_NAME).o
    
    MERGE_BIN = $(BINPATH)/$(MERGE_NAME).bin
    #MERGE_ELF = $(BINPATH)/$(MERGE_NAME).elf
    MERGE_DIS = $(BINPATH)/$(MERGE_NAME).dis
    MERGE_MAP = $(BINPATH)/$(MERGE_NAME).map
    MERGE_BIN_2 = $(BINPATH)/$(MERGE_NAME)_2.bin
    ###HK51_BOOT = $(BINPATH)/$(MERGE_NAME).bin
    RES_BIN = $(BINPATH)/$(RES_NAME).bin
    
    # **********************************************
    # Tools
    # **********************************************
    #SWAP      = perl $(TOOLS)/byteswap.pl
    BinIDPackFiles = python scripts/BinIDPackFiles_Compress.py
    BinIDPackResources = python scripts/BinIDPackResources.py
    AddBin = python scripts/Addbin.py
    
    # **********************************************
    # Files to be compiled
    # **********************************************
    SRC_S  = $(filter %.S, $(SRC_FILE))
    SRC_C  = $(filter %.c, $(SRC_FILE))
    SRC_O  = $(filter %.o,  $(SRC_FILE))
    SRC_B  = $(filter %.bin, $(SRC_FILE))
    
    OBJ_S  = ${SRC_S:%.S=$(OBJPATH)/%.o}
    OBJ_C  = ${SRC_C:%.c=$(OBJPATH)/%.o}
    OBJ_B  = ${SRC_B:%.bin=$(OBJPATH)/%.o}
    
    OBJ    = $(OBJ_C) $(OBJ_B) $(OBJ_S)
    
    BL_SRC_S  = $(filter %.S, $(BL_SRC_FILE))
    BL_SRC_C  = $(filter %.c, $(BL_SRC_FILE))
    BL_SRC_O  = $(filter %.o,  $(BL_SRC_FILE))
    BL_SRC_B  = $(filter %.bin, $(BL_SRC_FILE))
    
    BL_OBJ_S  = ${BL_SRC_S:%.S=$(OBJPATH)/%.o}
    BL_OBJ_C  = ${BL_SRC_C:%.c=$(OBJPATH)/%.o}
    BL_OBJ_B  = ${BL_SRC_B:%.bin=$(OBJPATH)/%.o}
    
    BL_OBJ    = $(BL_OBJ_C) $(BL_OBJ_B) $(BL_OBJ_S)
    SRC    = $(SRC_C) $(BL_SRC_C)
    
    
    # **********************************************
    # Compiler and linker options
    # **********************************************
    YOGA_GLOBAL_LDFLAGS = -msoft-float -g -nostdlib -Wl,--gc-sections -Wl,-static
    
    INCLUDE   = $(INC_DIR)
    
    CC_OPTS0  += -c $(INCLUDE) $(AEON_FLAG) $(CC_TVOPTS) $(YOGA_GLOBAL_CFLAGS) $(MALLOC_CFLAGS)
    CC_OPTS0  += -Wno-strict-aliasing
    CC_OPTS  = $(CC_OPTS0) -O2
    
    LD_OPTS += -nostartfiles $(YOGA_GLOBAL_LDFLAGS) $(AEON_FLAG) -LLIB -W1,--gc-sections
    LDLIB += -lc -lgcc -lm
    
    
    # **********************************************
    # Rules
    # **********************************************
    .PHONY : all clean pmsleep lint
    .SUFFIXES: .bin .elf .dis .sym .siz
    
    # Project Build
    
    all : $(PROJ)
    
    $(PROJ): loader setup sboot ap merge lint
    
    
    
    #Note: It's slow to produce .dis file w/o -gdwarf-2 set or original OS source code
    ap: $(AP_ELF) $(AP_BIN) $(AP_SYM)
    
    merge: $(MERGE_ELF) $(MERGE_BIN)
    
    dis: $(AP_DIS) $(MERGE_DIS)
    
    
    HEAP_START=$$(cat HEAP_START.txt) 
    HEAP_END=$$(cat HEAP_END.txt)
    HEAP_SIZE=$$((($(HEAP_END)-$(HEAP_START))/1024))
    HEAP_START_STRING=                ___heap = .
    HEAP_END_STRING=                ___heap_end = (RAM_START + RAM_SIZE)
    
    
    
    sboot: $(AP_BIN)
        @grep '__heap =' $(BINPATH)/AP.map | sed 's$(HEAP_START_STRING)\g' | sed 's/^.*0x/0x/g'>HEAP_START.txt;
        @grep '__heap_end =' $(BINPATH)/AP.map | sed 's$(HEAP_END_STRING)\g' | sed 's/^.*0x/0x/g'>HEAP_END.txt;
        @echo "HEAP_START= $(HEAP_START)"
        @echo "HEAP_END  = $(HEAP_END)"
        @echo "$(HEAP_SIZE)">HEAP_SIZE.txt
    #    @rm HEAP_START.txt
    #    @rm HEAP_END.txt
    #    @echo "HEAP_SIZE = $(HEAP_SIZE)KB"
        @awk '{if($$1>=100) {print "HEAP_SIZE = "$$1" KB";rm "HEAP_SIZE.txt";}else {print "Error:HEAP_SIZE("$$1"KB) is less than 100 KB";exit 1}}' HEAP_SIZE.txt
        @echo "[SBOOT] $@"
    #        @$(shell $(LZSSDIR)/lzss.out C 14336 $(BINPATH)/$(AP_NAME).bin $(BINPATH)/$(AP_COMPRESS_NAME).bin;)
            @$(shell $(MSCOMPDIR)/mscompress -c -u 14336 -9 $(BINPATH)/$(AP_NAME).bin > $(BINPATH)/$(AP_COMPRESS_NAME).bin;)
            @$(shell cp $(BINPATH)/$(AP_COMPRESS_NAME).bin $(ROOT)/boot/sboot/bin/$(AP_NAME).bin; cp $(BINPATH)/$(AP_NAME).map $(ROOT)/boot/sboot/bin;)
        @(cd $(ROOT)/boot/sboot; $(MAKE) clean;)
        @( mkdir -p $(ROOT)/boot/sboot/out;)
        ifeq ($(MEMORY_SIZE),MEMORY_128MB)
            @(cp $(ROOT)/boot/sboot/bin/$(BOARD_TYPE_SEL)/sboot_128.bin $(ROOT)/boot/sboot/out/sboot.bin;)
        else
            @(cp $(ROOT)/boot/sboot/bin/$(BOARD_TYPE_SEL)/sboot.bin $(ROOT)/boot/sboot/out/sboot.bin;)
        endif
    ########################################################################################
    #   since we can use SW PM, then PM.bin should be compiled according to BOARD define
    ########################################################################################
        @(/bin/cp -f $(ROOT)/boot/sboot/bin/$(BOARD_TYPE_SEL)/PM.bin $(ROOT)/boot/sboot/out;)
    ########################################################################################
        @$(MAKE) -C $(ROOT)/boot/sboot
    
    $(AP_ELF) : $(OBJ_S) $(OBJ_C) $(OBJ_B) $(DTV_LIB)
        @echo "[LD]  $@"
        @$(CC) $(LD_OPTS) -Wl,-Map,$(AP_MAP) -Wl,--start-group $^ -Wl,--end-group -T$(LOADER) -o $@ $(LDLIB)
        #@$(AR) -r $(ROOT)/core/api/msAPI_Flash.a $(OBJPATH)/core/api/msAPI_Flash.o
        @$(SIZE) $@
    
    
    $(AP_BIN) : $(AP_ELF)
        @echo "[BIN] $@"
        @$(OBJCOPY) -O binary -S -g -x -X -R .sbss -R .bss -R .reginfo $< $@
    
    
    $(AP_OBJ): $(AP_BIN)
    #        $(shell $(LZSSDIR)/lzss.out C 14336 $(BINPATH)/AP.bin $(BINPATH)/AP_C.bin; cd $(BINPATH); $(OBJCOPY) -I binary -O elf32-littleaeon -B aeon:aeonR2 --prefix-sections=bin AP_C.bin ../$(OBJPATH)/AP.o)
            $(shell $(MSCOMPDIR)/mscompress -c -u 14336 -9 $(BINPATH)/$(AP_NAME).bin > $(BINPATH)/$(AP_COMPRESS_NAME).bin; cd $(BINPATH); $(OBJCOPY) -I binary -O elf32-littleaeon -B aeon:aeonR2 --prefix-sections=bin AP_C.bin ../$(OBJPATH)/AP.o)
    
    
    $(MERGE_ELF): $(BL_OBJ_S) $(BL_OBJ_C) $(BL_OBJ_B) $(AP_OBJ)
        @echo "[LD]  $@"
        @$(CC) $(LD_OPTS) -Wl,-Map,$(MERGE_MAP) $^ -T$(BOOTLOADER) -o $@ $(LDLIB)
        @$(SIZE) $@
    
    $(MERGE_BIN) : $(AP_BIN)
        @echo "[BIN] $@"
        $(shell cp $(ROOT)/boot/sboot/out/all.bin $(MERGE_BIN);)
            $(BinIDPackFiles) -BIGENDIAN -CRC16ENABLE -multiflash 8 8 0958336900 $@ $(BIN_INFO) $(IMGINFO_OFFSET) $(APC_BIN) 0 $(OS_TYPE)
    
    $(RES_BIN) : $(AP_ELF)
        @echo "[BIN] $@"
        $(BinIDPackResources) -BIGENDIAN -CRC16ENABLE 8 8 0958336900 $< $@ $(BIN_INFO)
        @cp core/bin/s7/audio/out_dvb_t3_d.bin $(BINPATH)/au_d.bin
        @cp core/bin/s7/audio/out_dvb_t3_s.bin $(BINPATH)/au_s.bin
        cp tv-ap/dvb/ui2/logo/Mstar_OSD_Logo_683x384.jpg $(BINPATH)/boot0.jpg
        cp tv-ap/dvb/ui2/logo/mp3.mp3 $(BINPATH)/boot0.mp3
        @./generate_pnl_bin.sh $(BINPATH)/AP.elf $(BINPATH)
    
    
    $(OBJ_B) $(BL_OBJ_B): $(OBJPATH)/%.o : %.bin
        @echo "[BIN] $@"
        @$(shell cd $(dir $<); $(OBJCOPY) -I binary -O elf32-littleaeon -B aeon --prefix-sections=bin $(notdir $<) $(abspath $@))
    
    $(OBJPATH)/%.o: %.S
        $(call make-depend-compile,$<,$@,$(subst .o,.d,$@))
    
    $(OBJPATH)/%.o: %.c
        $(call make-depend-compile,$<,$@,$(subst .o,.d,$@))
    
    $(OBJPATH)/%.o: %.bin
        @echo "[BIN] $@"
        @$(shell cd $(dir $<); $(OBJCOPY) -I binary -O elf32-littleaeon -B aeon --prefix-sections=bin $(notdir $<) $(abspath $@))
    
    .c.ln:  ;   lint -abhi $*.c
    .elf.dis: ; @echo "[DIS] $@" ; $(OBJDUMP) -d -h -S $< > $@
    .elf.sym: ; @echo "[SYM] $@" ; $(NM) -a -S $< > $@
    .elf.siz: ; @echo "[SIZ] $@" ; $(SIZE) $< > $
    
    
    LINT_INC=$(subst -I,,$(INC_DIR))
    LINT_SRC_C=$(SRC_C)
    LINT_DEF=$(subst -D,-d,$(filter -D%,$(CC_OPTS)))
    
    lint:
    ifneq ($(DISABLE_LINT),1)
        @(
        echo "scripts/co-gnu3.lnt"; 
        echo $(LINT_OPT1); 
        echo | $(CPP) -dM | 
        sed -e '/LONG_LONG/d' | 
        sed -e 's/#define ([^ ]*) "(..*)"/-d"1=(2)"/' | 
        sed -e 's/#define ([^ ]*) (..*)/-d"1=2"/' | 
        sed -e 's/#define /-d/'; 
        for i in $(LINT_DEF); do 
            echo $$i; 
        done; 
        for i in $(LINT_INC); do 
            echo -i"$$i"; 
        done; 
        for i in `$(REALPATH) \`echo | $(CPP) -x c -Wp,-v 2>&1 | grep '^ '\``; do 
            echo -i"$$i"; 
        done; 
        for i in $(LINT_SRC_C); do 
            echo $$i; 
        done; 
        ) > $(BINPATH)/$(PROJ).lnt
        @$(FLINT) -fff $(BINPATH)/$(PROJ).lnt > $(BINPATH)/LINT.txt; 
         grep -v 'Module:' $(BINPATH)/LINT.txt | grep -v '^$$' ; true
        @echo
        @echo `grep 'Error' $(BINPATH)/LINT.txt | wc -l` LINT Errors
    endif
    
    .PHONY: $(OBJPATH)/tv-ap/dvb/ui/MApp_ZUI_ACTmenufunc.o
    loader:
    
    
    # Project Setup
    setup:
        @mkdir -p $(OBJDIR) $(BINDIR);
        @rm -f $(call src-to-obj,$(REBUILD_FILES))
        @cp -f $(ROOT)/project/loader/target.ld $(LOADER); chmod 744 $(LOADER)
        @$(AWK) '{if ($$2=="BEON_MEM_ADR") print $$3;}' $(MMAP) > $(ROOT)/project/mmap/aeon_mem_adr
        @$(AWK) 'BEGIN { 
                    getline < "$(ROOT)/project/mmap/aeon_mem_adr"; 
                    ADR = $$1 
                } 
                { 
                    if ($$1=="RAM_START") gsub($$3, ""ADR";", $$0); 
                    if ($$1=="ram" && $$3=="ORIGIN") gsub($$5, ""ADR",", $$0); 
                    if ($$1==".prog_img_info") gsub($$2, "("ADR"+0x1100)", $$0); 
                    if ($$1==".img_info") gsub($$2, "("ADR"+0x2000)", $$0); 
                    if ($$1==".isp_info") gsub($$2, "("ADR"+0x3000)", $$0); 
                    print > FILENAME ".tmp"; 
                }' $(LOADER)
                @mv -f $(LOADER).tmp $(LOADER)
        @$(AWK) '{if ($$2=="BEON_MEM_LEN") print $$3;}' $(MMAP) > $(ROOT)/project/mmap/aeon_mem_len
        @$(AWK) 'BEGIN { 
                    getline < "$(ROOT)/project/mmap/aeon_mem_len"; 
                    LEN = $$1
                } 
                { 
                    if ($$1=="RAM_SIZE") gsub($$3, ""LEN";", $$0); 
                    if ($$1=="ram" && $$6=="LENGTH") gsub($$8, ""LEN"", $$0); 
                    print > FILENAME ".tmp"; 
                }' $(LOADER)
                @mv -f $(LOADER).tmp $(LOADER)
    
    env:
        @echo CC_OPTS = $(CC_OPTS)
        @echo LD_OPTS = $(LD_OPTS)
        @echo SRC = $(SRC)
    
    # Project API
    DOCGEN :
    #    doxygen.exe $(ROOT)/project/Doxygen/Venus_3RD_PARTY_DDI_API.doxygen
    
    # Project Clean
    clean :
        find $(OBJPATH) -name '*.o' -exec rm -f {} ;
        rm -f $(BINPATH)/$(AP_NAME).* $(BINPATH)/$(MERGE_NAME).* ###$(BINPATH)/$(AP_NAME)_2.* $(BINPATH)/$(MERGE_NAME)_2.*
            ifeq ($(BUILD_TARGET),MAIN_AP_SYSTEM)
            @$(MAKE) PROJ=$(PROJ)_BLOADER clean
            endif
    
    realclean:
        echo $($(ver))
    
    checkstack: $(AP_ELF)
        $(OBJDUMP) -d $(AP_ELF) | scripts/checkstack.pl aeon
    
    
    # Project Dependence
    
    # $(call make-depend-compile,source-file,object-file,depend-file)
    define make-depend-compile
        @echo "[CC]  $1"
        @mkdir -p $(dir $2)
        @$(CC) -MM -MF $3 -MP -MT $2 $(CC_OPTS) $1
        @$(CC) $(CC_OPTS) -o $2 -c $1
    endef
    
    src-to-obj = $(patsubst %.bin,$(OBJPATH)%.o,
                 $(patsubst %.S,$(OBJPATH)/%.o,
                 $(patsubst %.c,$(OBJPATH)/%.o,$1)))
    
    -include $(OBJ_S:.o=.d) $(OBJ_C:.o=.d)
  • 相关阅读:
    《Java大学教程》—第12章 案例研究--第2部分
    《Java大学教程》—第11章 案例研究--第1部分
    《Java大学教程》—第10章 图形和事件驱动程序
    《Java大学教程》—第8章 通过继承扩展类
    《Java大学教程》—第7章 类的实现
    《Java大学教程》—第6章 类和对象
    《Java大学教程》—第5章 数组
    《Java大学教程》—第4章 方法的实现
    spring_01概念及案例
    MyEclipse中jsp编码设置
  • 原文地址:https://www.cnblogs.com/jiangzhaowei/p/11078718.html
Copyright © 2011-2022 走看看