Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #
  2. # This is the main Makefile, which uses MicroPython build system,
  3. # but Zephyr arch-specific toolchain and target-specific flags.
  4. # This Makefile builds MicroPython as a library, and then calls
  5. # recursively Makefile.zephyr to build complete application binary
  6. # using Zephyr build system.
  7. #
  8. # To build a "minimal" configuration, use "make-minimal" wrapper.
  9. BOARD ?= qemu_x86
  10. CONF_FILE = prj_$(BOARD)_merged.conf
  11. OUTDIR_PREFIX = $(BOARD)
  12. # Default heap size is 16KB, which is on conservative side, to let
  13. # it build for smaller boards, but it won't be enough for larger
  14. # applications, and will need to be increased.
  15. MICROPY_HEAP_SIZE = 16384
  16. FROZEN_DIR = scripts
  17. # Default target
  18. all:
  19. include ../../py/mkenv.mk
  20. include $(TOP)/py/py.mk
  21. # Zephyr (generated) config files - must be defined before include below
  22. Z_EXPORTS = outdir/$(OUTDIR_PREFIX)/Makefile.export
  23. ifneq ($(MAKECMDGOALS), clean)
  24. include $(Z_EXPORTS)
  25. endif
  26. INC += -I.
  27. INC += -I$(TOP)
  28. INC += -I$(BUILD)
  29. INC += -I$(ZEPHYR_BASE)/net/ip
  30. INC += -I$(ZEPHYR_BASE)/net/ip/contiki
  31. INC += -I$(ZEPHYR_BASE)/net/ip/contiki/os
  32. SRC_C = main.c \
  33. help.c \
  34. modusocket.c \
  35. modutime.c \
  36. modzephyr.c \
  37. modzsensor.c \
  38. modmachine.c \
  39. machine_pin.c \
  40. uart_core.c \
  41. lib/utils/stdout_helpers.c \
  42. lib/utils/printf.c \
  43. lib/utils/pyexec.c \
  44. lib/utils/interrupt_char.c \
  45. lib/mp-readline/readline.c \
  46. $(SRC_MOD)
  47. # List of sources for qstr extraction
  48. SRC_QSTR += $(SRC_C)
  49. OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
  50. CFLAGS = $(Z_CFLAGS) \
  51. -std=gnu99 -fomit-frame-pointer -DNDEBUG -DMICROPY_HEAP_SIZE=$(MICROPY_HEAP_SIZE) $(CFLAGS_EXTRA) $(INC)
  52. include $(TOP)/py/mkrules.mk
  53. GENERIC_TARGETS = all zephyr run qemu qemugdb flash debug debugserver
  54. KCONFIG_TARGETS = \
  55. initconfig config nconfig menuconfig xconfig gconfig \
  56. oldconfig silentoldconfig defconfig savedefconfig \
  57. allnoconfig allyesconfig alldefconfig randconfig \
  58. listnewconfig olddefconfig
  59. CLEAN_TARGETS = pristine mrproper
  60. $(GENERIC_TARGETS): $(LIBMICROPYTHON)
  61. $(CLEAN_TARGETS): clean
  62. $(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
  63. $(MAKE) -C outdir/$(BOARD) $@
  64. $(LIBMICROPYTHON): | $(Z_EXPORTS)
  65. build/genhdr/qstr.i.last: | $(Z_EXPORTS)
  66. # If we recreate libmicropython, also cause zephyr.bin relink
  67. LIBMICROPYTHON_EXTRA_CMD = -$(RM) -f outdir/$(OUTDIR_PREFIX)/zephyr.lnk
  68. # MicroPython's global clean cleans everything, fast
  69. CLEAN_EXTRA = outdir libmicropython.a prj_*_merged.conf
  70. # Clean Zephyr things in Zephyr way
  71. z_clean:
  72. $(MAKE) -f Makefile.zephyr BOARD=$(BOARD) clean
  73. # This rule is for prj_$(BOARD)_merged.conf, not $(CONF_FILE), which
  74. # can be overriden.
  75. # prj_$(BOARD).conf is optional, that's why it's resolved with $(wildcard)
  76. # function.
  77. prj_$(BOARD)_merged.conf: prj_base.conf $(wildcard prj_$(BOARD).conf)
  78. $(PYTHON) makeprj.py prj_base.conf prj_$(BOARD).conf $@
  79. test:
  80. cd $(TOP)/tests && ./run-tests --target minimal --device "execpty:make -C ../ports/zephyr run BOARD=$(BOARD) QEMU_PTY=1"
  81. cmake: outdir/$(BOARD)/Makefile
  82. outdir/$(BOARD)/Makefile: $(CONF_FILE)
  83. mkdir -p outdir/$(BOARD) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -Boutdir/$(BOARD) -H.
  84. $(Z_EXPORTS): outdir/$(BOARD)/Makefile
  85. make --no-print-directory -C outdir/$(BOARD) outputexports CMAKE_COMMAND=: >$@
  86. make -C outdir/$(BOARD) syscall_macros_h_target syscall_list_h_target kobj_types_h_target