Makefile 4.3 KB

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