mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
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. This is tricky to maintain. Add a foreach template in the sandbox cpu Makefile which generates the custom compile rules from a CFLAGS_USE_SYSHDRS list. This keeps the rules data-driven without needing changes to the common scripts/Makefile.lib, which could affect other architectures. Move initjmp.o into the template since it uses the same pattern. Add sdl.o to the list too, with an override for its command since it also needs -fshort-wchar removed and -fno-lto added. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -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/
|
||||
|
||||
@@ -5,42 +5,29 @@
|
||||
# (C) Copyright 2000-2003
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
|
||||
obj-y := cache.o cpu.o state.o initjmp.o
|
||||
extra-y := start.o os.o
|
||||
obj-y := cache.o cpu.o state.o initjmp.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 $@ $<
|
||||
# These files need to be built with system headers, since they use system
|
||||
# calls or system-level interfaces. Generate a custom compile rule for each
|
||||
# one that drops -nostdinc and converts -I to -idirafter.
|
||||
CFLAGS_USE_SYSHDRS := eth-raw-os.o initjmp.o os.o sdl.o
|
||||
|
||||
$(obj)/os.o: $(src)/os.c FORCE
|
||||
$(call if_changed_dep,cc_os.o)
|
||||
define syshdrs_rule
|
||||
quiet_cmd_cc_$(1) = CC $$(quiet_modtag) $$@
|
||||
cmd_cc_$(1) = $$(CC) $$(filter-out -nostdinc, \
|
||||
$$(patsubst -I%,-idirafter%,$$(c_flags))) -c -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)/$(1): $$(src)/$(1:.o=.c) FORCE
|
||||
$$(call if_changed_dep,cc_$(1))
|
||||
endef
|
||||
|
||||
$(obj)/eth-raw-os.o: $(src)/eth-raw-os.c FORCE
|
||||
$(call if_changed_dep,cc_eth-raw-os.o)
|
||||
$(foreach f,$(CFLAGS_USE_SYSHDRS),$(eval $(call syshdrs_rule,$(f))))
|
||||
|
||||
# initjmp.c is build in the system environment, so needs standard includes
|
||||
# CFLAGS_REMOVE_initjmp.o cannot be used to drop header include path
|
||||
quiet_cmd_cc_initjmp.o = CC $(quiet_modtag) $@
|
||||
cmd_cc_initjmp.o = $(CC) $(filter-out -nostdinc, \
|
||||
$(patsubst -I%,-idirafter%,$(c_flags))) -c -o $@ $<
|
||||
|
||||
$(obj)/initjmp.o: $(src)/initjmp.c FORCE
|
||||
$(call if_changed_dep,cc_initjmp.o)
|
||||
|
||||
# sdl.c fails to build with -fshort-wchar using musl
|
||||
# sdl.c also needs -fshort-wchar removed (musl) and -fno-lto, so override
|
||||
# the generated rule
|
||||
cmd_cc_sdl.o = $(CC) $(filter-out -nostdinc -fshort-wchar, \
|
||||
$(patsubst -I%,-idirafter%,$(c_flags))) -fno-lto -c -o $@ $<
|
||||
|
||||
$(obj)/sdl.o: $(src)/sdl.c FORCE
|
||||
$(call if_changed_dep,cc_sdl.o)
|
||||
|
||||
Reference in New Issue
Block a user