Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2526|回复: 3
打印 上一主题 下一主题

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

[复制链接]

3

主题

7

帖子

19

积分

实习版主

Rank: 7Rank: 7Rank: 7

积分
19
跳转到指定楼层
楼主
发表于 2016-12-9 18:22:28 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
即源码级修改了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


回复

使用道具 举报

3

主题

7

帖子

19

积分

实习版主

Rank: 7Rank: 7Rank: 7

积分
19
沙发
 楼主| 发表于 2016-12-9 18:28:28 | 只看该作者
makefile的参数
一般我们执行make –fclient.mk build;除了build

   
Target   name
   
   
Description
   
  
build
  
  
Default  target. Compile Firefox, Thunderbird, etc
  
  
check
  
  
Standalone  shell unit test invoked directly by make
  
  
configure
  
  
Launch  the configure program to define headers and and attributes for the target  build machine.
  
  
export
  
  
Generate  and install exported headers: EXPORTS
  
  
makefiles
  
  
Target  used to only regenerate makefiles
  
  
package
  
  
Generate  a package tarball
  

  
Clean Targets
  
  
clean
  
  
Remove object files, binaries and generated content
  
  
clobber
  
  
alias for clean
  
  
distclean
  
  
Clean + configure cleanup
  

主要流程
1.configureconfigure.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的大部分规则在configure
DEPTH               = @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 ...

l  MODULE=xxx模块名,会在 include下创建模块文件夹,如dist/include/$(MODULE)。
l  MODULE_NAME=xxx:如果makefile是用于产生一个component,需要指定组件注册的名字,改名字需要和NS_IMPL_NSGETMODULE函数指定的名字一致。(目前该函数已经不再使用,一般设为component模块定义的文件名字,如例子代码中的nsSampleModule)
l  EXPORTS=xxx.h:需要导出的头文件,拷贝到dist/include/$(MODULE)下.

l  XPIDL_MODULE=xxx:指定IDL文件产生的xpt文件的名字,每一个有IDL文件的目录必须有一个唯一的typelib和文件,存放于dist/bin/component
l  XPIDLSRCS=xxx指定IDL文件,用于产生需要的头文件与xpt文件件,拷贝到dist/idl目录,产生的头文件拷贝/dist/include/$(MODULE)
l  LIBRARY_NAME=xxx:指定产生的lib的名字,存放于dist/bin/component。
l  SHORTLIB_NAME=xxxxxxxx: 指定一个8字符的名字,如xpcomsmp.dll
l  IS_COMPONENT:指定是否产生一个组件(component)。有三种库文件(组件,非组件动态库,静态库)。
n  组件:component是一种独立的动态库(也可以是静态编译的),不会被其他库引用,存放于dist/bin/component目录.
n  非组件动态库:放在dist/bin目录下,提供其他组件调用
n  静态库
l  FORCE_SHARED_LIB=1:把组件编译成dll形式,它与EXPORT_LIBRARY是对立的。
l  EXPORT_LIBRARY=1与BUILD_STATIC_LIBS一起使用,把component编译成静态形式
在--enable-static的模式下,组件会编译成静态库并连接到可执行程序,执行程序需要通过EXPORT_LIBRARY来表示可给连接
l  BUILD_STATIC_LIBS需要在—enable-static的编译条件下才会在autoconf.mk中设置(才会有效)。
l  FORCE_STATIC_LIB=1指示模块编译成静态库。
l  SHARED_LIBRARY_LIBS: 指定需要连接的库
l  EXTRA_COMPONENTS:安装组件组要的文件 *.js, *.manifest.
l  EXTRA_DSO_LDOPTS:当编译一个动态库时起效,用于连接需要的lib.
l  EXTRA_DSO_LIBS一般是嵌入到EXTRA_DSO_LDOPTS使用,标识一些lib,并自动产生对应的连接符号–lfoo(linux) foo.lib(windows)




回复 支持 反对

使用道具 举报

3

主题

7

帖子

19

积分

实习版主

Rank: 7Rank: 7Rank: 7

积分
19
板凳
 楼主| 发表于 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,即可编译该组件




回复 支持 反对

使用道具 举报

3

主题

7

帖子

19

积分

实习版主

Rank: 7Rank: 7Rank: 7

积分
19
地板
 楼主| 发表于 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).
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-4-20 20:44 , Processed in 0.061440 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表