binutils-2.18/opcodes/Makefile分析

 

快乐虾

http://blog.csdn.net/lights_joy/

lights@hb165.com

 

   

本文适用于

binutils-2.18

configure –target=bfin-uclinux-gnu

Blackfin系列DSP

Cygwin gcc 3.4.4

   

欢迎转载,但请保留作者信息

 

 

 

1       opcodes/Makefile

这个文件由主控Makefile调用configure脚本生成并执行make操作。要求生成的目标为all

1.1    all

Makefile中的第一个目标就是all

all: config.h

       $(MAKE) $(AM_MAKEFLAGS) all-recursive

因此它将执行all-recursive这个目标。这个目标的生成都是由RECURSIVE_TARGETS来完成的。

RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive /

       html-recursive info-recursive install-data-recursive /

       install-exec-recursive install-info-recursive /

       install-recursive installcheck-recursive installdirs-recursive /

       pdf-recursive ps-recursive uninstall-info-recursive /

       uninstall-recursive

# This directory's subdirectories are mostly independent; you can cd

# into them and run `make' without going through this Makefile.

# To change the values of `make' variables: instead of editing Makefiles,

# (1) if the variable is set in `config.status', edit `config.status'

#     (which will cause the Makefiles to be regenerated when you run `make');

# (2) otherwise, pass the desired values on the `make' command line.

$(RECURSIVE_TARGETS):

@failcom='exit 1'; /

for f in x $$MAKEFLAGS; do /

  case $$f in /

    *=* | --[!k]*);; /

    *k*) failcom='fail=yes';; /

  esac; /

done; /

dot_seen=no; /

target=`echo $@ | sed s/-recursive//`; /

list='$(SUBDIRS)'; for subdir in $$list; do /

  echo "Making $$target in $$subdir"; /

  if test "$$subdir" = "."; then /

    dot_seen=yes; /

    local_target="$$target-am"; /

  else /

    local_target="$$target"; /

  fi; /

  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) /

  || eval $$failcom; /

done; /

if test "$$dot_seen" = "no"; then /

  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; /

fi; test -z "$$fail"

在这段脚本中将分别进入各子目录并执行make xxx操作,xxx-recusive目标的前面一部分。

po子目录略过不做分析。当在opcodes目录下执行all-recursive操作时,上述脚本转而执行all-am目标,因此下面转而分析all-am目标。这条规则定义为:

all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) config.h

LIBRARIES = $(noinst_LIBRARIES)

noinst_LIBRARIES = libopcodes.a

LTLIBRARIES = $(bfdlib_LTLIBRARIES)

bfdlib_LTLIBRARIES = libopcodes.la

看看libopcodes.a的规则:

stamp-lib: libopcodes.la

       libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; /

       if [ -f $$libtooldir/libopcodes.a ]; then /

         cp $$libtooldir/libopcodes.a libopcodes.tmp; /

         $(RANLIB) libopcodes.tmp; /

         $(SHELL) $(srcdir)/../move-if-change libopcodes.tmp libopcodes.a; /

       else true; fi

       touch stamp-lib

 

libopcodes.a: stamp-lib ; @true

因而实际工作都由libopcodes.la完成,最后这段脚本将之复制为libopcodes.a

 

1.2    libopcodes.la

这条规则定义为:

libopcodes.la: $(libopcodes_la_OBJECTS) $(libopcodes_la_DEPENDENCIES)

       $(LINK) -rpath $(bfdlibdir) $(libopcodes_la_LDFLAGS) $(libopcodes_la_OBJECTS) $(libopcodes_la_LIBADD) $(LIBS)

在生成所有的.o文件后,这段脚本将它们链接为libopcodes.la文件。

1.2.1   $( libopcodes_la_OBJECTS)

这个变量定义为:

libopcodes_la_OBJECTS = $(am_libopcodes_la_OBJECTS)

am_libopcodes_la_OBJECTS = dis-buf.lo disassemble.lo dis-init.lo

1.2.1.1             dis-buf.lo

这个目标的生成由通用规则完成:

.c.lo:

       $(LTCOMPILE) -c -o $@ $<

然后有依赖关系:

dis-buf.lo: dis-buf.c sysdep.h config.h $(INCDIR)/ansidecl.h /

  $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /

  opintl.h

直接调用libtool脚本生成同名的.o.lo两个文件。

 

1.2.1.2             disassemble.lo

这条规则定义为:

disassemble.lo: disassemble.c $(INCDIR)/dis-asm.h

       $(LIBTOOL) --mode=compile $(COMPILE) -c  -DARCH_bfin $(srcdir)/disassemble.c

直接调用libtool脚本生成同名的.o.lo两个文件。

 

1.2.1.3             dis-init.lo

这个目标的生成由通用规则完成:

.c.lo:

       $(LTCOMPILE) -c -o $@ $<

然后有依赖关系:

dis-init.lo: dis-init.c sysdep.h config.h $(INCDIR)/ansidecl.h /

  $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /

  $(BFD_H)

直接调用libtool脚本生成同名的.o.lo两个文件。

 

1.2.2   $( libopcodes_la_DEPENDENCIES)

这个变量定义为:

libopcodes_la_DEPENDENCIES = $(OFILES)

OFILES =  bfin-dis.lo

 

1.2.2.1             bfin-dis.lo

这个目标的生成由通用规则完成:

.c.lo:

       $(LTCOMPILE) -c -o $@ $<

然后有依赖关系:

bfin-dis.lo: bfin-dis.c $(INCDIR)/opcode/bfin.h $(INCDIR)/dis-asm.h /

  $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h

直接调用libtool脚本生成同名的.o.lo两个文件。

 

 

2       目标生成顺序

以下是所有目标的生成顺序:

opcodes/Makefile: all: begin

opcodes/Makefile: all-recursive: begin

opcodes/Makefile: dis-buf.lo: begin

opcodes/Makefile: dis-buf.lo: end

opcodes/Makefile: disassemble.lo: begin

opcodes/Makefile: disassemble.lo: end

opcodes/Makefile: dis-init.lo: begin

opcodes/Makefile: dis-init.lo: end

opcodes/Makefile: bfin-dis.lo: begin

opcodes/Makefile: bfin-dis.lo: end

opcodes/Makefile: libopcodes.la: begin

opcodes/Makefile: libopcodes.la: end

opcodes/Makefile: stamp-lib: begin

opcodes/Makefile: stamp-lib: end

opcodes/Makefile: all-recursive: end

opcodes/Makefile: all: end

 

3       参考资料

binutils-2.18/libiberty/Makefile分析 2008-8-27

binutils-2.18/bfd/Makefile分析( 2008-8-28 )

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌云阁主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值