zephyr/Makefile: Automatically derive target-specific CFLAGS.
By tricking Zephyt arch Makefiles compute them for us (not just for Zephyr). This make potentially break as Zephyr evolves.
This commit is contained in:
parent
cbc0bf6fec
commit
244b02f744
@ -15,20 +15,18 @@ BOARD ?= qemu_x86
|
||||
# Zephyr 1.6.0
|
||||
OUTDIR_PREFIX = $(BOARD)
|
||||
|
||||
# Zephyr (generated) config files - must be defined before include below
|
||||
Z_DOTCONFIG = outdir/$(OUTDIR_PREFIX)/.config
|
||||
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
|
||||
DQUOTE = "
|
||||
# "
|
||||
include $(Z_DOTCONFIG)
|
||||
override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
|
||||
include z_config_proxy.mk
|
||||
|
||||
# Zephyr toolchain config is 2-pass, so included twice
|
||||
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
||||
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
||||
|
||||
CFLAGS_arm = -mthumb -mcpu=cortex-m3 -mabi=aapcs
|
||||
CFLAGS_x86 = -fno-asynchronous-unwind-tables -ffreestanding -fno-stack-protector \
|
||||
-fno-omit-frame-pointer -mpreferred-stack-boundary=2 -mno-sse -march=pentium
|
||||
CFLAGS_TARGET = $(CFLAGS_$(ARCH))
|
||||
CFLAGS_TARGET = $(cflags-y)
|
||||
|
||||
include ../py/mkenv.mk
|
||||
include ../py/py.mk
|
||||
@ -64,8 +62,6 @@ KCONFIG_TARGETS = config nconfig menuconfig xconfig gconfig
|
||||
$(GENERIC_TARGETS) $(KCONFIG_TARGETS): $(LIBMICROPYTHON)
|
||||
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) $@
|
||||
|
||||
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
|
||||
|
||||
$(LIBMICROPYTHON): $(Z_AUTOCONF_H)
|
||||
build/genhdr/qstr.i.last: $(Z_AUTOCONF_H)
|
||||
|
||||
@ -73,5 +69,12 @@ $(Z_AUTOCONF_H):
|
||||
rm -f $(LIBMICROPYTHON)
|
||||
-$(MAKE) -f Makefile.zephyr BOARD=$(BOARD)
|
||||
|
||||
zephyr_arch.mk: $(Z_DOTCONFIG)
|
||||
echo "include $(ZEPHYR_BASE)/arch/$(ARCH)/Makefile" >$@
|
||||
|
||||
z_config_proxy.mk:
|
||||
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) initconfig
|
||||
echo "include z_config.mk" >$@
|
||||
|
||||
# Clean Zephyr things too
|
||||
CLEAN_EXTRA = outdir
|
||||
CLEAN_EXTRA = outdir z_config_proxy.mk
|
||||
|
17
zephyr/z_config.mk
Normal file
17
zephyr/z_config.mk
Normal file
@ -0,0 +1,17 @@
|
||||
srctree = $(ZEPHYR_BASE)
|
||||
|
||||
include $(Z_DOTCONFIG)
|
||||
override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
|
||||
SOC_NAME = $(subst $(DQUOTE),,$(CONFIG_SOC))
|
||||
SOC_SERIES = $(subst $(DQUOTE),,$(CONFIG_SOC_SERIES))
|
||||
SOC_FAMILY = $(subst $(DQUOTE),,$(CONFIG_SOC_FAMILY))
|
||||
ifeq ($(SOC_SERIES),)
|
||||
SOC_PATH = $(SOC_NAME)
|
||||
else
|
||||
SOC_PATH = $(SOC_FAMILY)/$(SOC_SERIES)
|
||||
endif
|
||||
|
||||
KBUILD_CFLAGS := -c
|
||||
include $(ZEPHYR_BASE)/scripts/Kbuild.include
|
||||
|
||||
include $(ZEPHYR_BASE)/arch/$(ARCH)/Makefile
|
Loading…
Reference in New Issue
Block a user