diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-06-16 14:58:42 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-06-21 03:32:18 -0400 |
commit | 15571cfa8c55c1f011b8f3e9947a4d8fa97de9dd (patch) | |
tree | 2d968c0bc669181196e9aaa92628f1eb866b8de1 | |
parent | 70d0d5241d6b56da062ca22ff72d666ad3254870 (diff) |
kbuild: Allow gcov to be enabled on the command line
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | scripts/Kbuild.include | 10 | ||||
-rw-r--r-- | scripts/Makefile.lib | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7778cc97a4e0..5341736f2e30 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -277,3 +277,13 @@ ifneq ($(and $(filter notintermediate, $(.FEATURES)),$(filter-out 4.4,$(MAKE_VER else .SECONDARY: endif + + # expand_parents(a/b/c) = a/b/c a/b a +expand_parents2 = $(if $(subst .,,$(1)),$(call expand_parents,$(1)),) +expand_parents = $(1) $(call expand_parents2,$(patsubst %/,%,$(dir $(1)))) + +# flatten_dirs(a/b/c) = a_b_c a_b a +flatten_dirs = $(subst /,_,$(call expand_parents,$(1))) + +# eval_vars(X_,a/b/c) = $(X_a_b_c) $(X_a_b) $(X_a) +eval_vars = $(foreach var,$(call flatten_dirs,$(2)),$($(1)$(var))) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 100a386fcd71..1f106c71e5fe 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -148,7 +148,7 @@ _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) # ifeq ($(CONFIG_GCOV_KERNEL),y) _c_flags += $(if $(patsubst n%,, \ - $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \ + $(GCOV_PROFILE_$(basetarget).o)$(call eval_vars,GCOV_PROFILE_,$(src))$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \ $(CFLAGS_GCOV)) endif |