Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 := u8g 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. swTimer \
  45. misc \
  46. pm \
  47. $(OPT_SEL_MKTARGETS)
  48. endif # } PDIR
  49. APPDIR = .
  50. LDDIR = ../ld
  51. TARGET_LDFLAGS = \
  52. -nostdlib \
  53. -Wl,-EL \
  54. --longcalls \
  55. --text-section-literals
  56. LD_FILE = $(LDDIR)/nodemcu.ld
  57. COMPONENTS_eagle.app.v6 = \
  58. user/libuser.a \
  59. driver/libdriver.a \
  60. platform/libplatform.a \
  61. task/libtask.a \
  62. libc/liblibc.a \
  63. lua/liblua.a \
  64. lwip/liblwip.a \
  65. smart/smart.a \
  66. spiffs/spiffs.a \
  67. fatfs/libfatfs.a \
  68. pm/libpm.a \
  69. esp-gdbstub/libgdbstub.a \
  70. net/libnodemcu_net.a \
  71. mbedtls/libmbedtls.a \
  72. modules/libmodules.a \
  73. swTimer/libswtimer.a \
  74. misc/libmisc.a \
  75. $(OPT_SEL_COMPONENTS)
  76. # Inspect the modules library and work out which modules need to be linked.
  77. # For each enabled module, a symbol name of the form XYZ_module_selected is
  78. # returned. At link time those names are declared undefined, so those (and
  79. # only those) modules are pulled in.
  80. SELECTED_MODULE_SYMS=$(filter %_module_selected %module_selected1,$(shell $(NM) modules/.output/$(TARGET)/$(FLAVOR)/lib/libmodules.a))
  81. LINKFLAGS_eagle.app.v6 = \
  82. -Wl,--gc-sections \
  83. -Wl,-Map=mapfile \
  84. -nostdlib \
  85. -T$(LD_FILE) \
  86. -Wl,@../ld/defsym.rom \
  87. -Wl,--no-check-sections \
  88. -Wl,--wrap=_xtos_set_exception_handler \
  89. -Wl,-static \
  90. $(addprefix -u , $(SELECTED_MODULE_SYMS)) \
  91. -Wl,--start-group \
  92. -lmain \
  93. -lc \
  94. -lgcc \
  95. -lhal \
  96. -lphy \
  97. -lpp \
  98. -lnet80211 \
  99. -lwpa \
  100. -lwpa2 \
  101. -lsmartconfig \
  102. -lcrypto \
  103. -lwps \
  104. $(DEP_LIBS_eagle.app.v6) \
  105. -Wl,--end-group \
  106. -lm
  107. DEPENDS_eagle.app.v6 = \
  108. $(LD_FILE) \
  109. Makefile
  110. #############################################################
  111. # Configuration i.e. compile options etc.
  112. # Target specific stuff (defines etc.) goes in here!
  113. # Generally values applying to a tree are captured in the
  114. # makefile at its root level - these are then overridden
  115. # for a subtree within the makefile rooted therein
  116. #
  117. #UNIVERSAL_TARGET_DEFINES = \
  118. # Other potential configuration flags include:
  119. # -DTXRX_TXBUF_DEBUG
  120. # -DTXRX_RXBUF_DEBUG
  121. # -DWLAN_CONFIG_CCX
  122. CONFIGURATION_DEFINES = -D__ets__ \
  123. -DICACHE_FLASH \
  124. -DLUA_OPTIMIZE_MEMORY=2 \
  125. -DMIN_OPT_LEVEL=2 \
  126. -DLWIP_OPEN_SRC \
  127. -DPBUF_RSV_FOR_WLAN \
  128. -DEBUF_LWIP \
  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: