Makefile 4.5 KB

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