xref: /OK3568_Linux_fs/buildroot/package/micropython/micropython.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# micropython
4#
5################################################################################
6
7MICROPYTHON_VERSION = 1.17
8MICROPYTHON_SITE = $(call github,micropython,micropython,v$(MICROPYTHON_VERSION))
9# Micropython has a lot of code copied from other projects, and also a number
10# of submodules for various libs. However, we don't even clone the submodules,
11# and most of the copied code is not used in the unix build.
12MICROPYTHON_LICENSE = MIT, BSD-1-Clause, BSD-3-Clause, Zlib
13MICROPYTHON_LICENSE_FILES = LICENSE
14MICROPYTHON_DEPENDENCIES = host-pkgconf libffi host-python3
15
16# Set GIT_DIR so package won't use buildroot's version number
17MICROPYTHON_MAKE_ENV = \
18	$(TARGET_MAKE_ENV) \
19	GIT_DIR=.
20
21# Use fallback implementation for exception handling on architectures that don't
22# have explicit support.
23ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb),)
24MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
25endif
26
27# xtensa has problems with nlr_push, use setjmp based implementation instead
28ifeq ($(BR2_xtensa),y)
29MICROPYTHON_CFLAGS = -DMICROPY_NLR_SETJMP=1
30endif
31
32# When building from a tarball we don't have some of the dependencies that are in
33# the git repository as submodules
34MICROPYTHON_MAKE_OPTS += \
35	MICROPY_PY_BTREE=0 \
36	MICROPY_PY_USSL=0 \
37	CROSS_COMPILE=$(TARGET_CROSS) \
38	CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
39	CWARN=
40
41define MICROPYTHON_BUILD_CMDS
42	$(MICROPYTHON_MAKE_ENV) $(MAKE) -C $(@D)/mpy-cross
43	$(MICROPYTHON_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
44		$(MICROPYTHON_MAKE_OPTS)
45endef
46
47define MICROPYTHON_INSTALL_TARGET_CMDS
48	$(MICROPYTHON_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
49		$(MICROPYTHON_MAKE_OPTS) \
50		DESTDIR=$(TARGET_DIR) \
51		PREFIX=/usr \
52		install
53endef
54
55$(eval $(generic-package))
56