Browse Source

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.
pull/2500/head
Paul Sokolovsky 8 years ago
parent
commit
244b02f744
  1. 21
      zephyr/Makefile
  2. 17
      zephyr/z_config.mk

21
zephyr/Makefile

@ -15,20 +15,18 @@ BOARD ?= qemu_x86
# Zephyr 1.6.0 # Zephyr 1.6.0
OUTDIR_PREFIX = $(BOARD) OUTDIR_PREFIX = $(BOARD)
# Zephyr (generated) config files - must be defined before include below
Z_DOTCONFIG = outdir/$(OUTDIR_PREFIX)/.config Z_DOTCONFIG = outdir/$(OUTDIR_PREFIX)/.config
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
DQUOTE = " DQUOTE = "
# " # "
include $(Z_DOTCONFIG) include z_config_proxy.mk
override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
# Zephyr toolchain config is 2-pass, so included twice # 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)
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_TARGET = $(cflags-y)
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))
include ../py/mkenv.mk include ../py/mkenv.mk
include ../py/py.mk include ../py/py.mk
@ -64,8 +62,6 @@ KCONFIG_TARGETS = config nconfig menuconfig xconfig gconfig
$(GENERIC_TARGETS) $(KCONFIG_TARGETS): $(LIBMICROPYTHON) $(GENERIC_TARGETS) $(KCONFIG_TARGETS): $(LIBMICROPYTHON)
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) $@ $(MAKE) -f Makefile.zephyr BOARD=$(BOARD) $@
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
$(LIBMICROPYTHON): $(Z_AUTOCONF_H) $(LIBMICROPYTHON): $(Z_AUTOCONF_H)
build/genhdr/qstr.i.last: $(Z_AUTOCONF_H) build/genhdr/qstr.i.last: $(Z_AUTOCONF_H)
@ -73,5 +69,12 @@ $(Z_AUTOCONF_H):
rm -f $(LIBMICROPYTHON) rm -f $(LIBMICROPYTHON)
-$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) -$(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 Zephyr things too
CLEAN_EXTRA = outdir CLEAN_EXTRA = outdir z_config_proxy.mk

17
zephyr/z_config.mk

@ -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…
Cancel
Save