Makefile 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. # copyright (c) 2010 Espressif System
  2. #
  3. .NOTPARALLEL:
  4. TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
  5. # SDK base version, as released by Espressif depends on the RELEASE flag
  6. #
  7. # RELEASE = lastest pulls the latest V3.0.0 branch version as at the issue of this make
  8. # otherwise it pulls the labelled version in the SDK version's release directory
  9. #
  10. ifeq ("$(RELEASE)","latest-3.0")
  11. SDK_VER := 3.0.0
  12. SDK_FILE_SHA1 := NA
  13. SDK_ZIP_ROOT := ESP8266_NONOS_SDK-release-v$(SDK_VER)
  14. SDK_FILE_VER := release/v$(SDK_VER)
  15. else ifeq ("$(RELEASE)","master")
  16. SDK_VER := master
  17. SDK_FILE_SHA1 := NA
  18. SDK_ZIP_ROOT := ESP8266_NONOS_SDK-$(SDK_VER)
  19. SDK_FILE_VER := $(SDK_VER)
  20. else
  21. # SDK_VER := 3.0
  22. # SDK_FILE_VER := v$(SDK_VER)
  23. SDK_FILE_VER := e4434aa730e78c63040ace360493aef420ec267c
  24. SDK_VER := 3.0-e4434aa
  25. SDK_FILE_SHA1 := ac6528a6a206d3d4c220e4035ced423eb314cfbf
  26. SDK_ZIP_ROOT := ESP8266_NONOS_SDK-$(SDK_FILE_VER)
  27. endif
  28. SDK_REL_DIR := sdk/esp_iot_sdk_v$(SDK_VER)
  29. SDK_DIR := $(TOP_DIR)/$(SDK_REL_DIR)
  30. APP_DIR := $(TOP_DIR)/app
  31. ESPTOOL_VER := 2.6
  32. # Ensure that the Espresif SDK is search before application paths and also prevent
  33. # the SDK's c_types.h from being included from anywhere, by predefining its include-guard.
  34. CCFLAGS := $(CCFLAGS) -I $(PDIR)sdk-overrides/include -I $(SDK_DIR)/include -D_C_TYPES_H_
  35. LDFLAGS := -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
  36. ifdef DEBUG
  37. CCFLAGS += -ggdb -O0
  38. LDFLAGS += -ggdb
  39. else
  40. CCFLAGS += -O2
  41. endif
  42. # Handling of V=1/VERBOSE=1 flag
  43. #
  44. # if V=1, $(summary) does nothing
  45. # if V is unset or not 1, $(summary) echoes a summary
  46. VERBOSE ?=
  47. V ?= $(VERBOSE)
  48. ifeq ("$(V)","1")
  49. export summary := @true
  50. else
  51. export summary := @echo
  52. # disable echoing of commands, directory names
  53. MAKEFLAGS += --silent -w
  54. endif # $(V)==1
  55. ifndef BAUDRATE
  56. BAUDRATE=115200
  57. endif
  58. #############################################################
  59. # Select compile
  60. #
  61. # ** HEALTH WARNING ** This section is largely legacy directives left over from
  62. # an Espressif template. As far as I (TerrryE) know, we've only used the Linux
  63. # Path. I have successfully build AMD and Intel (both x86, AMD64) and RPi ARM6
  64. # all under Ubuntu. Our docker container runs on Windows in an Ubuntu VM.
  65. # Johny Mattson maintains a prebuild AMD64 xtensa cross-compile gcc v4.8.5
  66. # toolchain which is compatible with the non-OS SDK and can be used on any recent
  67. # Ubuntu version including the Docker and Travis build environments.
  68. #
  69. # You have the option to build your own toolchain and specify a TOOLCHAIN_ROOT
  70. # environment variable (see https://github.com/pfalcon/esp-open-sdk). If your
  71. # architecture is compatable then you can omit this variable and the make will
  72. # download and use this prebuilt toolchain.
  73. #
  74. # If any developers wish to develop, test and support alternative environments
  75. # then please raise a GitHub issue on this work.
  76. #
  77. ifndef $(OS)
  78. # Assume Windows if MAKE_HOST contains "indows" and Linux otherwise
  79. ifneq (,$(findstring indows,$(MAKE_HOST)))
  80. OS := windows
  81. else
  82. OS := linux
  83. endif
  84. endif
  85. ifneq (,$(findstring indows,$(OS)))
  86. #------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows.
  87. ifeq ($(XTENSA_CORE),lx106)
  88. # It is xcc
  89. AR = xt-ar
  90. CC = xt-xcc
  91. CXX = xt-xcc
  92. NM = xt-nm
  93. CPP = xt-cpp
  94. OBJCOPY = xt-objcopy
  95. #MAKE = xt-make
  96. CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
  97. else
  98. # It is gcc, may be cygwin
  99. # Can we use -fdata-sections?
  100. CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections -fpack-struct=4
  101. AR = xtensa-lx106-elf-ar
  102. CC = xtensa-lx106-elf-gcc
  103. CXX = xtensa-lx106-elf-g++
  104. NM = xtensa-lx106-elf-nm
  105. CPP = xtensa-lx106-elf-cpp
  106. OBJCOPY = xtensa-lx106-elf-objcopy
  107. endif
  108. FIRMWAREDIR = ..\\bin\\
  109. ifndef COMPORT
  110. ESPPORT = com1
  111. else
  112. ESPPORT = $(COMPORT)
  113. endif
  114. ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
  115. # ->AMD64
  116. endif
  117. ifeq ($(PROCESSOR_ARCHITECTURE),x86)
  118. # ->IA32
  119. endif
  120. #---------------- END UNTESTED ---------------- We are under windows.
  121. else
  122. # We are under other system, may be Linux. Assume using gcc.
  123. UNAME_S := $(shell uname -s)
  124. UNAME_P := $(shell uname -p)
  125. ifeq ($(OS),linux)
  126. ifndef TOOLCHAIN_ROOT
  127. TOOLCHAIN_VERSION = 20190731.0
  128. GCCTOOLCHAIN = linux-x86_64-$(TOOLCHAIN_VERSION)
  129. TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
  130. GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
  131. export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin
  132. endif
  133. endif
  134. ifndef COMPORT
  135. ESPPORT = /dev/ttyUSB0
  136. else
  137. ESPPORT = $(COMPORT)
  138. endif
  139. CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
  140. AR = xtensa-lx106-elf-ar
  141. CC = $(WRAPCC) xtensa-lx106-elf-gcc
  142. CXX = $(WRAPCC) xtensa-lx106-elf-g++
  143. NM = xtensa-lx106-elf-nm
  144. CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
  145. OBJCOPY = xtensa-lx106-elf-objcopy
  146. FIRMWAREDIR = ../bin/
  147. WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused
  148. endif
  149. GITHUB_SDK = https://github.com/espressif/ESP8266_NONOS_SDK
  150. GITHUB_ESPTOOL = https://github.com/espressif/esptool
  151. ESPTOOL ?= $(TOP_DIR)/tools/toolchains/esptool.py
  152. SUBDIRS ?= $(patsubst %/,%,$(dir $(filter-out tools/Makefile,$(wildcard */Makefile))))
  153. ODIR := .output
  154. ifdef TARGET
  155. CSRCS ?= $(wildcard *.c)
  156. CXXSRCS ?= $(wildcard *.cpp)
  157. ASRCs ?= $(wildcard *.s)
  158. ASRCS ?= $(wildcard *.S)
  159. OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
  160. OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
  161. $(CXXSRCS:%.cpp=$(OBJODIR)/%.o) \
  162. $(ASRCs:%.s=$(OBJODIR)/%.o) \
  163. $(ASRCS:%.S=$(OBJODIR)/%.o)
  164. DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \
  165. $(CXXSCRS:%.cpp=$(OBJODIR)/%.d) \
  166. $(ASRCs:%.s=$(OBJODIR)/%.d) \
  167. $(ASRCS:%.S=$(OBJODIR)/%.d)
  168. LIBODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/lib
  169. OLIBS := $(GEN_LIBS:%=$(LIBODIR)/%)
  170. IMAGEODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/image
  171. OIMAGES := $(GEN_IMAGES:%=$(IMAGEODIR)/%)
  172. BINODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/bin
  173. OBINS := $(GEN_BINS:%=$(BINODIR)/%)
  174. ifndef PDIR
  175. ifneq ($(wildcard $(TOP_DIR)/local/fs/*),)
  176. SPECIAL_MKTARGETS += spiffs-image
  177. else
  178. SPECIAL_MKTARGETS += spiffs-image-remove
  179. endif
  180. endif
  181. endif # TARGET
  182. #
  183. # Note:
  184. # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
  185. # If you add global optimize options then they will override "-Os" defined above.
  186. # Note that "-Os" should NOT be used to reduce code size because of the runtime
  187. # impact of the extra non-aligned exception burdon.
  188. #
  189. CCFLAGS += \
  190. -g \
  191. -Wpointer-arith \
  192. -Wundef \
  193. -Werror \
  194. -Wl,-EL \
  195. -fno-inline-functions \
  196. -nostdlib \
  197. -mlongcalls \
  198. -mtext-section-literals \
  199. # -Wall
  200. CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  201. DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  202. #############################################################
  203. # Functions
  204. #
  205. ifdef TARGET
  206. define ShortcutRule
  207. $(1): .subdirs $(2)/$(1)
  208. endef
  209. define MakeLibrary
  210. DEP_LIBS_$(1) = $$(foreach lib,$$(filter %.a,$$(COMPONENTS_$(1))),$$(dir $$(lib))$$(LIBODIR)/$$(notdir $$(lib)))
  211. DEP_OBJS_$(1) = $$(foreach obj,$$(filter %.o,$$(COMPONENTS_$(1))),$$(dir $$(obj))$$(OBJODIR)/$$(notdir $$(obj)))
  212. $$(LIBODIR)/$(1).a: $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(DEPENDS_$(1))
  213. @mkdir -p $$(LIBODIR)
  214. $$(if $$(filter %.a,$$?),mkdir -p $$(EXTRACT_DIR)_$(1))
  215. $$(if $$(filter %.a,$$?),cd $$(EXTRACT_DIR)_$(1); $$(foreach lib,$$(filter %.a,$$?),$$(AR) xo $$(UP_EXTRACT_DIR)/$$(lib);))
  216. $(summary) AR $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  217. $$(AR) ru $$@ $$(filter %.o,$$?) $$(if $$(filter %.a,$$?),$$(EXTRACT_DIR)_$(1)/*.o)
  218. $$(if $$(filter %.a,$$?),$$(RM) -r $$(EXTRACT_DIR)_$(1))
  219. endef
  220. define MakeImage
  221. DEP_LIBS_$(1) = $$(foreach lib,$$(filter %.a,$$(COMPONENTS_$(1))),$$(dir $$(lib))$$(LIBODIR)/$$(notdir $$(lib)))
  222. DEP_OBJS_$(1) = $$(foreach obj,$$(filter %.o,$$(COMPONENTS_$(1))),$$(dir $$(obj))$$(OBJODIR)/$$(notdir $$(obj)))
  223. $$(IMAGEODIR)/$(1).out: $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(DEPENDS_$(1))
  224. @mkdir -p $$(IMAGEODIR)
  225. $(summary) LD $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$$@
  226. $$(CC) $$(LDFLAGS) $$(if $$(LINKFLAGS_$(1)),$$(LINKFLAGS_$(1)),$$(LINKFLAGS_DEFAULT) $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1))) -o $$@
  227. endef
  228. $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
  229. @mkdir -p $(BINODIR)
  230. $(summary) NM $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$@
  231. @$(NM) $< | grep -w U && { echo "Firmware has undefined (but unused) symbols!"; exit 1; } || true
  232. $(summary) ESPTOOL $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$< $(FIRMWAREDIR)
  233. $(ESPTOOL) elf2image --flash_mode dio --flash_freq 40m $< -o $(FIRMWAREDIR)
  234. endif # TARGET
  235. #############################################################
  236. # Rules base
  237. # Should be done in top-level makefile only
  238. #
  239. ifndef TARGET
  240. all: toolchain sdk_pruned pre_build buildinfo .subdirs
  241. else
  242. all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
  243. endif
  244. .PHONY: sdk_extracted
  245. .PHONY: sdk_pruned
  246. .PHONY: toolchain
  247. sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_VER)
  248. sdk_pruned: sdk_extracted toolchain $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
  249. ifdef GITHUB_TOOLCHAIN
  250. TOOLCHAIN_ROOT := $(TOP_DIR)/tools/toolchains/esp8266-linux-x86_64-$(TOOLCHAIN_VERSION)
  251. toolchain: $(TOOLCHAIN_ROOT)/bin $(ESPTOOL)
  252. $(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz
  253. mkdir -p $(TOP_DIR)/tools/toolchains/
  254. $(summary) EXTRACT $(patsubst $(TOP_DIR)/%,%,$<)
  255. tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
  256. touch $@
  257. $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz:
  258. mkdir -p $(TOP_DIR)/cache
  259. $(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
  260. $(WGET) $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz -O $@ \
  261. || { rm -f "$@"; exit 1; }
  262. else
  263. toolchain: $(ESPTOOL)
  264. endif
  265. $(ESPTOOL): $(TOP_DIR)/cache/esptool/v$(ESPTOOL_VER).tar.gz
  266. mkdir -p $(TOP_DIR)/tools/toolchains/
  267. tar -C $(TOP_DIR)/tools/toolchains/ -xzf $< --strip-components=1 esptool-$(ESPTOOL_VER)/esptool.py
  268. chmod +x $@
  269. touch $@
  270. $(TOP_DIR)/cache/esptool/v$(ESPTOOL_VER).tar.gz:
  271. mkdir -p $(TOP_DIR)/cache/esptool/
  272. $(WGET) $(GITHUB_ESPTOOL)/archive/v$(ESPTOOL_VER).tar.gz -O $@ || { rm -f "$@"; exit 1; }
  273. $(TOP_DIR)/sdk/.extracted-$(SDK_VER): $(TOP_DIR)/cache/$(SDK_FILE_VER).zip
  274. mkdir -p "$(dir $@)"
  275. $(summary) UNZIP $(patsubst $(TOP_DIR)/%,%,$<)
  276. (cd "$(dir $@)" && \
  277. rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-* && \
  278. unzip $(TOP_DIR)/cache/$(SDK_FILE_VER).zip \
  279. '*/lib/*' \
  280. '*/ld/*.v6.ld' \
  281. '*/include/*' \
  282. '*/bin/esp_init_data_default_v05.bin' \
  283. )
  284. mv $(dir $@)/$(SDK_ZIP_ROOT) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
  285. touch $@
  286. $(TOP_DIR)/sdk/.pruned-$(SDK_VER):
  287. rm -f $(SDK_DIR)/lib/liblwip.a $(SDK_DIR)/lib/libssl.a $(SDK_DIR)/lib/libmbedtls.a
  288. $(summary) PRUNE libmain.a libc.a
  289. echo $(PATH)
  290. $(AR) d $(SDK_DIR)/lib/libmain.a time.o
  291. $(AR) d $(SDK_DIR)/lib/libc.a lib_a-time.o
  292. touch $@
  293. $(TOP_DIR)/cache/$(SDK_FILE_VER).zip:
  294. mkdir -p "$(dir $@)"
  295. $(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
  296. $(WGET) $(GITHUB_SDK)/archive/$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
  297. if test "$(SDK_FILE_SHA1)" != "NA"; then echo "$(SDK_FILE_SHA1) $@" | sha1sum -c - || { rm -f "$@"; exit 1; }; fi
  298. clean:
  299. $(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clean;)
  300. $(RM) -r $(ODIR)/$(TARGET)/$(FLAVOR)
  301. $(RM) -r "$(TOP_DIR)/sdk"
  302. clobber: $(SPECIAL_CLOBBER)
  303. $(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clobber;)
  304. $(RM) -r $(ODIR)
  305. flash:
  306. @echo "use one of the following targets to flash the firmware"
  307. @echo " make flash512k - for ESP with 512kB flash size"
  308. @echo " make flash1m-dout - for ESP with 1MB flash size and flash mode = dout (Sonoff, ESP8285)"
  309. @echo " make flash4m - for ESP with 4MB flash size"
  310. flash512k:
  311. $(MAKE) -e FLASHOPTIONS="-fm qio -fs 4m -ff 40m" flashinternal
  312. flash4m:
  313. $(MAKE) -e FLASHOPTIONS="-fm dio -fs 32m -ff 40m" flashinternal
  314. flash1m-dout:
  315. $(MAKE) -e FLASHOPTIONS="-fm dout -fs 8m -ff 40m" flashinternal
  316. flashinternal:
  317. ifndef PDIR
  318. $(MAKE) -C $(APP_DIR) flashinternal
  319. else
  320. $(ESPTOOL) --port $(ESPPORT) --baud $(BAUDRATE) write_flash $(FLASHOPTIONS) 0x00000 $(FIRMWAREDIR)0x00000.bin 0x10000 $(FIRMWAREDIR)0x10000.bin
  321. endif
  322. .subdirs:
  323. @set -e; $(foreach d, $(SUBDIRS), $(MAKE) -C $(d);)
  324. ifneq ($(MAKECMDGOALS),clean)
  325. ifneq ($(MAKECMDGOALS),clobber)
  326. ifdef DEPS
  327. sinclude $(DEPS)
  328. endif
  329. endif
  330. endif
  331. .PHONY: spiffs-image-remove
  332. spiffs-image-remove:
  333. $(MAKE) -C tools remove-image spiffsimg/spiffsimg
  334. .PHONY: spiffs-image
  335. spiffs-image: bin/0x10000.bin
  336. $(MAKE) -C tools
  337. ############ Note: this target needs moving into app/modules make ############
  338. .PHONY: pre_build
  339. ifneq ($(wildcard $(TOP_DIR)/server-ca.crt),)
  340. pre_build: $(APP_DIR)/modules/server-ca.crt.h
  341. $(APP_DIR)/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt
  342. $(summary) MKCERT $(patsubst $(TOP_DIR)/%,%,$<)
  343. python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(APP_DIR)/modules/server-ca.crt.h
  344. DEFINES += -DHAVE_SSL_SERVER_CRT=\"server-ca.crt.h\"
  345. else
  346. pre_build:
  347. @-rm -f $(APP_DIR)/modules/server-ca.crt.h
  348. endif
  349. .PHONY: buildinfo
  350. buildinfo:
  351. tools/update_buildinfo.sh
  352. ifdef TARGET
  353. $(OBJODIR)/%.o: %.c
  354. @mkdir -p $(dir $@);
  355. $(summary) CC $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  356. $(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
  357. $(OBJODIR)/%.d: %.c
  358. @mkdir -p $(dir $@);
  359. $(summary) DEPEND: CC $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  360. @set -e; rm -f $@; \
  361. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  362. sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  363. rm -f $@.$$$$
  364. $(OBJODIR)/%.o: %.cpp
  365. @mkdir -p $(OBJODIR);
  366. $(summary) CXX $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  367. $(CXX) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
  368. $(OBJODIR)/%.d: %.cpp
  369. @mkdir -p $(OBJODIR);
  370. $(summary) DEPEND: CXX $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  371. @set -e; rm -f $@; \
  372. sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  373. rm -f $@.$$$$
  374. $(OBJODIR)/%.o: %.s
  375. @mkdir -p $(dir $@);
  376. $(summary) CC $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  377. $(CC) $(CFLAGS) -o $@ -c $<
  378. $(OBJODIR)/%.d: %.s
  379. @mkdir -p $(dir $@); \
  380. set -e; rm -f $@; \
  381. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  382. sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  383. rm -f $@.$$$$
  384. $(OBJODIR)/%.o: %.S
  385. @mkdir -p $(dir $@);
  386. $(summary) CC $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
  387. $(CC) $(CFLAGS) -D__ASSEMBLER__ -o $@ -c $<
  388. $(OBJODIR)/%.d: %.S
  389. @mkdir -p $(dir $@); \
  390. set -e; rm -f $@; \
  391. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  392. sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  393. rm -f $@.$$$$
  394. $(foreach lib,$(GEN_LIBS),$(eval $(call ShortcutRule,$(lib),$(LIBODIR))))
  395. $(foreach image,$(GEN_IMAGES),$(eval $(call ShortcutRule,$(image),$(IMAGEODIR))))
  396. $(foreach bin,$(GEN_BINS),$(eval $(call ShortcutRule,$(bin),$(BINODIR))))
  397. $(foreach lib,$(GEN_LIBS),$(eval $(call MakeLibrary,$(basename $(lib)))))
  398. $(foreach image,$(GEN_IMAGES),$(eval $(call MakeImage,$(basename $(image)))))
  399. endif # TARGET
  400. #############################################################
  401. # Recursion Magic - Don't touch this!!
  402. #
  403. # Each subtree potentially has an include directory
  404. # corresponding to the common APIs applicable to modules
  405. # rooted at that subtree. Accordingly, the INCLUDE PATH
  406. # of a module can only contain the include directories up
  407. # its parent path, and not its siblings
  408. #
  409. # Required for each makefile to inherit from the parent
  410. #
  411. PDIR := ../$(PDIR)
  412. sinclude $(PDIR)Makefile