
From: Simon Glass <sjg@chromium.org> The current mechanism uses a completely separate build rule for each file which must be built with system headers. Before adding any more files, adjust the scheme so that the flags are handled in the common Makefile, with sandbox simply listing the files affected. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) arch/sandbox/Makefile | 2 +- arch/sandbox/cpu/Makefile | 23 ++++------------------- scripts/Makefile.lib | 16 +++++++++++----- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index a335f8acfde..5bbf9f1f96b 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ -head-y := arch/sandbox/cpu/start.o arch/sandbox/cpu/os.o +head-y := arch/sandbox/cpu/start.o head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o libs-y += arch/sandbox/cpu/ libs-y += arch/sandbox/lib/ diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index aac65e48675..03cdf2ae0f1 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -5,29 +5,14 @@ # (C) Copyright 2000-2003 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. -obj-y := cache.o cpu.o mem.o state.o -extra-y := start.o os.o +obj-y := cache.o cpu.o mem.o state.o os.o +extra-y := start.o extra-$(CONFIG_SANDBOX_SDL) += sdl.o obj-$(CONFIG_XPL_BUILD) += spl.o obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o -# os.c is build in the system environment, so needs standard includes -# CFLAGS_REMOVE_os.o cannot be used to drop header include path -quiet_cmd_cc_os.o = CC $(quiet_modtag) $@ -cmd_cc_os.o = $(CC) $(filter-out -nostdinc, \ - $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $< - -$(obj)/os.o: $(src)/os.c FORCE - $(call if_changed_dep,cc_os.o) - -# eth-raw-os.c is built in the system env, so needs standard includes -# CFLAGS_REMOVE_eth-raw-os.o cannot be used to drop header include path -quiet_cmd_cc_eth-raw-os.o = CC $(quiet_modtag) $@ -cmd_cc_eth-raw-os.o = $(CC) $(filter-out -nostdinc, \ - $(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $< - -$(obj)/eth-raw-os.o: $(src)/eth-raw-os.c FORCE - $(call if_changed_dep,cc_eth-raw-os.o) +# Compile these files with system headers +CFLAGS_USE_SYSHDRS := eth-raw-os.o os.o sdl.o # sdl.c fails to build with -fshort-wchar using musl cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 4102e662c5f..6d6a21f262a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -162,15 +162,21 @@ __cpp_flags = $(call flags,_cpp_flags) endif endif -# Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE -c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ - $(__c_flags) $(modkern_cflags) \ +# Handle special sandbox files which need to be built with system headers +use_syshdrs = $(filter $(basetarget).o, $(CFLAGS_USE_SYSHDRS)) +nostdinc = $(if $(use_syshdrs),,$(NOSTDINC_FLAGS)) +ubootinclude = $(if $(use_syshdrs),$(patsubst -I%,-idirafter%,\ + $(UBOOTINCLUDE)),$(UBOOTINCLUDE)) + +# Modified for U-Boot: NOSTDINC_FLAGS -> nostdinc and LINUXINCLUDE -> ubootinclude +c_flags = -Wp,-MD,$(depfile) $(nostdinc) $(ubootinclude) \ + $(__c_flags) $(modkern_cflags) \ $(basename_flags) $(modname_flags) -a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ +a_flags = -Wp,-MD,$(depfile) $(nostdinc) $(ubootinclude) \ $(__a_flags) $(modkern_aflags) -cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ +cpp_flags = -Wp,-MD,$(depfile) $(nostdinc) $(ubootinclude) \ $(__cpp_flags) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) -- 2.43.0