Skip to content

Commit 244b02f

Browse files
committed
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.
1 parent cbc0bf6 commit 244b02f

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

zephyr/Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ BOARD ?= qemu_x86
1515
# Zephyr 1.6.0
1616
OUTDIR_PREFIX = $(BOARD)
1717

18+
# Zephyr (generated) config files - must be defined before include below
1819
Z_DOTCONFIG = outdir/$(OUTDIR_PREFIX)/.config
20+
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
1921
DQUOTE = "
2022
# "
21-
include $(Z_DOTCONFIG)
22-
override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
23+
include z_config_proxy.mk
2324

2425
# Zephyr toolchain config is 2-pass, so included twice
2526
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
2627
include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
2728

28-
CFLAGS_arm = -mthumb -mcpu=cortex-m3 -mabi=aapcs
29-
CFLAGS_x86 = -fno-asynchronous-unwind-tables -ffreestanding -fno-stack-protector \
30-
-fno-omit-frame-pointer -mpreferred-stack-boundary=2 -mno-sse -march=pentium
31-
CFLAGS_TARGET = $(CFLAGS_$(ARCH))
29+
CFLAGS_TARGET = $(cflags-y)
3230

3331
include ../py/mkenv.mk
3432
include ../py/py.mk
@@ -64,14 +62,19 @@ KCONFIG_TARGETS = config nconfig menuconfig xconfig gconfig
6462
$(GENERIC_TARGETS) $(KCONFIG_TARGETS): $(LIBMICROPYTHON)
6563
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) $@
6664

67-
Z_AUTOCONF_H = outdir/$(OUTDIR_PREFIX)/include/generated/autoconf.h
68-
6965
$(LIBMICROPYTHON): $(Z_AUTOCONF_H)
7066
build/genhdr/qstr.i.last: $(Z_AUTOCONF_H)
7167

7268
$(Z_AUTOCONF_H):
7369
rm -f $(LIBMICROPYTHON)
7470
-$(MAKE) -f Makefile.zephyr BOARD=$(BOARD)
7571

72+
zephyr_arch.mk: $(Z_DOTCONFIG)
73+
echo "include $(ZEPHYR_BASE)/arch/$(ARCH)/Makefile" >$@
74+
75+
z_config_proxy.mk:
76+
$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) initconfig
77+
echo "include z_config.mk" >$@
78+
7679
# Clean Zephyr things too
77-
CLEAN_EXTRA = outdir
80+
CLEAN_EXTRA = outdir z_config_proxy.mk

zephyr/z_config.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
srctree = $(ZEPHYR_BASE)
2+
3+
include $(Z_DOTCONFIG)
4+
override ARCH = $(subst $(DQUOTE),,$(CONFIG_ARCH))
5+
SOC_NAME = $(subst $(DQUOTE),,$(CONFIG_SOC))
6+
SOC_SERIES = $(subst $(DQUOTE),,$(CONFIG_SOC_SERIES))
7+
SOC_FAMILY = $(subst $(DQUOTE),,$(CONFIG_SOC_FAMILY))
8+
ifeq ($(SOC_SERIES),)
9+
SOC_PATH = $(SOC_NAME)
10+
else
11+
SOC_PATH = $(SOC_FAMILY)/$(SOC_SERIES)
12+
endif
13+
14+
KBUILD_CFLAGS := -c
15+
include $(ZEPHYR_BASE)/scripts/Kbuild.include
16+
17+
include $(ZEPHYR_BASE)/arch/$(ARCH)/Makefile

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy