Commit 2ec8107d8e0d1d285b2bbf1999e7f4e46b6b535b

Authored by Jiri Olsa
Committed by Arnaldo Carvalho de Melo
1 parent 699c12a7cc

tools build: Add CFLAGS_REMOVE_* support

Adding support to remove options from final CFLAGS for both object file
and build target. It's now possible to remove CFLAGS options like:

  CFLAGS_REMOVE_krava.o += -Wstrict-prototypes

Committer notes:

This comes from the kernel's kbuild infrastructure, the subset that is
supported in tools/ is being documented at tools/build/Documentation/Build.txt.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/1478093749-5602-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 2 changed files with 7 additions and 3 deletions Side-by-side Diff

tools/build/Build.include
... ... @@ -89,7 +89,9 @@
89 89 # - per target C flags
90 90 # - per object C flags
91 91 # - BUILD_STR macro to allow '-D"$(variable)"' constructs
92   -c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
  92 +c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
  93 +c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
  94 +c_flags = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
93 95 cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
94 96  
95 97 ###
tools/build/Documentation/Build.txt
... ... @@ -135,8 +135,10 @@
135 135  
136 136 It's possible to alter the standard object C flags in the following way:
137 137  
138   - CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
139   - CFLAGS_gtk += '...' - alters CFLAGS for gtk build object
  138 + CFLAGS_perf.o += '...' - adds CFLAGS for perf.o object
  139 + CFLAGS_gtk += '...' - adds CFLAGS for gtk build object
  140 + CFLAGS_REMOVE_perf.o += '...' - removes CFLAGS for perf.o object
  141 + CFLAGS_REMOVE_gtk += '...' - removes CFLAGS for gtk build object
140 142  
141 143 This C flags changes has the scope of the Build makefile they are defined in.
142 144