快乐虾
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 gas/Makefile
这个文件由主控Makefile调用configure脚本生成并执行make操作。要求生成的目标为all。
1.1 all
在Makefile中的第一个目标就是all:
$(MAKE) $(AM_MAKEFLAGS) all-recursive
all diststuff: info
info这个目标只负责文档的生成,在此略过它,只分析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目标的前面一部分。
doc 和po两个子目录略过不做分析。当在bfd目录下执行all-recursive操作时,上述脚本转而执行all-am目标,因此下面转而分析all-am目标。这条规则定义为:
all-am: Makefile $(PROGRAMS) $(SCRIPTS) config.h
PROGRAMS = $(noinst_PROGRAMS)
noinst_PROGRAMS = as-new$(EXEEXT)
SCRIPTS = $(noinst_SCRIPTS)
noinst_SCRIPTS = $(GDBINIT)
GDBINIT = .gdbinit
因此这个目标实际依赖于as-new$(EXEEXT),它的规则定义为:
as-new$(EXEEXT): $(as_new_OBJECTS) $(as_new_DEPENDENCIES)
@rm -f as-new$(EXEEXT)
$(LINK) $(as_new_LDFLAGS) $(as_new_OBJECTS) $(as_new_LDADD) $(LIBS)
在生成所有的.o文件后,这段脚本将之链接为as-new.exe。
1.1.1 $(as_new_OBJECTS)
这个变量定义为:
as_new_OBJECTS = $(am_as_new_OBJECTS)
am_as_new_OBJECTS = $(am__objects_1)
am__objects_1 = app.$(OBJEXT) as.$(OBJEXT) atof-generic.$(OBJEXT) /
cond.$(OBJEXT) depend.$(OBJEXT) dwarf2dbg.$(OBJEXT) /
dw2gencfi.$(OBJEXT) ecoff.$(OBJEXT) ehopt.$(OBJEXT) /
expr.$(OBJEXT) flonum-copy.$(OBJEXT) flonum-konst.$(OBJEXT) /
flonum-mult.$(OBJEXT) frags.$(OBJEXT) hash.$(OBJEXT) /
input-file.$(OBJEXT) input-scrub.$(OBJEXT) listing.$(OBJEXT) /
literal.$(OBJEXT) macro.$(OBJEXT) messages.$(OBJEXT) /
output-file.$(OBJEXT) read.$(OBJEXT) remap.$(OBJEXT) /
sb.$(OBJEXT) stabs.$(OBJEXT) subsegs.$(OBJEXT) /
symbols.$(OBJEXT) write.$(OBJEXT)
这些目标的生成全部由通用规则完成:
.c.o:
$(COMPILE) -c $<
同时有以下依赖关系:
app.o: app.c
as.o: as.c subsegs.h $(INCDIR)/obstack.h output-file.h /
sb.h macro.h dwarf2dbg.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h /
../bfd/bfdver.h
atof-generic.o: atof-generic.c $(INCDIR)/safe-ctype.h
cond.o: cond.c sb.h macro.h $(INCDIR)/obstack.h
depend.o: depend.c
dwarf2dbg.o: dwarf2dbg.c $(INCDIR)/safe-ctype.h dwarf2dbg.h /
$(INCDIR)/filenames.h subsegs.h $(INCDIR)/obstack.h /
$(INCDIR)/elf/dwarf2.h
dw2gencfi.o: dw2gencfi.c dw2gencfi.h $(INCDIR)/elf/dwarf2.h /
subsegs.h $(INCDIR)/obstack.h
ecoff.o: ecoff.c ecoff.h
ehopt.o: ehopt.c subsegs.h $(INCDIR)/obstack.h $(INCDIR)/elf/dwarf2.h
expr.o: expr.c $(INCDIR)/safe-ctype.h $(INCDIR)/obstack.h
flonum-copy.o: flonum-copy.c
flonum-konst.o: flonum-konst.c
flonum-mult.o: flonum-mult.c
frags.o: frags.c subsegs.h $(INCDIR)/obstack.h
hash.o: hash.c $(INCDIR)/safe-ctype.h $(INCDIR)/obstack.h
input-file.o: input-file.c input-file.h $(INCDIR)/safe-ctype.h
input-scrub.o: input-scrub.c input-file.h sb.h
listing.o: listing.c $(INCDIR)/obstack.h $(INCDIR)/safe-ctype.h /
input-file.h subsegs.h
literal.o: literal.c subsegs.h $(INCDIR)/obstack.h
macro.o: macro.c $(INCDIR)/safe-ctype.h sb.h macro.h
messages.o: messages.c
output-file.o: output-file.c output-file.h
read.o: read.c $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h /
sb.h macro.h ecoff.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h
remap.o: remap.c
sb.o: sb.c sb.h
stabs.o: stabs.c $(INCDIR)/obstack.h subsegs.h ecoff.h /
$(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def
subsegs.o: subsegs.c subsegs.h $(INCDIR)/obstack.h
symbols.o: symbols.c $(INCDIR)/safe-ctype.h $(INCDIR)/obstack.h /
subsegs.h struc-symbol.h
write.o: write.c subsegs.h $(INCDIR)/obstack.h output-file.h /
dwarf2dbg.h $(BFDDIR)/libbfd.h $(INCDIR)/hashtab.h
都是直接编译即可。
1.1.2 $(as_new_DEPENDENCIES)
这个变量定义为:
as_new_DEPENDENCIES = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) /
$(extra_objects) $(GASLIBS) $(LIBINTL_DEP)
1.1.2.1 $(TARG_CPU_O)
这个变量定义为:
TARG_CPU_O = tc-bfin.o
这条规则定义为:
$(TARG_CPU_O): $(TARG_CPU_C)
$(COMPILE) -c $(TARG_CPU_C)
TARG_CPU_C = $(srcdir)/config/tc-bfin.c
直接编译即可。
1.1.2.2 $(OBJ_FORMAT_O)
这个变量定义为:
OBJ_FORMAT_O = obj-elf.o
这条规则定义为:
obj-elf.o : $(srcdir)/config/obj-elf.c $(DEP_bfin_elf)
$(COMPILE) -c $(srcdir)/config/obj-elf.c
直接编译即可。
1.1.2.3 $(ATOF_TARG_O)
这个变量定义为:
ATOF_TARG_O = atof-ieee.o
这条规则定义为:
$(ATOF_TARG_O): $(ATOF_TARG_C)
$(COMPILE) -c $(ATOF_TARG_C)
直接编译即可。
1.1.2.4 $(extra_objects)
这个变量定义为:
extra_objects = bfin-parse.o bfin-lex.o
1.1.2.4.1 bfin-parse.o
这个目标由通用规则生成:
.c.o:
$(COMPILE) -c $<
同时有以下依赖关系:
bfin-parse.o: bfin-parse.c bfin-parse.h $(srcdir)/config/bfin-defs.h /
$(INCDIR)/elf/common.h $(INCDIR)/elf/bfin.h $(BFDDIR)/libbfd.h
直接编译即可。
1.1.2.4.2 bfin-lex.o
这条规则定义为:
bfin-lex.o: bfin-lex.c bfin-parse.h $(srcdir)/config/bfin-defs.h
$(COMPILE) -c $< $(NO_WERROR)
直接编译即可。
1.1.2.5 $(GASLIBS)
这个变量定义为:
GASLIBS = ../opcodes/libopcodes.la ../bfd/libbfd.la ../libiberty/libiberty.a
目标均已经生成,略过。
1.1.2.6 $(LIBINTL_DEP)
这个变量定义为:
LIBINTL_DEP =
略过。
2 目标生成顺序
以下是所有目标的生成顺序:
gas/Makefile: info-recursive: begin
gas/Makefile: info-recursive: end
gas/Makefile: all: begin
gas/Makefile: all-recursive: begin
gas/Makefile: app.o: begin
gas/Makefile: app.o: end
gas/Makefile: as.o: begin
gas/Makefile: as.o: end
gas/Makefile: atof-generic.o: begin
gas/Makefile: atof-generic.o: end
gas/Makefile: cond.o: begin
gas/Makefile: cond.o: end
gas/Makefile: depend.o: begin
gas/Makefile: depend.o: end
gas/Makefile: dwarf2dbg.o: begin
gas/Makefile: dwarf2dbg.o: end
gas/Makefile: dw2gencfi.o: begin
gas/Makefile: dw2gencfi.o: end
gas/Makefile: ecoff.o: begin
gas/Makefile: ecoff.o: end
gas/Makefile: ehopt.o: begin
gas/Makefile: ehopt.o: end
gas/Makefile: expr.o: begin
gas/Makefile: expr.o: end
gas/Makefile: flonum-copy.o: begin
gas/Makefile: flonum-copy.o: end
gas/Makefile: flonum-konst.o: begin
gas/Makefile: flonum-konst.o: end
gas/Makefile: flonum-mult.o: begin
gas/Makefile: flonum-mult.o: end
gas/Makefile: frags.o: begin
gas/Makefile: frags.o: end
gas/Makefile: hash.o: begin
gas/Makefile: hash.o: end
gas/Makefile: input-file.o: begin
gas/Makefile: input-file.o: end
gas/Makefile: input-scrub.o: begin
gas/Makefile: input-scrub.o: end
gas/Makefile: listing.o: begin
gas/Makefile: listing.o: end
gas/Makefile: literal.o: begin
gas/Makefile: literal.o: end
gas/Makefile: macro.o: begin
gas/Makefile: macro.o: end
gas/Makefile: messages.o: begin
gas/Makefile: messages.o: end
gas/Makefile: output-file.o: begin
gas/Makefile: output-file.o: end
gas/Makefile: read.o: begin
gas/Makefile: read.o: end
gas/Makefile: remap.o: begin
gas/Makefile: remap.o: end
gas/Makefile: sb.o: begin
gas/Makefile: sb.o: end
gas/Makefile: stabs.o: begin
gas/Makefile: stabs.o: end
gas/Makefile: subsegs.o: begin
gas/Makefile: subsegs.o: end
gas/Makefile: symbols.o: begin
gas/Makefile: symbols.o: end
gas/Makefile: write.o: begin
gas/Makefile: write.o: end
gas/Makefile: tc-bfin.o: begin
gas/Makefile: tc-bfin.o: end
gas/Makefile: obj-elf.o: begin
gas/Makefile: obj-elf.o: end
gas/Makefile: atof-ieee.o: begin
gas/Makefile: atof-ieee.o: end
gas/Makefile: bfin-parse.o: begin
gas/Makefile: bfin-parse.o: end
gas/Makefile: bfin-lex.o: begin
gas/Makefile: bfin-lex.o: end
gas/Makefile: as-new.exe: begin
gas/Makefile: as-new.exe: end
gas/Makefile: all-recursive: end
gas/Makefile: all: end
3 参考资料
binutils-2.18/libiberty/Makefile分析( 2008-8-27 )
binutils-2.18/bfd/Makefile分析( 2008-8-28 )