kconfig / kbuild: Re-sync with Linux 4.19
[oweals/u-boot.git] / scripts / Makefile.lib
index ef116e0e0aeb8ae65f9619281bf4e82db06af8d4..8decb0e451d4c29c6f1ec8ca7ae4d08e0f675e08 100644 (file)
@@ -144,9 +144,10 @@ else
 # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
 #   and locates generated .h files
 # FIXME: Replace both with specific CFLAGS* statements in the makefiles
-__c_flags      = $(call addtree,-I$(obj)) $(call flags,_c_flags)
-__a_flags      =                          $(call flags,_a_flags)
-__cpp_flags     =                          $(call flags,_cpp_flags)
+__c_flags      = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
+                 $(call flags,_c_flags)
+__a_flags      = $(call flags,_a_flags)
+__cpp_flags     = $(call flags,_cpp_flags)
 endif
 
 # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE
@@ -160,7 +161,7 @@ a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
                 $(__cpp_flags)
 
-ld_flags       = $(LDFLAGS) $(ldflags-y)
+ld_flags       = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
 
 # Try these files in order to find the U-Boot-specific .dtsi include file
 u_boot_dtsi_options = $(strip $(wildcard $(dir $<)$(basename $(notdir $<))-u-boot.dtsi) \
@@ -255,8 +256,7 @@ $(obj)/%: $(src)/%_shipped
 # ---------------------------------------------------------------------------
 
 quiet_cmd_ld = LD      $@
-cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
-              $(filter-out FORCE,$^) -o $@
+cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@
 
 # Objcopy
 # ---------------------------------------------------------------------------
@@ -274,6 +274,30 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
 # DTC
 # ---------------------------------------------------------------------------
 
+# Disable noisy checks by default
+ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+DTC_FLAGS += -Wno-unit_address_vs_reg \
+       -Wno-unit_address_format \
+       -Wno-avoid_unnecessary_addr_size \
+       -Wno-alias_paths \
+       -Wno-graph_child_address \
+       -Wno-graph_port \
+       -Wno-unique_unit_address \
+       -Wno-simple_bus_reg \
+       -Wno-pci_device_reg
+
+# U-Boot specific disables
+DTC_FLAGS += -Wno-pci_bridge \
+        -Wno-pci_device_bus_num
+endif
+
+ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+DTC_FLAGS += -Wnode_name_chars_strict \
+       -Wproperty_name_chars_strict
+endif
+
+DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
+
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_dt_S_dtb= DTB     $@
 # Modified for U-Boot
@@ -292,6 +316,10 @@ cmd_dt_S_dtb=                                              \
 $(obj)/%.dtb.S: $(obj)/%.dtb
        $(call cmd,dt_S_dtb)
 
+ifeq ($(CONFIG_SPL_LOAD_FIT_APPLY_OVERLAY),y)
+DTC_FLAGS += -@
+endif
+
 quiet_cmd_dtc = DTC     $@
 # Modified for U-Boot
 # Bring in any U-Boot-specific include at the end of the file
@@ -300,7 +328,9 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
        $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $(pre-tmp) ; \
        $(DTC) -O dtb -o $@ -b 0 \
                -i $(dir $<) $(DTC_FLAGS) \
-               -d $(depfile).dtc.tmp $(dtc-tmp) ; \
+               -d $(depfile).dtc.tmp $(dtc-tmp) || \
+               (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \
+               ; \
        cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) ; \
        sed -i "s:$(pre-tmp):$(<):" $(depfile)
 
@@ -538,3 +568,11 @@ quiet_cmd_fdtgrep = FDTGREP $@
        $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
                -P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl \
                $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
+
+# fdt_rm_props
+# ---------------------------------------------------------------------------
+# Pass the original device tree file through fdtgrep. This removes various
+# unused properties. The output is typically a smaller device tree file.
+quiet_cmd_fdt_rm_props = FDTGREP $@
+       cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
+                       $(addprefix -P ,$(subst $\",,$(CONFIG_OF_REMOVE_PROPS)))