BCM VOIP 应用程序编译分析

VOIP应用程序源码分布:

Vodsl(VOIP应用程序) -- userspace/private/apps/vodsl
  |_bos(系统适配层)-- xChange/dslx_common/xchg_common
  |_endpoint(驱动适配层)-- userspace/private/apps/vodsl/endpoint
  |_voip(主程序)
  |_prov(配置、调试接口及sip程序main)--userspace/private/apps/vodsl/voip/prov
  |_pstn(FXO相关业务)--userspace/private/apps/vodsl/voip/pstn
  |_rtp(RTP相关处理)--userspace/private/apps/vodsl/voip/rtp
  |_util(辅助模块,如防火墙控制、日志等)--userspace/private/apps/vodsl/voip/util
  |_sip(sip协议产品目录)--userspace/private/apps/vodsl/voip/sip
      |_codec(编码列表相关)-- xChange/dslx_common/voice_res_gw/codec
      |_callctrl(MT5协议栈适配层)—
xChange/dslx_common/prot_callctrl/stacks/callctrl
      |_callmgr(呼叫管理模块)-- xChange/dslx_common/prot_callctrl/apps/vrg
      |_sip_mx(MT5协议栈,无源码,库路径为)—
userspace/private/apps/vodsl/voip/sip/sip_mx/lib


 

VOIP应用程序编译分析:

一、根目录Makefile

all: prebuild_checks all_postcheck1

 

all_postcheck1:  profile_saved_check sanity_check \

     create_install kernelbuild modbuild kernelbuildlite \

     userspace  gdbserver vodsl dectd hosttools buildimage

 

vodsl: sanity_check

         //这里BUILD_VODSLprofile里定义为BUILD_VODSL=dynamic

         $(MAKE) -C $(BUILD_DIR)/userspace/private/apps/vodsl $(BUILD_VODSL)

 

二、userspace/private/apps/vodsl的Makefile

dynamic: $(PROGRAM_NAME) install dectfwucp

 

$(PROGRAM_NAME): subdirs $(OBJS)

         ……   //这里依赖SUBDIRS各子目录的.o目标文件生成vodsl主程序

 

OBJS = $(foreach obj,$(SUBDIRS),$(obj)/$(obj).o)

 

subdirs: $(patsubst %, _dir_%, $(SUBDIRS))

 

//这里TGT为空

//通过profilemake.voice结合,查到目前SUBDIRS包含endpoint  bos  voip

$(patsubst %, _dir_%, $(SUBDIRS)) :

         $(MAKE) -C $(patsubst _dir_%, %, $@) $(TGT)

 

三、userspace/private/apps/vodsl/endpoint的Makefile

endpoint.o: $(OBJS)

    ……    //生成endpoint.o

 

OBJS = endpoint_user.o endpoint_test.o

 

四、userspace/private/apps/vodsl/bos的Makefile

