Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #############################################################
  2. # Required variables for each makefile
  3. # Discard this section from all parent makefiles
  4. # Expected variables (with automatic defaults):
  5. # CSRCS (all "C" files in the dir)
  6. # SUBDIRS (all subdirs with a Makefile)
  7. # GEN_LIBS - list of libs to be generated ()
  8. # GEN_IMAGES - list of object file images to be generated ()
  9. # GEN_BINS - list of binaries to be generated ()
  10. # COMPONENTS_xxx - a list of libs/objs in the form
  11. # subdir/lib to be extracted and rolled up into
  12. # a generated lib/image xxx.a ()
  13. #
  14. TARGET = eagle
  15. #FLAVOR = release
  16. FLAVOR = debug
  17. #EXTRA_CCFLAGS += -u
  18. ifndef PDIR # {
  19. GEN_IMAGES= eagle.app.v6.out
  20. GEN_BINS= eagle.app.v6.bin
  21. OPT_MKTARGETS := coap crypto dht http mqtt pcm sjson sqlite3 tsl2561 websocket
  22. OPT_MKLIBTARGETS := u8g2 ucg
  23. SEL_MKTARGETS := $(shell $(CC) -E -dM include/user_modules.h | sed -n '/^\#define LUA_USE_MODULES_/{s/.\{24\}\(.*\)/\L\1/; p}')
  24. OPT_SEL_MKLIBTARGETS := $(foreach tgt,$(OPT_MKLIBTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS)))
  25. OPT_SEL_MKTARGETS := $(foreach tgt,$(OPT_MKTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS))) \
  26. $(foreach tgt,$(OPT_SEL_MKLIBTARGETS),$(tgt)lib)
  27. OPT_SEL_COMPONENTS := $(foreach tgt,$(OPT_SEL_MKTARGETS),$(tgt)/lib$(tgt).a)
  28. SPECIAL_MKTARGETS :=$(APP_MKTARGETS)
  29. SUBDIRS= \
  30. user \
  31. driver \
  32. mbedtls \
  33. platform \
  34. libc \
  35. lua \
  36. lwip \
  37. task \
  38. smart \
  39. modules \
  40. spiffs \
  41. net \
  42. fatfs \
  43. esp-gdbstub \
  44. pm \
  45. uzlib \
  46. $(OPT_SEL_MKTARGETS)
  47. endif # } PDIR
  48. APPDIR = .
  49. LDDIR = ../ld
  50. TARGET_LDFLAGS = \
  51. -nostdlib \
  52. -Wl,-EL \
  53. --longcalls \
  54. --text-section-literals
  55. LD_FILE = $(LDDIR)/nodemcu.ld
  56. COMPONENTS_eagle.app.v6 = \
  57. user/libuser.a \
  58. driver/libdriver.a \
  59. platform/libplatform.a \
  60. task/libtask.a \
  61. libc/liblibc.a \
  62. lua/liblua.a \
  63. lwip/liblwip.a \
  64. smart/smart.a \
  65. spiffs/spiffs.a \
  66. fatfs/libfatfs.a \
  67. pm/libpm.a \
  68. esp-gdbstub/libgdbstub.a \
  69. net/libnodemcu_net.a \
  70. mbedtls/libmbedtls.a \
  71. modules/libmodules.a \
  72. smart/smart.a \
  73. uzlib/libuzlib.a \
  74. $(OPT_SEL_COMPONENTS)
  75. # Inspect the modules library and work out which modules need to be linked.
  76. # For each enabled module, a symbol name of the form XYZ_module_selected is
  77. # returned. At link time those names are declared undefined, so those (and
  78. # only those) modules are pulled in.
  79. SELECTED_MODULE_SYMS=$(filter %_module_selected %module_selected1,$(shell $(NM) modules/.output/$(TARGET)/$(FLAVOR)/lib/libmodules.a))
  80. LINKFLAGS_eagle.app.v6 = \
  81. -Wl,--gc-sections \
  82. -Wl,-Map=mapfile \
  83. -nostdlib \
  84. -T$(LD_FILE) \
  85. -Wl,@../ld/defsym.rom \
  86. -Wl,--no-check-sections \
  87. -Wl,--wrap=_xtos_set_exception_handler \
  88. -Wl,-static \
  89. $(addprefix -u , $(SELECTED_MODULE_SYMS)) \
  90. -Wl,--start-group \
  91. -lmain \
  92. -lc \
  93. -lgcc \
  94. -lhal \
  95. -lphy \
  96. -lpp \
  97. -lnet80211 \
  98. -lwpa \
  99. -lwpa2 \
  100. -lsmartconfig \
  101. -lcrypto \
  102. -lwps \
  103. $(DEP_LIBS_eagle.app.v6) \
  104. -Wl,--end-group \
  105. -lm
  106. DEPENDS_eagle.app.v6 = \
  107. $(LD_FILE) \
  108. Makefile
  109. #############################################################
  110. # Configuration i.e. compile options etc.
  111. # Target specific stuff (defines etc.) goes in here!
  112. # Generally values applying to a tree are captured in the
  113. # makefile at its root level - these are then overridden
  114. # for a subtree within the makefile rooted therein
  115. #
  116. #UNIVERSAL_TARGET_DEFINES = \
  117. # Other potential configuration flags include:
  118. # -DTXRX_TXBUF_DEBUG
  119. # -DTXRX_RXBUF_DEBUG
  120. # -DWLAN_CONFIG_CCX
  121. CONFIGURATION_DEFINES = -D__ets__ \
  122. -DICACHE_FLASH \
  123. -DLUA_OPTIMIZE_MEMORY=2 \
  124. -DMIN_OPT_LEVEL=2 \
  125. -DLWIP_OPEN_SRC \
  126. -DPBUF_RSV_FOR_WLAN \
  127. -DEBUF_LWIP \
  128. -DUSE_OPTIMIZE_PRINTF \
  129. -DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
  130. DEFINES += \
  131. $(UNIVERSAL_TARGET_DEFINES) \
  132. $(CONFIGURATION_DEFINES)
  133. DDEFINES += \
  134. $(UNIVERSAL_TARGET_DEFINES) \
  135. $(CONFIGURATION_DEFINES)
  136. #############################################################
  137. # Recursion Magic - Don't touch this!!
  138. #
  139. # Each subtree potentially has an include directory
  140. # corresponding to the common APIs applicable to modules
  141. # rooted at that subtree. Accordingly, the INCLUDE PATH
  142. # of a module can only contain the include directories up
  143. # its parent path, and not its siblings
  144. #
  145. # Required for each makefile to inherit from the parent
  146. #
  147. INCLUDES := $(INCLUDES) -I $(PDIR)include
  148. INCLUDES += -I ./
  149. PDIR := ../$(PDIR)
  150. sinclude $(PDIR)Makefile
  151. .PHONY: FORCE
  152. FORCE: