快乐虾
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 gprof/Makefile
这个文件由主控Makefile调用configure脚本生成并执行make操作。要求生成的目标为all。
1.1 all
在Makefile中的第一个目标就是all:
all: $(BUILT_SOURCES) gconfig.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
BUILD_SOURCES定义了一些源文件。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子目录略过不做分析。当在gprof目录下执行all-recursive操作时,上述脚本转而执行all-am目标,因此下面转而分析all-am目标。这条规则定义为:
all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS) gconfig.h
PROGRAMS = $(bin_PROGRAMS)
bin_PROGRAMS = gprof$(EXEEXT)
MANS = $(man_MANS)
man_MANS = gprof.1
HEADERS = $(noinst_HEADERS)
noinst_HEADERS = /
basic_blocks.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h /
corefile.h gmon.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h /
search_list.h source.h sym_ids.h symtab.h utils.h
因此这个目标实际依赖于gprof$(EXEEXT),它的规则定义为:
gprof$(EXEEXT): $(gprof_OBJECTS) $(gprof_DEPENDENCIES)
@rm -f gprof$(EXEEXT)
$(LINK) $(gprof_LDFLAGS) $(gprof_OBJECTS) $(gprof_LDADD) $(LIBS)
在生成所有的.o文件后,这段脚本将之链接为gprof.exe。
1.1.1 $(gprof_OBJECTS)
这个变量定义为:
gprof_OBJECTS = $(am_gprof_OBJECTS)
am_gprof_OBJECTS = $(am__objects_1) flat_bl.$(OBJEXT) /
bsd_callg_bl.$(OBJEXT) fsf_callg_bl.$(OBJEXT)
am__objects_1 = basic_blocks.$(OBJEXT) call_graph.$(OBJEXT) /
cg_arcs.$(OBJEXT) cg_dfn.$(OBJEXT) cg_print.$(OBJEXT) /
corefile.$(OBJEXT) gmon_io.$(OBJEXT) gprof.$(OBJEXT) /
hertz.$(OBJEXT) hist.$(OBJEXT) source.$(OBJEXT) /
search_list.$(OBJEXT) symtab.$(OBJEXT) sym_ids.$(OBJEXT) /
utils.$(OBJEXT) i386.$(OBJEXT) alpha.$(OBJEXT) vax.$(OBJEXT) /
tahoe.$(OBJEXT) sparc.$(OBJEXT) mips.$(OBJEXT)
这些目标的生成全部由通用规则完成:
.c.o:
$(COMPILE) -c $<
同时有以下依赖关系:
basic_blocks.o: basic_blocks.c $(INCDIR)/libiberty.h /
$(INCDIR)/ansidecl.h gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h basic_blocks.h corefile.h gmon_io.h gmon_out.h /
search_list.h source.h symtab.h sym_ids.h
call_graph.o: call_graph.c gprof.h $(BFDDIR)/sysdep.h /
../bfd/config.h $(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h /
$(INCDIR)/filenames.h ../bfd/bfd.h $(INCDIR)/ansidecl.h /
$(INCDIR)/symcat.h gconfig.h search_list.h source.h /
symtab.h cg_arcs.h call_graph.h corefile.h gmon_io.h /
gmon_out.h sym_ids.h
cg_arcs.o: cg_arcs.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h search_list.h /
source.h symtab.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h /
utils.h sym_ids.h
cg_dfn.o: cg_dfn.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h search_list.h /
source.h symtab.h cg_arcs.h cg_dfn.h utils.h
cg_print.o: cg_print.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h search_list.h /
source.h symtab.h cg_arcs.h cg_print.h hist.h utils.h /
corefile.h
corefile.o: corefile.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h search_list.h /
source.h symtab.h hist.h corefile.h $(INCDIR)/safe-ctype.h
gmon_io.o: gmon_io.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
basic_blocks.h corefile.h call_graph.h gmon_io.h gmon_out.h /
gmon.h hertz.h hist.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h
gprof.o: gprof.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h ../bfd/bfdver.h /
search_list.h source.h symtab.h basic_blocks.h call_graph.h /
cg_arcs.h cg_print.h corefile.h gmon_io.h hertz.h hist.h /
sym_ids.h $(INCDIR)/demangle.h $(INCDIR)/libiberty.h
hertz.o: hertz.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h hertz.h
hist.o: hist.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h $(INCDIR)/ansidecl.h /
$(INCDIR)/fopen-same.h $(INCDIR)/filenames.h ../bfd/bfd.h /
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h gconfig.h search_list.h /
source.h symtab.h corefile.h gmon_io.h gmon_out.h hist.h /
sym_ids.h utils.h
source.o: source.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
$(INCDIR)/filenames.h search_list.h source.h
search_list.o: search_list.c $(INCDIR)/libiberty.h /
$(INCDIR)/ansidecl.h gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h
symtab.o: symtab.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h
sym_ids.o: sym_ids.c $(INCDIR)/libiberty.h $(INCDIR)/ansidecl.h /
$(INCDIR)/safe-ctype.h gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
sym_ids.h corefile.h
utils.o: utils.c $(INCDIR)/demangle.h $(INCDIR)/libiberty.h /
$(INCDIR)/ansidecl.h gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
utils.h corefile.h
i386.o: i386.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
alpha.o: alpha.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
vax.o: vax.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
tahoe.o: tahoe.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
sparc.o: sparc.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
mips.o: mips.c gprof.h $(BFDDIR)/sysdep.h ../bfd/config.h /
$(INCDIR)/ansidecl.h $(INCDIR)/fopen-same.h $(INCDIR)/filenames.h /
../bfd/bfd.h $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h /
gconfig.h search_list.h source.h symtab.h cg_arcs.h /
corefile.h hist.h
flat_bl.o: flat_bl.c $(INCDIR)/ansidecl.h
bsd_callg_bl.o: bsd_callg_bl.c $(INCDIR)/ansidecl.h
fsf_callg_bl.o: fsf_callg_bl.c $(INCDIR)/ansidecl.h
都是直接编译即可。
1.1.2 $(gprof_DEPENDENCIES)
这个变量定义为:
gprof_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL_DEP)
这几个目标都已经生成,略过。
2 目标生成顺序
以下是所有目标的生成顺序:
gprof/Makefile: all: begin
gprof/Makefile: all-recursive: begin
gprof/Makefile: basic_blocks.o: begin
gprof/Makefile: basic_blocks.o: end
gprof/Makefile: call_graph.o: begin
gprof/Makefile: call_graph.o: end
gprof/Makefile: cg_arcs.o: begin
gprof/Makefile: cg_arcs.o: end
gprof/Makefile: cg_dfn.o: begin
gprof/Makefile: cg_dfn.o: end
gprof/Makefile: cg_print.o: begin
gprof/Makefile: cg_print.o: end
gprof/Makefile: corefile.o: begin
gprof/Makefile: corefile.o: end
gprof/Makefile: gmon_io.o: begin
gprof/Makefile: gmon_io.o: end
gprof/Makefile: gprof.o: begin
gprof/Makefile: gprof.o: end
gprof/Makefile: hertz.o: begin
gprof/Makefile: hertz.o: end
gprof/Makefile: hist.o: begin
gprof/Makefile: hist.o: end
gprof/Makefile: source.o: begin
gprof/Makefile: source.o: end
gprof/Makefile: search_list.o: begin
gprof/Makefile: search_list.o: end
gprof/Makefile: symtab.o: begin
gprof/Makefile: symtab.o: end
gprof/Makefile: sym_ids.o: begin
gprof/Makefile: sym_ids.o: end
gprof/Makefile: utils.o: begin
gprof/Makefile: utils.o: end
gprof/Makefile: i386.o: begin
gprof/Makefile: i386.o: end
gprof/Makefile: alpha.o: begin
gprof/Makefile: alpha.o: end
gprof/Makefile: vax.o: begin
gprof/Makefile: vax.o: end
gprof/Makefile: tahoe.o: begin
gprof/Makefile: tahoe.o: end
gprof/Makefile: sparc.o: begin
gprof/Makefile: sparc.o: end
gprof/Makefile: mips.o: begin
gprof/Makefile: mips.o: end
gprof/Makefile: flat_bl.o: begin
gprof/Makefile: flat_bl.o: end
gprof/Makefile: bsd_callg_bl.o: begin
gprof/Makefile: bsd_callg_bl.o: end
gprof/Makefile: fsf_callg_bl.o: begin
gprof/Makefile: fsf_callg_bl.o: end
gprof/Makefile: gprof.exe: begin
gprof/Makefile: gprof.exe: end
gprof/Makefile: all-recursive: end
gprof/Makefile: all: end
3 参考资料
binutils-2.18/libiberty/Makefile分析( 2008-8-27 )
binutils-2.18/bfd/Makefile分析( 2008-8-28 )