hcj 发表于 2016-12-9 18:22:28

重新生成obj目录下的makefile方法及相关选项的设置

即源码级修改了makefile.in,然后再哪里执行相应的命令,能重新影响到它对应的makefile
方法1:在obj目录下的此文件夹的上一层,执行make,本层会重新生成makefile ,这种方法不太通用
可尝试 是否可以找到 执行相应的config或其它命令令其生效的方法
方法2:直接在此目标文件夹执行make,其流程是重新检测源码级的makefile.in,根据源码级的makefile.in重新生成目标文件夹下的makefile---基于makefile.in的改变自动转到目标上的makefile 使修改生效
方法3:在目标文件夹下执行 make export ,这样会影响到makefile的内容改变,但并不真正进行编译操作

源码级以D:\svn\code\thunderbird17.0.8\mail\Makefile.in为例





目标级:D:\svn\code\thunderbird17.0.8\tb_rel\mail\Makefile




掌握相应路径和宏的设置方法,后缀开发自己的代码时,可自己写对应的makefile.in以生成自己的makefile


hcj 发表于 2016-12-9 18:28:28

参考https://developer.mozilla.org/en-US/docs/How_Mozilla's_build_system_worksmakefile的参数一般我们执行make –fclient.mk build;除了build

   Target   name      Description   
buildDefaulttarget. Compile Firefox, Thunderbird, etc
checkStandaloneshell unit test invoked directly by make
configureLaunchthe configure program to define headers and and attributes for the targetbuild machine.
exportGenerateand install exported headers: EXPORTS
makefilesTargetused to only regenerate makefiles
packageGeneratea package tarball


Clean Targets
cleanRemove object files, binaries and generated content
clobberalias for clean
distcleanClean + configure cleanup

主要流程1.configure由configure.in(使用M4编写)通过Autoconf2.13生成。configure最初会生成config.status,并处理autoconf.mk,在这个阶段主要的结构都在config.status(python脚本),它的结构主要有两部分,一部分是作为configure的输出,一部分是build backend(一个类似gnu make的工具)的命令工具。2.make从根目录开始处理makefile,递归到每一个DIRS定义的子目录。调用编译器编译


Makefile相关(gunmake相关)标准头:由configure 替换其中的变量,configure的大部分规则在configureDEPTH               = @DEPTH@topsrcdir= @top_srcdir@srcdir               = @srcdir@VPATH                = @srcdir@


#大部分参数都是定义在config,mk与rules.mk之间

include$(topsrcdir)/config/config.mk
# ... Main body of Makefile goes here ...


include$(topsrcdir)/config/rules.mk
# ... Additional rules go here ...
lMODULE=xxx模块名,会在 include下创建模块文件夹,如dist/include/$(MODULE)。lMODULE_NAME=xxx:如果makefile是用于产生一个component,需要指定组件注册的名字,改名字需要和NS_IMPL_NSGETMODULE函数指定的名字一致。(目前该函数已经不再使用,一般设为component模块定义的文件名字,如例子代码中的nsSampleModule)lEXPORTS=xxx.h:需要导出的头文件,拷贝到dist/include/$(MODULE)下.
lXPIDL_MODULE=xxx:指定IDL文件产生的xpt文件的名字,每一个有IDL文件的目录必须有一个唯一的typelib和文件,存放于dist/bin/componentlXPIDLSRCS=xxx指定IDL文件,用于产生需要的头文件与xpt文件件,拷贝到dist/idl目录,产生的头文件拷贝/dist/include/$(MODULE)lLIBRARY_NAME=xxx:指定产生的lib的名字,存放于dist/bin/component。lSHORTLIB_NAME=xxxxxxxx: 指定一个8字符的名字,如xpcomsmp.dlllIS_COMPONENT:指定是否产生一个组件(component)。有三种库文件(组件,非组件动态库,静态库)。n组件:component是一种独立的动态库(也可以是静态编译的),不会被其他库引用,存放于dist/bin/component目录.n非组件动态库:放在dist/bin目录下,提供其他组件调用n静态库lFORCE_SHARED_LIB=1:把组件编译成dll形式,它与EXPORT_LIBRARY是对立的。lEXPORT_LIBRARY=1与BUILD_STATIC_LIBS一起使用,把component编译成静态形式在--enable-static的模式下,组件会编译成静态库并连接到可执行程序,执行程序需要通过EXPORT_LIBRARY来表示可给连接lBUILD_STATIC_LIBS需要在—enable-static的编译条件下才会在autoconf.mk中设置(才会有效)。lFORCE_STATIC_LIB=1指示模块编译成静态库。lSHARED_LIBRARY_LIBS: 指定需要连接的库lEXTRA_COMPONENTS:安装组件组要的文件 *.js, *.manifest.lEXTRA_DSO_LDOPTS:当编译一个动态库时起效,用于连接需要的lib.lEXTRA_DSO_LIBS一般是嵌入到EXTRA_DSO_LDOPTS使用,标识一些lib,并自动产生对应的连接符号–lfoo(linux) foo.lib(windows)

编译关键字见:https://developer.mozilla.org/en-US/docs/tag/Build%20Glossary

hcj 发表于 2016-12-9 18:29:29

https://developer.mozilla.org/en ... akefile_-_variables
对obj-i686-pc-mingw32\mozilla\xpcom\sample 单独编译

导出sample目录,在它上层makefile中加入字段
DIRS=\
    sample\
#这里不能有空行
    $(NULL)
执行 make export,即可导出.
例子中是把sample加到
(以来于下面的TOOL_DIRS )
TOOL_DIRS += \
    tests \
    sample \
    typelib/xpt/tests \#对typelib/xpt/tests有依赖
    $(NULL)


再进入sample,执行make,即可编译该组件




hcj 发表于 2016-12-9 18:29:50

Configure.in+mozilla/build/**.m4-------autoconfi2.1.3处理---->Configure
Configure+Makefile.in-----sh运行该configure脚本--->makefile

.mozconfig中
mk_add_options传给 client.mk文件。
ac_add_options传给configure.in文件。
大多数的编译配置选项都在configure.in中可以找到。
如:
MOZ_ARG_DISABLE_BOOL(tests,
[--disable-tests         Do not build test libraries & programs],
    ENABLE_TESTS=,
    ENABLE_TESTS=1 )
MOZ_ARG_DISABLE_BOOL 定义在mozilla/build/autoconf/altoptions.m4文件中
在.mozconfig中加入 ac_add_options --disable-tests即可影响ENABLE_TESTS这个编译条件

makefile.in标准头变量在生成每个makefile时自动复制,具体的函数在ConfigStatus.py,
DEPTH               = @DEPTH@
topsrcdir= @top_srcdir@   
srcdir               = @srcdir@
VPATH                = @srcdir@


    The DEPTH variable should be set to the relative path from your Makefile.in to the toplevel Mozilla directory.
    topsrcdir is substituted in by configure, and points to the toplevel mozilla directory.
    srcdir is also substituted in by configure, and points to the source directory for the current directory. In source tree builds, this will simply point to "." (the current directory).
    VPATH is a list of directories where make will look for prerequisites (i.e. source files).
页: [1]
查看完整版本: 重新生成obj目录下的makefile方法及相关选项的设置