Makefile回顾,阅读makefile,config.ini文件,自行写阅读理解。
1,Makefile文件的理解
打开Makefile文件所在路径,如下图。
用vim文本编译器打开Makefile进行阅读,内容如下图。
自己阅读理解如下标注#后的中文解释。
#MODEL ?= hi3518a //是否有赋值,没有的就赋值为hi3518a,以下的#MODEL语句也类似作用
#MODEL ?= hi3518e
#MODEL ?= hi3518e_w
#MODEL ?= hi3518c
#MODEL ?= hi3516c
#MODEL ?= hi3518a_s
#MODEL ?= hi3518a_p
#MODEL ?= hi3516a
#MODEL ?= hi3516d
#MODEL ?= m388c2g
#MODEL ?= m388c1g
#MODEL ?= hi3518e_v2
#MODEL ?= hi3516c_v2
#MODEL ?= hi3518e_ws
#MODEL ?= hi3518c_ws
#MODEL ?= hi3518e_wsc
#MODEL ?= hi3518a_wsc
LDFLAGS_EXT :=
DEF_EXT :=
ifeq ($(MODEL),hi3518a) #如果MODEL变量的值等于hi3518a则执行下面的语句,以下的ifeq ... endif语句也类似
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518a_inc_config.ini //将对应的config.ini文件赋值给CONFIG_DIR_SRC
endif
ifeq ($(MODEL),hi3518e)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518e_inc_config.ini
endif
ifeq ($(MODEL),hi3518e_w)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518e_w_inc_config.ini
endif
ifeq ($(MODEL),hi3518c)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518c_inc_config.ini
endif
ifeq ($(MODEL),hi3516c)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3516c_inc_config.ini
endif
ifeq ($(MODEL),hi3518a_s)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518a_s_inc_config.ini
endif
ifeq ($(MODEL),hi3518a_p)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518a_p_inc_config.ini
endif
ifeq ($(MODEL),hi3516a)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3516a_inc_config.ini
endif
ifeq ($(MODEL),hi3516d)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3516d_inc_config.ini
endif
ifeq ($(MODEL),m388c2g)
CONFIG_DIR_SRC := $(CURDIR)/configs/m388c2g_inc_config.ini
endif
ifeq ($(MODEL),m388c1g)
CONFIG_DIR_SRC := $(CURDIR)/configs/m388c1g_inc_config.ini
endif
ifeq ($(MODEL),hi3518e_v2)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518e_v2_inc_config.ini
endif
ifeq ($(MODEL),hi3516c_v2)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3516c_v2_inc_config.ini
endif
ifeq ($(MODEL),hi3518e_ws)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518e_ws_inc_config.ini
endif
ifeq ($(MODEL),hi3518c_ws)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518c_ws_inc_config.ini
endif
ifeq ($(MODEL),hi3518e_wsc)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518e_wsc_inc_config.ini
endif
ifeq ($(MODEL),hi3518a_wsc)
CONFIG_DIR_SRC := $(CURDIR)/configs/hi3518a_wsc_inc_config.ini
endif
ifndef MODEL #如果前面有定义MODEL则执行ifdef和endif之间的语句
include $(CURDIR)/config.ini #CURDIR表示当前路径,即把当前路径下的config.ini文件包含进来
endif
INC_PATH := $(CURDIR)/include #当前路径下的include文件赋值给INC_PATH
LIB_PATH := $(CURDIR)/lib/$(CROSS)
BIN_PATH := $(CURDIR)/bin
DBG_PATH := $(CURDIR)/debug
PAK_PATH := $(CURDIR)/package_demo
SRC_FUNCTION_DEF := $(foreach str,$(FUNCTION_DEF),-D$(str)) #foreach循环将FUNCTION_DEF表达式中的值挨个取出,并存放到变量str中,然后-D$(str)编译时间并放到变量str中
#JUAN ONVIF NVT lib
ifeq (ONVIFNVT,$(findstring ONVIFNVT, $(FUNCTION_DEF))) #在变量FUNCTION_DEF存放的字符串中搜索字符串”ONVIFNVT“,如果找到则返回”ONVIFNVT“,找不到返回空,并将返回值与ONIVFNVT进行比较,相等则执行ifeq后面的语句,不等则跳过该语句。
LDFLAGS_EXT += "-lonvif" #将字符串-lonvif累加赋值给LDFLAGS_EXT
endif
#Danale p2p lib
ifeq (DANALE,$(findstring DANALE,$(FUNCTION_DEF)))
LDFLAGS_EXT += "-ldana_video"
endif
#UDX p2p lib
ifeq (P2P,$(findstring P2P,$(FUNCTION_DEF)))
LDFLAGS_EXT += "-lP2PSDKDevice"
LDFLAGS_EXT += "-lNkECloud"
LDFLAGS_EXT += "-lcares"
#LDFLAGS_EXT += "-lFUdx"
#LDFLAGS_EXT += "-lFastUdx"
LDFLAGS_EXT += "-lFastUdx2"
LDFLAGS_EXT += "-lNkEmbedded"
LDFLAGS_EXT += "-lstdc++"
endif
#ants lib
ifeq (ANTS,$(findstring ANTS,$(FUNCTION_DEF)))
LDFLAGS_EXT += "-lantsserver"
LDFLAGS_EXT += "-lpublic"
LDFLAGS_EXT += "-ltinyxml"
endif
# N1 Reference Library
ifeq (N1,$(findstring N1,$(FUNCTION_DEF)))
LDFLAGS_EXT += "-lNkN1SDK"
LDFLAGS_EXT += "-lNkCipher"
LDFLAGS_EXT += "-lNkEmbedded"
LDFLAGS_EXT += "-lNkUtils"
LDFLAGS_EXT += "-lstdc++"
LDFLAGS_EXT += "-ldl"
endif
LDFLAGS_EXT += "-lsecuredat"
MAKE := @make #不显示make命令本身,只显示make的结果
.PHONY: target all src shell sdk api sdk_clean tarball image config
#info:
# @echo $(PRODUCT_CLASS) #输出变量PRODUCT_CLASS里的内容
# @echo $(PRODUCT_MODEL)
# @echo $(SOC_MODEL)
#
target: src #target表示目标文件,src表示依赖的源文件
src: srclib #目标文件src经过以下语句生成,且依赖的srclib文件
echo $(PRODUCT_CLASS) #输出变量PRODUCT_CLASS的值
$(MAKE) -C src CROSS="$(CROSS)" \
PRODUCT_CLASS="$(PRODUCT_CLASS)" \
PRODUCT_MODEL="$(PRODUCT_MODEL)" \
SOC_MODEL="$(SOC_MODEL)" \
INC_PATH="$(INC_PATH)" \
LIB_PATH="$(LIB_PATH)" \
BIN_PATH="$(BIN_PATH)" \
DBG_PATH="$(DBG_PATH)" \
SERISE_CODE="$(SERISE_CODE)" \
FUNCTION_DEF_LIB="$(shell echo $(FUNCTION_DEF) | tr A-Z a-z )" \
SRC_FUNCTION_DEF="$(SRC_FUNCTION_DEF)" \
LDFLAGS_EXT="$(LDFLAGS_EXT)" \
DEVICE_MODEL="$(DEVICE_MODEL)" \
DEF_EXT="$(DEF_EXT)" \
PRODUCT_NAME="$(PRODUCT_NAME)" \
srclib:#目标文件srclib经过以下语句生成
rm -f $(BIN_PATH)/ipcam_app
$(MAKE) -C src srclib CROSS="@$(CROSS)" \
PRODUCT_CLASS="$(PRODUCT_CLASS)" \
PRODUCT_MODEL="$(PRODUCT_MODEL)" \
SOC_MODEL="$(SOC_MODEL)" \
INC_PATH="$(INC_PATH)" \
LIB_PATH="$(LIB_PATH)" \
BIN_PATH="$(BIN_PATH)" \
DBG_PATH="$(DBG_PATH)" \
SERISE_CODE="$(SERISE_CODE)" \
FUNCTION_DEF_LIB="$(shell echo $(FUNCTION_DEF) | tr A-Z a-z )" \
SRC_FUNCTION_DEF="$(SRC_FUNCTION_DEF)" \
DEVICE_MODEL="$(DEVICE_MODEL)" \
DEF_EXT="$(DEF_EXT)" \
PRODUCT_NAME="$(PRODUCT_NAME)" \
shell:#目标文件shell经过以下语句生成
$(MAKE) -C shell CROSS="@$(CROSS)" \
INC_PATH="$(INC_PATH)" \
LIB_PATH="$(LIB_PATH)" \
BIN_PATH="$(BIN_PATH)" \
DBG_PATH="$(DBG_PATH)" \
sdk:#目标文件sdk经过以下语句生成
$(MAKE) --directory=sdk SOC_MODEL="$(SOC_MODEL)" \
PRODUCT_MODEL="$(PRODUCT_MODEL)" \
SRC_FUNCTION_DEF="$(SRC_FUNCTION_DEF)" \
DEF_EXT="$(DEF_EXT)" \
PRODUCT_NAME="$(PRODUCT_NAME)" \
api:#目标文件api经过以下语句生成
$(MAKE) --directory=api CROSS=$(CROSS)
tarball:#目标文件 tarball将有以下语句编译生成
$(MAKE) --directory=sdk clean
checkinclude:#目标文件checkinclude 将有以下语句编译生成
rm -rf include/sdk
cp -a api/include/* include
cp -a sdk/sdk include
image: src #目标文件image将有以下语句编译生成,且依赖于src文件
#cd ../release
$(MAKE) -C ../release DEVICE_MODEL="$(DEVICE_MODEL)" PRODUCT_MODEL="$(PRODUCT_MODEL)" FUNCTION_DEF="$(FUNCTION_DEF)" MODEL_ROOTFS="$(MODEL_ROOTFS)" CROSS="$(CROSS)"
all: clean sdk srclib src image //这里的all:表示将要执行生成后面的文件clean sdk srclib src image
demoapp: #目标文件demoapp将有以下语句编译生成
echo $(PRODUCT_CLASS)
rm -f $(BIN_PATH)/demo_app
$(MAKE) -C demo CROSS="$(CROSS)" \
PRODUCT_CLASS="$(PRODUCT_CLASS)" \
PRODUCT_MODEL="$(PRODUCT_MODEL)" \
SOC_MODEL="$(SOC_MODEL)" \
INC_PATH="$(INC_PATH)" \
LIB_PATH="$(LIB_PATH)" \
BIN_PATH="$(BIN_PATH)" \
DBG_PATH="$(DBG_PATH)" \
FUNCTION_DEF_LIB="$(shell echo $(FUNCTION_DEF) | tr A-Z a-z )" \
SRC_FUNCTION_DEF="$(SRC_FUNCTION_DEF)" \
LDFLAGS_EXT="$(LDFLAGS_EXT)" \
DEVICE_MODEL="$(DEVICE_MODEL)" \
DEF_EXT="$(DEF_EXT)" \
demo: clean sdk demoapp #目标文件依赖于clean,sdk,demoapp文件
packet_demo: api #目标文件packet_demo由以下命令语句生成,且依赖于api文件
rm -f IPC_demo*.tar.gz
rm -rf $(PAK_PATH)
mkdir $(PAK_PATH)
mkdir $(PAK_PATH)/bin
cp -a demo $(PAK_PATH)
cp -a include $(PAK_PATH)
cp -a sdk $(PAK_PATH)
cp -a Makefile $(PAK_PATH)
cp -a lib $(PAK_PATH)
tar -zcvf `date "+IPC_demo-%Y%m%d-%H%M-$(MODEL_NAME).tar.gz"` package_demo;
config: #目标文件config由以下rm ,cp语句编译生成
rm -f $(CURDIR)/config.ini
cp -a $(CONFIG_DIR_SRC) $(CURDIR)/config.ini
#eg: make config MODEL=hi3518a
#这里的clean表示清除,当执行amke clean事将执行下面的rm -f 删除语句
clean:
rm -f $(shell find $(CURDIR) -name *.o)
rm -f $(shell find $(CURDIR) -name *.d)
2config.ini文件的阅读理解
打开config.ini所在路径,自己阅读理解如下图标注#后的中文解释
。
![ac33b2a5c4b98dbdc4893178cb91857a.png](en-resource://database/554:1)
用vi文本编译器打开 config.ini进行阅读 ,内容如下图。
![39aea61c6d640e621a050947f2b9a72d.png](en-resource://database/553:0)
自己的阅读理解如下标注#后的中文解释。
#Hisilicon Hi3516d inception
#以下的:=语句表示将:=右边的表达式或变量赋值给左边的表达式或变量
DEVICE_MODEL := hi3516d_inc
PRODUCT_CLASS := hi3516d-inception
PRODUCT_MODEL := 564220
SOC_MODEL := HI3516D
CROSS := arm-hisiv300-linux-
SERISE_CODE := C5
FUNCTION_DEF := N1 ONVIFNVT TFCARD P2P STEPER_AF
MODEL_ROOTFS := rootfs_16a
DEF_EXT += "-DUART_PTZ"
DEF_EXT += "-DSAFETY"
DEF_EXT += "-DSD_GPIO_I2C"
#DEF_EXT += "-DXC_PRODUCT"
NULL_FOLDER := null_folder
PRODUCT_NAME := HI3516D_MODEL
#############################################################
FLASH_MAP_INI := flashmap_hi3516d_xc.ini
UBOOT_ENV_TXT := uboot_env_hi3516d.txt
UBOOT_ENV_SIZE := 128K
MPP_PACKET := 3516a_xc
NETSDK_PACKET_MODEL1 := 3516a_xc
NETSDK_PACKET_MODEL2 := $(NULL_FOLDER)
SHELL_MODEL_SRC := 3516a
RESOURCE_MODEL_SRC := 16d_web_new
ISP_CFG_MODEL_SRC := hi_isp_cfg_ini_16A_D
JA_TOOLS_SRC := ja_tools
MODEL_CONF_SRC := model/3516DV100
LICENSE := license
#############################################################
MPP_PACKET_PATH := mpp
NETSDK_PACKET_PATH := netsdk
RESOURCE_PACKET_PATH := resource
SHELL_PACKET_PATH := shell
MODEL_CONF_PATH := model_conf
#以下的:=语句表示将:=右边的路径或变量赋值给左边的变量
IMAGE_PATH := "$(CURDIR)/image/"
IMAGE_ROOTFS := $(IMAGE_PATH)rootfs.squash.uboot
IMAGE_RESOURCE := $(IMAGE_PATH)rootfs.squash.resource
IMAGE_UBOOTENV := $(IMAGE_PATH)u-boot-env.bin
#MK_ROM_BIN := "./tools/mk_rom_bin"
#MK_UBOOT_ENV := "./tools/mk_uboot_env"
IMAGE_APP_HOME_DIR_SRC := $(CURDIR)/../app_rebulid/bin
IMAGE_APP_EXEC_SRC := $(IMAGE_APP_HOME_DIR_SRC)/ipcam_app_rel
IMAGE_APP_SHELL_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(SHELL_PACKET_PATH)/$(SHELL_MODEL_SRC)
IMAGE_APP_RESOURCE_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(RESOURCE_PACKET_PATH)/$(RESOURCE_MODEL_SRC)
IMAGE_APP_FLASH_MAP_SRC := $(CURDIR)/flashmap/$(FLASH_MAP_INI)
IMAGE_APP_NETSDK_DIR_SRC_MODEL1 := $(IMAGE_APP_HOME_DIR_SRC)/$(NETSDK_PACKET_PATH)/$(NETSDK_PACKET_MODEL1) # FIXME:
IMAGE_APP_NETSDK_DIR_SRC_MODEL2 := $(IMAGE_APP_HOME_DIR_SRC)/$(NETSDK_PACKET_PATH)/$(NETSDK_PACKET_MODEL2) # FIXME:
IMAGE_LINUX_MODULE_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(MPP_PACKET_PATH)/$(MPP_PACKET)
IMAGE_APP_WIFI_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(NULL_FOLDER)
IMAGE_APP_SDCARD_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(NULL_FOLDER)
IMAGE_APP_JA_TOOLS_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(JA_TOOLS_SRC)
IMAGE_APP_ISP_CFG_INI_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(ISP_CFG_MODEL_SRC)
IMAGE_APP_MODEL_CONF_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(MODEL_CONF_PATH)/$(MODEL_CONF_SRC)
IMAGE_APP_LICENSE_DIR_SRC := $(IMAGE_APP_HOME_DIR_SRC)/$(LICENSE)
IMAGE_APP_HOME_DIR_DST := $(MODEL_ROOTFS)/usr/share/ipcam
IMAGE_APP_EXEC_DST := $(IMAGE_APP_HOME_DIR_DST)/app
IMAGE_APP_SHELL_DST := $(IMAGE_APP_HOME_DIR_DST)/shell
IMAGE_APP_RESOURCE_DIR_DST := ./resource
IMAGE_APP_FLASH_MAP_DST := $(IMAGE_APP_HOME_DIR_DST)/flashmap.ini
IMAGE_APP_NETSDK_DIR_DST_MODEL1 := $(IMAGE_APP_HOME_DIR_DST)/resource/netsdk_3516a100 # FIXME:
IMAGE_APP_NETSDK_DIR_DST_MODEL2 := $(IMAGE_APP_HOME_DIR_DST)/resource/netsdk_3516c100 # FIXME:
IMAGE_APP_NETSDK_DIR_RESOURCE_DST_MODEL1 := $(IMAGE_APP_RESOURCE_DIR_DST)/netsdk_3516a100 # FIXME:
IMAGE_APP_NETSDK_DIR_RESOURCE_DST_MODEL2 := $(IMAGE_APP_RESOURCE_DIR_DST)/netsdk_3516c100 # FIXME:
IMAGE_LINUX_MODULE_DST := $(IMAGE_APP_HOME_DIR_DST)/mpp
IMAGE_APP_WIFI_DIR_DST := $(IMAGE_APP_HOME_DIR_DST)/wifi_tools
IMAGE_APP_SDCARD_DIR_DST := $(IMAGE_APP_HOME_DIR_DST)/sdcard_tools
IMAGE_APP_JA_TOOLS_DIR_DST := $(IMAGE_APP_HOME_DIR_DST)/ja_tools
IMAGE_APP_ISP_CFG_INI_DST := $(IMAGE_APP_RESOURCE_DIR_DST)/ispcfg # FIXME:
IMAGE_APP_MODEL_CONF_DIR_DST := $(IMAGE_APP_RESOURCE_DIR_DST)/model_conf
IMAGE_APP_LICENSE_DIR_DST := $(IMAGE_APP_RESOURCE_DIR_DST)/license