Makefile.micropython 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # This file is part of the MicroPython project, http://micropython.org/
  2. # The MIT License (MIT)
  3. # Copyright (c) 2022-2023 Damien P. George
  4. #
  5. # This file is intended to be included by a Makefile in a custom project.
  6. # Set the build output directory for the generated files.
  7. BUILD = build-embed
  8. # Include the core environment definitions; this will set $(TOP).
  9. include $(MICROPYTHON_TOP)/py/mkenv.mk
  10. # Include py core make definitions.
  11. include $(TOP)/py/py.mk
  12. include $(TOP)/extmod/extmod.mk
  13. # Set the location of the MicroPython embed port.
  14. MICROPYTHON_EMBED_PORT = $(MICROPYTHON_TOP)/ports/embed
  15. # Set default makefile-level MicroPython feature configurations.
  16. MICROPY_ROM_TEXT_COMPRESSION ?= 0
  17. # Set CFLAGS for the MicroPython build.
  18. CFLAGS += -I. -I$(TOP) -I$(BUILD) -I$(MICROPYTHON_EMBED_PORT)
  19. CFLAGS += -Wall -Werror -std=c99
  20. # Define the required generated header files.
  21. GENHDR_OUTPUT = $(addprefix $(BUILD)/genhdr/, \
  22. moduledefs.h \
  23. mpversion.h \
  24. qstrdefs.generated.h \
  25. root_pointers.h \
  26. )
  27. # Define the top-level target, the generated output files.
  28. .PHONY: all
  29. all: micropython-embed-package
  30. clean: clean-micropython-embed-package
  31. .PHONY: clean-micropython-embed-package
  32. clean-micropython-embed-package:
  33. $(RM) -rf $(PACKAGE_DIR)
  34. PACKAGE_DIR ?= micropython_embed
  35. PACKAGE_DIR_LIST = $(addprefix $(PACKAGE_DIR)/,py extmod shared/runtime genhdr port)
  36. .PHONY: micropython-embed-package
  37. micropython-embed-package: $(GENHDR_OUTPUT)
  38. $(ECHO) "Generate micropython_embed output:"
  39. $(Q)$(RM) -rf $(PACKAGE_DIR_LIST)
  40. $(Q)$(MKDIR) -p $(PACKAGE_DIR_LIST)
  41. $(ECHO) "- py"
  42. $(Q)$(CP) $(TOP)/py/*.[ch] $(PACKAGE_DIR)/py
  43. $(ECHO) "- extmod"
  44. $(Q)$(CP) $(TOP)/extmod/modplatform.h $(PACKAGE_DIR)/extmod
  45. $(Q)$(CP) $(TOP)/extmod/modtime.[ch] $(PACKAGE_DIR)/extmod
  46. $(Q)$(CP) $(TOP)/extmod/modrandom.[ch] $(PACKAGE_DIR)/extmod
  47. $(ECHO) "- shared"
  48. $(Q)$(CP) $(TOP)/shared/runtime/gchelper.h $(PACKAGE_DIR)/shared/runtime
  49. $(Q)$(CP) $(TOP)/shared/runtime/gchelper_generic.c $(PACKAGE_DIR)/shared/runtime
  50. $(ECHO) "- genhdr"
  51. $(Q)$(CP) $(GENHDR_OUTPUT) $(PACKAGE_DIR)/genhdr
  52. $(ECHO) "- port"
  53. $(Q)$(CP) $(MICROPYTHON_EMBED_PORT)/port/*.[ch] $(PACKAGE_DIR)/port
  54. # Include remaining core make rules.
  55. include $(TOP)/py/mkrules.mk