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