Implement "make path/to/file.c.gcov", also introduce a new env variable "GCOV_OBJ_DIR" which should point to the objects directory of gcov. (defaults to /sys/kernel/debug/gcov/path/to/compile) Signed-off-by: WANG Cong <amwang@xxxxxxxxxx> --- Index: linux-2.6/scripts/Makefile.build =================================================================== --- linux-2.6.orig/scripts/Makefile.build +++ linux-2.6/scripts/Makefile.build @@ -169,6 +169,13 @@ cmd_cc_symtypes_c = $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +ifdef CONFIG_GCOV_KERNEL +cmd_gcov_gcov_c = $(srctree)/scripts/gen_gcov.sh $(GCOV_OBJ_DIR) $< + +$(obj)/%.c.gcov: $(src)/%.c FORCE + $(call cmd,gcov_gcov_c) +endif + # C (.c) files # The C file is compiled and updated dependency information is generated. # (See cmd_cc_o_c + relevant part of rule_cc_o_c) Index: linux-2.6/Makefile =================================================================== --- linux-2.6.orig/Makefile +++ linux-2.6/Makefile @@ -313,6 +313,7 @@ NM = $(CROSS_COMPILE)nm STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump +GCOV = $(CROSS_COMPILE)gcov AWK = awk GENKSYMS = scripts/genksyms/genksyms DEPMOD = /sbin/depmod @@ -353,7 +354,7 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC -export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE +export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE GCOV export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS @@ -1517,6 +1518,8 @@ endif $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.o: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.c.gcov: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.lst: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.s: %.S prepare scripts FORCE -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html