sandbox: Adjust how OS-interface files are built

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>
This commit is contained in:
Simon Glass
2025-06-10 19:16:52 -06:00
parent b833ab6b79
commit 3b8ed0cebb
3 changed files with 16 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0+ # 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 head-$(CONFIG_SANDBOX_SDL) += arch/sandbox/cpu/sdl.o
libs-y += arch/sandbox/cpu/ libs-y += arch/sandbox/cpu/
libs-y += arch/sandbox/lib/ libs-y += arch/sandbox/lib/

View File

@@ -5,29 +5,14 @@
# (C) Copyright 2000-2003 # (C) Copyright 2000-2003
# Wolfgang Denk, DENX Software Engineering, wd@denx.de. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
obj-y := cache.o cpu.o mem.o state.o obj-y := cache.o cpu.o mem.o state.o os.o
extra-y := start.o os.o extra-y := start.o
extra-$(CONFIG_SANDBOX_SDL) += sdl.o extra-$(CONFIG_SANDBOX_SDL) += sdl.o
obj-$(CONFIG_XPL_BUILD) += spl.o obj-$(CONFIG_XPL_BUILD) += spl.o
obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o obj-$(CONFIG_ETH_SANDBOX_RAW) += eth-raw-os.o
# os.c is build in the system environment, so needs standard includes # Compile these files with system headers
# CFLAGS_REMOVE_os.o cannot be used to drop header include path CFLAGS_USE_SYSHDRS := eth-raw-os.o os.o sdl.o
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)
# sdl.c fails to build with -fshort-wchar using musl # sdl.c fails to build with -fshort-wchar using musl
cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \ cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \

View File

@@ -162,15 +162,21 @@ __cpp_flags = $(call flags,_cpp_flags)
endif endif
endif endif
# Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE # Handle special sandbox files which need to be built with system headers
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ use_syshdrs = $(filter $(basetarget).o, $(CFLAGS_USE_SYSHDRS))
$(__c_flags) $(modkern_cflags) \ 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) $(basename_flags) $(modname_flags)
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ a_flags = -Wp,-MD,$(depfile) $(nostdinc) $(ubootinclude) \
$(__a_flags) $(modkern_aflags) $(__a_flags) $(modkern_aflags)
cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ cpp_flags = -Wp,-MD,$(depfile) $(nostdinc) $(ubootinclude) \
$(__cpp_flags) $(__cpp_flags)
ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))