bos.o: $(BOSLIBS_SUBDIR)/*.o $(LIB) generic_private_lib_install

 

BOSLIBS_SUBDIR  = lib

$(BOSLIBS_SUBDIR)/*.o:

    //切换到xChange/dslx目录

    cd $(XCHANGE_DIR)/dslx;

   

    //使用build脚本生成bos库涉及到的.a静态库,build脚本下面单独分析

    //通过查看  make.voice和profile,各环境变量如下:

    //XCHANGE_BUILD_APP = Bcm6828uni

    //XCHANGE_DSP_APP = all

    // XCHANGE_DSP_APP_EXTENSION = 空

    $(XCHANGE_DIR)/dslx/build -a $(XCHANGE_BUILD_APP)

-d $(XCHANGE_DSP_APP)$(XCHANGE_DSP_APP_EXTENSION)

-t bosu $(XCHANGE_BUILD_EXTRA_CFLAGS);

   

mkdir -p $(CURDIR)/$(BOSLIBS_SUBDIR)

 

//将上面build脚本生成的静态库复制到BOSLIBS_SUBDIR下面

for i   in  $(BOSLIBS); do  \

cp $(XCHANGE_DIR)/dslx/lib/LinuxUser/$(XCHANGE_BUILD_APP)/xchg/$$i.a $(CURDIR)/$(BOSLIBS_SUBDIR)/$$i.lib; \

done; \

 

//将BOSLIBS_SUBDIR下面的静态库全部解压开

cd  $(CURDIR)/$(BOSLIBS_SUBDIR); \

for i   in  $(BOSLIBS); do  \

$(AR)   x $$i.lib;      \

done;

 

//将解压后的.o文件重新链接成所需要的目标文件bos.o

$(LD) -G 0 -r $@ -o $(BOSTARGET);

 

build -a Bcm6828uni –d all –t bosu 分析

 

该脚本通过参数解析,最后主要执行如下动作,其中设置如下环境变量:

APPDIR = Bcm6828uni ;

DSPAPP = all

TARGET = bosu

CXC_OS_TYPE = LinuxUser

CXC_LINUX_ARCHITECTURE = MIPS

BOS_LIBS = bos sme str

 

//进入xChange/dslx/apps/Bcm6828uni目录

cd ${CXC_PROJ_DIR}/dslx/apps/${APPDIR}

 

//执行该目录下的Makefile,编译目标为xchg_common

make verbose=${VERBOSE} dspapp=${DSPAPP} xchg_common

 

xChange/dslx/apps/Bcm6828uni下Makefile分析

 

include cxcApp$(notdir $(CURDIR)).mk //仅仅引用当前目录下的cxcAppBcm6828uni.mk

 

xChange/dslx/apps/Bcm6828uni下cxcAppBcm6828uni.mk分析

 

//定义DSP库文件的目录

 

//引用xChange/dslx/apps/rules/cxcAppRules.mk

include ../rules/cxcAppRules.mk

 

xChange/dslx/apps/rules下cxcAppRules.mk分析

 

//后面用到XCHG_MAKE_TARGETS环境变量

CXC_XCHG_TARGET_LIST := assert bos containers sme str trace blog

export XCHG_MAKE_TARGETS   := $(CXC_XCHG_TARGET_LIST)

 

//这里的XCHG_LIB_DIR环境变量比较重要,下面编译生成的静态库就输出在这里

//上面引用的静态库也是从这里引用的.

xc xchg_common:

    // XCHG_ROOT = xChange/dslx_common/xchg_common

$(MAKE) -C $(XCHG_ROOT) -f xchg_common.mk \

XCHG_LIB_DIR=$(CXC_BASE_LIB_DIR)/$(CXC_XCHG_OUTPUT_DIR) XCHG_OBJ_DIR=$(CXC_BASE_OBJ_DIR)/$(CXC_XCHG_OUTPUT_DIR)

 

xChange/dslx_common/xchg_common下xchg_common.mk分析

 

//这里引用了$(XCHG_ROOT)/xchg_common_targets.mk,而xchg_common_targets.mk里定义

//XCHG_ALL_TARGETS环境变量

include $(XCHG_ROOT)/xchg_common_env.mk

 

XCHG_VALID_TARGETS=$(XCHG_ALL_TARGETS) $(addprefix clean_,$(XCHG_ALL_TARGETS)) $(addprefix audit_,$(XCHG_ALL_TARGETS))

 

//这里MAKECMDGOALS为空,所以最终libTargets从XCHG_MAKE_TARGETS中取值

ifeq ($(strip $(filter $(MAKECMDGOALS),${XCHG_VALID_TARGETS})),)

libTargets := $(XCHG_MAKE_TARGETS)

else

xxx

endif

 

//这里all的目标定义在xChange/dslx_common/xchg_common/rules/xChgRules.mk

all:

 

//引用BOS模块编译所需要的各子目录下的Makefile,其中各子目录下的Makefile定义了

//各自关键的XCHG_LIB_BASE  XCHG_SRC_FILES环境变量

XCHG_MODULE_MAKEFILES :=

$(foreach target,$(libTargets),$(XCHG_DIR_$(target))/$(target).mk)

include $(XCHG_MODULE_MAKEFILES)

 

include $(XCHG_ROOT)/rules/xChgRules.mk

//xChgRules.mk里定义的all

all: target

 

//当前XCHG_MAKE_TARGETS环境变量值上从上面引用过来的,当前该值为

//assert bos containers sme str trace blog

//这里target的依赖规则都是从下面的XCHG_ARCHIVE_TEMPLATE功能宏中定义

target: $(XCHG_MAKE_TARGETS)

 

//调用功能宏XCHG_ARCHIVE_TEMPLATE,该功能宏定义在

//xChange/dslx_common/xchg_common/rules/xChgRules.mk中

//该功能宏的传入参数依次为assert bos containers sme str trace blog

$(foreach target,$(libTargets),$(eval $(call XCHG_ARCHIVE_TEMPLATE,$(target))))

 

xChange/dslx_common/xchg_common/rules/xChgRules.mk分析

 

define XCHG_ARCHIVE_TEMPLATE

 

//这里不同模块依赖的目标文件,都是从各模块自身的源文件列表中编译生成

XCHG_OBJ_FILES_$(1) := $(addprefix $(XCHG_OBJ_DIR)/, $(addsuffix $(XCHG_OBJ_EXT),$(basename $(XCHG_SRC_FILES_$(1)))))

XCHG_DEP_FILES_$(1) := $$(XCHG_OBJ_FILES_$(1):$(XCHG_OBJ_EXT)=.d)

XCHG_PREPROCESSED_FILES_$(1) := $(addsuffix .pp,$(basename $(XCHG_SRC_FILES_$(1))))

 

//该变量内容比较重要,最终生成的各个静态库目标文件就是存储在这里,这里调用了

// XCHG_MAKE_LIB_NAME功能宏,该功能宏定义在

//xChange/dslx_common/xchg_common/rules/xChgEnv.mk中,

//注意这里使用了XCHG_LIB_DIR,即上面在解压静态库时的路径

//在xChgEnv.mk中定义如下:

//XCHG_MAKE_LIB_NAME =

//$(foreach //libBase,$(1),$(XCHG_LIB_DIR)/$(XCHG_LIB_PREFIX)$(libBase)$(XCHG_LIB_EXT))

XCHG_LIB_NAME_$(1) := $(call XCHG_MAKE_LIB_NAME,$(1))

 

$(1) : XCHG_C_LOCAL_INCLUDE := $$(XCHG_C_LOCAL_INCLUDE_$(1))

$(1) : XCHG_C_LOCAL_DEFS := $$(XCHG_C_LOCAL_DEFS_$(1))

$$(XCHG_DEP_FILES_$(1)) : XCHG_C_LOCAL_INCLUDE := $$(XCHG_C_LOCAL_INCLUDE_$(1))

$$(XCHG_DEP_FILES_$(1)) : XCHG_C_LOCAL_DEFS := $$(XCHG_C_LOCAL_DEFS_$(1))

$$(XCHG_PREPROCESSED_FILES_$(1)) : XCHG_C_LOCAL_INCLUDE := $$(XCHG_C_LOCAL_INCLUDE_$(1))

$$(XCHG_PREPROCESSED_FILES_$(1)) : XCHG_C_LOCAL_DEFS := $$(XCHG_C_LOCAL_DEFS_$(1))

 

//这里就是上面$(XCHG_MAKE_TARGETS)的所有依赖目标,分别根据各自的源文件,生成对

//应的静态库。

$(1) : $$(XCHG_LIB_NAME_$(1))

$$(XCHG_LIB_NAME_$(1)) : $$(XCHG_OBJ_FILES_$(1))

    $(ECHO) 'Creating Archive $$@'

    $(MKDIR) -p $$(@D)

    $(RM) -f $$@

    $(XCHG_ARCHIVE) $(XCHG_ARCHIVE_OPTS)$$@ $$^

    $(ECHO)

 

endef

 

五、userspace/private/apps/vodsl/voip的Makefile

//通过分析make.voice 和 profile,SUBDIRS环境变量的内容如下

SUBDIRS  =  rtp util pstn prov sip

 

OBJS = $(foreach obj,$(SUBDIRS),$(obj)/$(obj).o)

 

//能过各子目录的.o文件生成voip.o

voip.o: subdirs $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

//进入到各子目录进行编译

$(patsubst %, _dir_%, $(SUBDIRS)) :

    $(MAKE) -C $(patsubst _dir_%, %, $@) $(TGT)

 

-----------------------------------------------------------------------------

1、userspace/private/apps/vodsl/voip/rtp的Makefile

OBJS = rtpapi.o rtcp.o udp.o

 

rtp.o: $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

2、userspace/private/apps/vodsl/voip/util的Makefile

//通过分析make.voice和profile,SUBDIRS环境变量的内容如下

SUBDIRS  = net regexp signal qos firewall map log vodslcmslock feature

OBJS = $(foreach obj,$(SUBDIRS),$(obj)/$(obj).o)

 

util.o: subdirs $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

//分别进入各子目录进行编译,不细分析。

$(patsubst %, _dir_%, $(SUBDIRS)) :

    $(MAKE) -C $(patsubst _dir_%, %, $@) $(TGT)

 

3、userspace/private/apps/vodsl/voip/pstn的Makefile

OBJS = ccMaps.o ccPstn.o

 

pstn.o: $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

4、userspace/private/apps/vodsl/voip/prov的Makefile

//通过分析make.voice和profile,OBJS变量内容如下:

OBJS = endptProv.o endptCmd.o endptProbe.o provisData.o sipCli.o

 

prov.o: $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

5、userspace/private/apps/vodsl/voip/sip的Makefile

//通过分析make.voice和profile,SUBDIRS变量内容如下:

SUBDIRS  = codec callctrl callmgr sip_mx

OBJS = $(foreach obj,$(SUBDIRS),$(obj)/$(obj).o)

 

sip.o: subdirs $(OBJS)

    $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(OBJS)

 

//进入各子目录进行编译

$(patsubst %, _dir_%, $(SUBDIRS)) :

    $(MAKE) -C $(patsubst _dir_%, %, $@) $(TGT)

 

5.1、userspace/private/apps/vodsl/voip/sip/codec的Makefile

CODECTARGET = codec.o

CODECLIB_DIR  = $(XCHANGE_DIR)/dslx/lib/LinuxKernel/$(XCHANGE_BUILD_APP)/vrg

CODECLIB = codec.a

 

%: force

 

force:

    //使用xChange/dslx/build脚本构造codec模块相关的静态库

    cd $(XCHANGE_DIR)/dslx;

    $(XCHANGE_DIR)/dslx/build -a $(XCHANGE_BUILD_APP)

-d $(XCHANGE_DSP_APP)$(XCHANGE_DSP_APP_EXTENSION) -t codec $(EXTRA_CFLAGS);

 

//将build脚本构建好的静态库复制出来,并解压,然后将解压后的.o文件重新生成最

//终所需要的codec.o目标文件

    mkdir -p tmp

    cp -f $(CODECLIB_DIR)/$(CODECLIB) ./tmp/$(CODECTEMP_TARGET)

    cd tmp; $(AR) x $(CODECTEMP_TARGET)

   

    $(LD) $(EXTRA_LDFLAGS) -r -o $(CODECTARGET) tmp/*.o

 

----------------------------------------------------------------------------

build –t codec脚本分析

 

分析了build脚本,codec的编译非应用层编译,上面需要的静态库是由make modbuild生成

 

5.2、userspace/private/apps/vodsl/voip/sip/callctrl的Makefile

CCTARGET = callctrl.o

CCLIB_DIR  = $(XCHANGE_DIR)/dslx/lib/LinuxUser

CCLIB = libcallctrl.a

 

%: force

 

force:

    //使用xChange/dslx/build脚本构造callctrl模块相关的静态库

    cd $(XCHANGE_DIR)/dslx; \

    $(XCHANGE_DIR)/dslx/build -a $(XCHANGE_BUILD_APP)

-d $(XCHANGE_DSP_APP)$(XCHANGE_DSP_APP_EXTENSION) -t sipcc $(EXTRA_CFLAGS);

 

//将build脚本构建好的静态库复制出来,并解压,然后将解压后的.o文件重新生成最

//终所需要的callctrl.o目标文件

    mkdir -p tmp

    cp -f $(CCLIB_DIR)/$(CCLIB) ./tmp/$(CCTEMP_TARGET)

    cd tmp;ar x $(CCTEMP_TARGET)

 

    $(LD) $(EXTRA_LDFLAGS) -r -o $(CCTARGET) tmp/*.o

 

----------------------------------------------------------------------------

build –t sipcc脚本分析

 

CXC_OS_TYPE=LinuxUser

CXC_LINUX_ARCHITECTURE=MIPS

 

//进入xChange/dslx/apps/Bcm6828uni目录

cd ${CXC_PROJ_DIR}/dslx/apps/${APPDIR}

 

//执行该目录下的Makefile,目标为callctrl

make verbose=${VERBOSE} dspapp=${DSPAPP} callctrl

 

xChange/dslx/apps/Bcm6828uni下cxcAppBcm6828uni.mk分析

 

//定义DSP库文件的目录

 

//引用xChange/dslx/apps/rules/cxcAppRules.mk

include ../rules/cxcAppRules.mk

 

xChange/dslx/apps/rules下cxcAppRules.mk分析

 

//引用了cxcAppEnv.mk,这时定义了关键的 CXC_CABLEX_DIR := $(CXC_PROJ_DIR)/dslx

//环境变量,该环境变量最终和下面的XCHG_LIB_DIR合成静态库生成的路径,该路径与

//上面要引用的静态库路径相同。

include $(CXC_PROJ_DIR)/dslx/apps/rules/cxcAppEnv.mk

 

callctrl:

    //进入xChange/dslx_common/prot_callctrl/build/vrg/dslx目录下,执行

    // sip_cc.mk

    $(MAKE) -C $(CXC_SIP_CC_DIR)/build/vrg/dslx -f sip_cc.mk

 

xChange/dslx_common/prot_callctrl/build/vrg/dslx/sip_cc.mk分析

 

XCHG_LIB_BASE  := libcallctrl

XCHG_LIB_DIR = $(CXC_CABLEX_DIR)/lib/$(CXC_OS_TYPE)/

XCHG_OBJ_DIR = $(CXC_CABLEX_DIR)/obj/$(CXC_OS_TYPE)/callctrl

 

//比较重要,在下面调用xChgRules.mk时,xChgRules.mk会判断该宏设置了才进行额外的//默认规则引用

XCHG_RECURSIVE_BUILD=1

 

//引用xChange/dslx_common/prot_callctrl/build/vrg/dslx/sources_sip_cc.mk

//主要定义了SRCDIR_SIP_CC  SRCS_SIP_CC 两个环境变量,包含callctrl的目录及源

//文件

CALLCTRLLIB_ROOT    := $(CXC_SIP_CC_DIR)

include $(CALLCTRLLIB_ROOT)/build/vrg/dslx/sources_sip_cc.mk

 

export CALLCTRL_SRC = $(SRCS_SIP_CC)

//这里可以看到callctrl模块的源码主要集中在

//xChange\dslx_common\prot_callctrl\stacks\callctrl目录中

CALLCTRL_SRCDIR = $(addprefix $(CALLCTRLLIB_ROOT)/stacks/callctrl/, $(SRCDIR_SIP_CC))

 

XCHG_SRC_FILES := $(CALLCTRL_SRC)

vpath %.c $(CALLCTRL_SRCDIR)

 

//引用xChange/dslx_common/xchg_common/rules/xChgRules.mk

include $(XCHG_RULES_DIR)/xChgRules.mk

 

xChange/dslx_common/xchg_common/rules/xChgRules.mk分析

 

all: target

 

XCHG_OBJ_FILES = $(addprefix $(XCHG_OBJ_DIR)/,

$(addsuffix $(XCHG_OBJ_EXT),$(basename $(XCHG_SRC_FILES))))

 

//上面已经赋值,才会进行此分支,额外增加引用规则

ifneq ($(XCHG_LIB_BASE),)

ifeq ($(XCHG_RECURSIVE_BUILD),1)

 

//这里调用了XCHG_MAKE_LIB_NAME功能宏,该功能宏定义在

//xChange/dslx_common/xchg_common/rules/xChgEnv.mk中,最终将引用

//XCHG_LIB_DIR环境变量组成生成静态库输出的目录,这个目录也是最上面

//引用静态库的地方。

XCHG_LIB_NAME  := $(call XCHG_MAKE_LIB_NAME,$(XCHG_LIB_BASE))

 

lib: $(XCHG_LIB_NAME)

target: lib

 

//生成最终的静态库目标

$(XCHG_LIB_NAME) : $(XCHG_OBJ_FILES)

    $(ECHO) 'Creating Archive $@'

    @$(MKDIR) -p $(@D)

    $(RM) -f $@

    $(XCHG_ARCHIVE) $(XCHG_ARCHIVE_OPTS)$@ $^

 

endif

endif

 

5.3、userspace/private/apps/vodsl/voip/sip/callmgr的Makefile

CALLMGRTARGET = callmgr.o

CALLMGRLIB_DIR  = $(XCHANGE_DIR)/dslx/lib/LinuxUser

CALLMGRLIB = libcallmgr.a

 

%: force

 

force:

    //使用xChange/dslx/build脚本构造sipcmgrcctrl模块相关的静态库

    cd $(XCHANGE_DIR)/dslx;                 \

    $(XCHANGE_DIR)/dslx/build -a $(XCHANGE_BUILD_APP)

-d $(XCHANGE_DSP_APP)$(XCHANGE_DSP_APP_EXTENSION)

-t sipcmgrcctrl $(EXTRA_BUILD_FLAGS) -D IP_SIP -D $(SIP_ALG_BUILD_FLAGS);

   

//将build脚本构建好的静态库复制出来,并解压,然后将解压后的.o文件重新生成最

//终所需要的callmgr.o目标文件

    mkdir -p tmp

    cp -f $(CALLMGRLIB_DIR)/$(CALLMGRLIB) ./tmp/$(CALLMGRTEMP_TARGET)

    cd tmp; $(AR) x $(CALLMGRTEMP_TARGET)

    $(LD) $(EXTRA_LDFLAGS) -r -o $(CALLMGRTARGET) tmp/*.o

 

-----------------------------------------------------------------------------

build –t sipcmgrcctrl脚本分析

 

CXC_OS_TYPE=LinuxUser

CXC_LINUX_ARCHITECTURE=MIPS

 

//进入xChange/dslx/apps/Bcm6828uni目录,执行该目录下的Makefile,目标为callmgr

cd ${CXC_PROJ_DIR}/dslx/apps/${APPDIR}

make verbose=${VERBOSE} dspapp=${DSPAPP} callmgr

 

------------------------------------------------------------------------------

xChange/dslx/apps/Bcm6828uni下cxcAppBcm6828uni.mk分析

 

//定义DSP库文件的目录

 

//引用xChange/dslx/apps/rules/cxcAppRules.mk

include ../rules/cxcAppRules.mk

 

xChange/dslx/apps/rules下cxcAppRules.mk分析

 

//进入xChange/dslx_common/prot_callctrl/build/vrg/dslx目录下,执行sip_cmgr.mk

callmgr:

    $(MAKE) -C $(CXC_SIP_CMGR_DIR)/build/vrg/dslx -f sip_cmgr.mk

 

xChange/dslx_common/prot_callctrl/build/vrg/dslx/sip_cmgr.mk分析

 

XCHG_LIB_BASE  := libcallmgr

XCHG_LIB_DIR = $(CXC_CABLEX_DIR)/lib/$(CXC_OS_TYPE)/

XCHG_OBJ_DIR = $(CXC_CABLEX_DIR)/obj/$(CXC_OS_TYPE)/callmgr

 

//比较重要,在下面调用xChgRules.mk时,xChgRules.mk会判断该宏设置了才进行额外的//默认规则引用

XCHG_RECURSIVE_BUILD=1

 

//引用xChange/dslx_common/prot_callctrl/build/vrg/dslx/ sources_sip_cmgr.mk

//主要定义了SRCDIR_SIP_CMGR  SRCS_SIP_CMGR 两个环境变量,包含callmgr的目录及源

//文件

include $(CALLMGRLIB_ROOT)/build/vrg/dslx/sources_sip_cmgr.mk

 

export CALLMGR_SRC = $(SRCS_SIP_CMGR)

export CALLMGR_SRCDIR = $(addprefix $(CALLMGRLIB_ROOT)/apps/vrg/, $(SRCDIR_SIP_CMGR))

 

XCHG_SRC_FILES := $(CALLMGR_SRC)

vpath %.c $(CALLMGR_SRCDIR)

 

//引用xChange/dslx_common/xchg_common/rules/xChgRules.mk

include $(XCHG_RULES_DIR)/xChgRules.mk

 

-----------------------------------------------------------------------------

xChange/dslx_common/xchg_common/rules/xChgRules.mk分析

 

all: target

 

XCHG_OBJ_FILES = $(addprefix $(XCHG_OBJ_DIR)/, $(addsuffix $(XCHG_OBJ_EXT),$(basename $(XCHG_SRC_FILES))))

 

//上面已经赋值,才会进行此分支,额外增加引用规则

ifneq ($(XCHG_LIB_BASE),)

ifeq ($(XCHG_RECURSIVE_BUILD),1)

 

//这里调用了XCHG_MAKE_LIB_NAME功能宏,该功能宏定义在

// xChange/dslx_common/xchg_common/rules/xChgEnv.mk中,最终将引用

// XCHG_LIB_DIR环境变量组成生成静态库输出的目录,这个目录也是最上面

//引用静态库的地方。

XCHG_LIB_NAME  := $(call XCHG_MAKE_LIB_NAME,$(XCHG_LIB_BASE))

 

lib: $(XCHG_LIB_NAME)

target: lib

 

//生成最终的静态库目标

$(XCHG_LIB_NAME) : $(XCHG_OBJ_FILES)

    $(ECHO) 'Creating Archive $@'

    @$(MKDIR) -p $(@D)

    $(RM) -f $@

    $(XCHG_ARCHIVE) $(XCHG_ARCHIVE_OPTS)$@ $^

 

endif

endif

 

5.4、userspace/private/apps/vodsl/voip/sip/sip_mx的Makefile

SIPTARGET = sip_mx.o

SIPSRC_DIR = $(XCHANGE_DIR)/dslx_common/prot_callctrl/stacks/sip_mx

SIPLIB = libsip_mx.a

 

%: force

 

force:

    //查找是否含有协议栈源码文件,当前项目没有MT5协议栈原码,所以不进此分支

    @rm -f $(TMPFILE);

    @find $(SIPSRC_DIR) -name '*.cpp' > $(TMPFILE)

    @if [ -s $(TMPFILE) ];then

        ……

    fi

   

    //直接复制方案商提供的静态库

    //CURDIR = userspace/private/apps/vodsl/voip/sip/sip_mx

    cp -f $(CURDIR)/lib/$(SIPLIB) $(CURDIR)/$(SIPTARGET)

 

你可能感兴趣的:(broadcom,4.X,原版VOIP代码分析)