Makefile 2.97 KB
Newer Older
1
#
2
3
4
5
6
# This is the main Makefile, which uses MicroPython build system,
# but Zephyr arch-specific toolchain and target-specific flags.
# This Makefile builds MicroPython as a library, and then calls
# recursively Makefile.zephyr to build complete application binary
# using Zephyr build system.
7
8
9
#

BOARD ?= qemu_x86
10
11
12
13
ifeq ($(MAKECMDGOALS), minimal)
# For minimal, CONF_FILE must be overriden early due to $(Z_EXPORTS) target
CONF_FILE = prj_minimal.conf
else
14
CONF_FILE = prj.conf
15
endif
16
17
18
19
20
# Zephyr 1.5.0
#OUTDIR_PREFIX =
# Zephyr 1.6.0
OUTDIR_PREFIX = $(BOARD)

21
22
23
24
# Default heap size is 16KB, which is on conservative side, to let
# it build for smaller boards, but it won't be enough for larger
# applications, and will need to be increased.
MICROPY_HEAP_SIZE = 16384
25
26
FROZEN_DIR = scripts

27
# Zephyr (generated) config files - must be defined before include below
28
29
30
Z_SYSGEN_H = outdir/$(OUTDIR_PREFIX)/misc/generated/sysgen/sysgen.h
Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
include $(Z_EXPORTS)
31
32
33
34
35
36
37

include ../py/mkenv.mk
include ../py/py.mk

INC += -I.
INC += -I..
INC += -I$(BUILD)
38
39
40
INC += -I$(ZEPHYR_BASE)/net/ip
INC += -I$(ZEPHYR_BASE)/net/ip/contiki
INC += -I$(ZEPHYR_BASE)/net/ip/contiki/os
41
42

SRC_C = main.c \
43
	help.c \
44
	modutime.c \
45
	modzephyr.c \
46
47
	modmachine.c \
	machine_pin.c \
48
49
50
51
	uart_core.c \
	lib/utils/stdout_helpers.c \
	lib/utils/printf.c \
	lib/utils/pyexec.c \
Paul Sokolovsky's avatar
Paul Sokolovsky committed
52
	lib/utils/interrupt_char.c \
53
54
55
	lib/mp-readline/readline.c \
	$(SRC_MOD)

56
57
58
# List of sources for qstr extraction
SRC_QSTR += $(SRC_C)

59
60
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

61
CFLAGS = $(KBUILD_CFLAGS) $(NOSTDINC_FLAGS) $(ZEPHYRINCLUDE) \
62
	 -std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC)
63
64
65

include ../py/mkrules.mk

66
$(Z_EXPORTS): $(CONF_FILE)
67
	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) initconfig outputexports
68

69
GENERIC_TARGETS = all zephyr qemu qemugdb flash debug
70
71
72
73
74
75
76
77
78
79
80
81
KCONFIG_TARGETS = \
	initconfig config nconfig menuconfig xconfig gconfig \
	oldconfig silentoldconfig defconfig savedefconfig \
	allnoconfig allyesconfig alldefconfig randconfig \
	listnewconfig olddefconfig
CLEAN_TARGETS = pristine mrproper

$(GENERIC_TARGETS): $(LIBMICROPYTHON)
$(CLEAN_TARGETS):  clean

$(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
	$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
82
	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE) $@
83

84
85
$(LIBMICROPYTHON): $(Z_SYSGEN_H)
build/genhdr/qstr.i.last: $(Z_SYSGEN_H)
86

87
$(Z_SYSGEN_H):
88
	rm -f $(LIBMICROPYTHON)
89
	-$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=$(CONF_FILE)
90

91
minimal:
92
	$(MAKE) BOARD=$(BOARD) CONF_FILE=prj_minimal.conf CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_minimal.h>"' FROZEN_DIR=
93

94
95
96
qemu-minimal:
	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) CONF_FILE=prj_minimal.conf QEMU_NET=0 run

97
# Clean Zephyr things too
98
99
100
101
clean: z_clean

z_clean:
	$(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
102
103
104
105
106

.PHONY: prj.conf
prj.conf: prj_base.conf
	cat $< >$@
	if [ -f prj_$(BOARD).conf ]; then cat prj_$(BOARD).conf >>$@; fi