Commit d8672b40d3a6f17de5b5bc71d6e531d7576a856a

Authored by Sam Ravnborg
1 parent 5b91c33cf2

kbuild: expand -I in KBUILD_CPPFLAGS

kbuild failed to expand include flags in KBUILD_CPPFLAGS
resulting in code like this in arch Makefiles:

ifeq ($(KBUILD_SRC),)
KBUILD_CPPFLAGS += -Iinclude/foo
else
KBUILD_CPPFLAGS += -I$(srctree)/include/foo
endif

Move use of LINUXINCLUDE into Makefile.lib to allow
us to expand -I directives of KBUILD_CPPFLAGS so
we can avoid the above code.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 2 changed files with 11 additions and 8 deletions Side-by-side Diff

... ... @@ -336,7 +336,7 @@
336 336 -I$(srctree)/arch/$(hdr-arch)/include \
337 337 -include include/linux/autoconf.h
338 338  
339   -KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
  339 +KBUILD_CPPFLAGS := -D__KERNEL__
340 340  
341 341 KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
342 342 -fno-strict-aliasing -fno-common \
... ... @@ -1638,7 +1638,7 @@
1638 1638 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
1639 1639  
1640 1640 a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1641   - $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
  1641 + $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
1642 1642 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1643 1643  
1644 1644 quiet_cmd_as_o_S = AS $@
scripts/Makefile.lib
... ... @@ -104,9 +104,11 @@
104 104 debug_flags =
105 105 endif
106 106  
107   -orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
  107 +orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \
  108 + $(ccflags-y) $(CFLAGS_$(basetarget).o)
108 109 _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
109   -_a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
  110 +_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \
  111 + $(asflags-y) $(AFLAGS_$(basetarget).o)
110 112 _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
111 113  
112 114 # If building the kernel in a separate objtree expand all occurrences
113 115  
114 116  
... ... @@ -127,15 +129,16 @@
127 129 __cpp_flags = $(call flags,_cpp_flags)
128 130 endif
129 131  
130   -c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
131   - $(__c_flags) $(modkern_cflags) \
  132 +c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
  133 + $(__c_flags) $(modkern_cflags) \
132 134 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
133 135 $(debug_flags)
134 136  
135   -a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
  137 +a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
136 138 $(__a_flags) $(modkern_aflags)
137 139  
138   -cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
  140 +cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
  141 + $(__cpp_flags)
139 142  
140 143 ld_flags = $(LDFLAGS) $(ldflags-y)
141 144