micropython.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ################################################################################
  2. #
  3. # micropython
  4. #
  5. ################################################################################
  6. MICROPYTHON_VERSION = 1.22.0
  7. MICROPYTHON_SITE = https://micropython.org/resources/source
  8. MICROPYTHON_SOURCE = micropython-$(MICROPYTHON_VERSION).tar.xz
  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.
  12. MICROPYTHON_LICENSE = MIT, BSD-1-Clause, BSD-3-Clause, Zlib
  13. MICROPYTHON_LICENSE_FILES = LICENSE
  14. MICROPYTHON_DEPENDENCIES = host-python3
  15. MICROPYTHON_CPE_ID_VENDOR = micropython
  16. # Use fallback implementation for exception handling on architectures that don't
  17. # have explicit support.
  18. ifeq ($(BR2_i386)$(BR2_x86_64)$(BR2_arm)$(BR2_armeb),)
  19. MICROPYTHON_CFLAGS = -DMICROPY_GCREGS_SETJMP=1
  20. endif
  21. # xtensa has problems with nlr_push, use setjmp based implementation instead
  22. ifeq ($(BR2_xtensa),y)
  23. MICROPYTHON_CFLAGS = -DMICROPY_NLR_SETJMP=1
  24. endif
  25. # When building from a tarball we don't have some of the dependencies that are in
  26. # the git repository as submodules
  27. MICROPYTHON_MAKE_OPTS += \
  28. MICROPY_PY_BTREE=0 \
  29. MICROPY_PY_USSL=0 \
  30. CROSS_COMPILE=$(TARGET_CROSS) \
  31. CFLAGS_EXTRA=$(MICROPYTHON_CFLAGS) \
  32. LDFLAGS_EXTRA="$(TARGET_LDFLAGS)" \
  33. CWARN=
  34. ifeq ($(BR2_PACKAGE_LIBFFI),y)
  35. MICROPYTHON_DEPENDENCIES += host-pkgconf libffi
  36. MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=1
  37. else
  38. MICROPYTHON_MAKE_OPTS += MICROPY_PY_FFI=0
  39. endif
  40. define MICROPYTHON_BUILD_CMDS
  41. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/mpy-cross
  42. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
  43. $(MICROPYTHON_MAKE_OPTS)
  44. endef
  45. define MICROPYTHON_INSTALL_TARGET_CMDS
  46. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/ports/unix \
  47. $(MICROPYTHON_MAKE_OPTS) \
  48. DESTDIR=$(TARGET_DIR) \
  49. PREFIX=/usr \
  50. install
  51. endef
  52. $(eval $(generic-package))