Makefile.unix 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. ############################################################################
  2. # tools/Makefile.unix
  3. #
  4. # Licensed to the Apache Software Foundation (ASF) under one or more
  5. # contributor license agreements. See the NOTICE file distributed with
  6. # this work for additional information regarding copyright ownership. The
  7. # ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance with the
  9. # License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. #
  19. ############################################################################
  20. export TOPDIR := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
  21. include $(TOPDIR)/Make.defs
  22. # GIT directory present
  23. GIT_DIR = $(if $(wildcard $(TOPDIR)$(DELIM).git),y,)
  24. ifeq ($(GIT_DIR),y)
  25. GIT_PRESENT = `git rev-parse --git-dir 2> /dev/null`
  26. endif
  27. # In case we cannot get version information from GIT
  28. ifeq ($(GIT_PRESENT),)
  29. -include $(TOPDIR)/.version
  30. # In case the version file does not exist
  31. CONFIG_VERSION_STRING ?= "0.0.0"
  32. CONFIG_VERSION_BUILD ?= "0"
  33. VERSION_ARG = -v $(CONFIG_VERSION_STRING) -b $(CONFIG_VERSION_BUILD)
  34. else
  35. # Generate .version every time from GIT history
  36. .PHONY: $(TOPDIR)/.version
  37. endif
  38. # Process architecture specific directories
  39. ARCH_DIR = arch/$(CONFIG_ARCH)
  40. ARCH_SRC = $(ARCH_DIR)/src
  41. ARCH_INC = $(ARCH_DIR)/include
  42. # CONFIG_APPS_DIR can be over-ridden from the command line or in the .config file.
  43. # The default value of CONFIG_APPS_DIR is ../apps. Ultimately, the application
  44. # will be built if APPDIR is defined. APPDIR will be defined if a directory containing
  45. # a Makefile is found at the path provided by CONFIG_APPS_DIR
  46. ifeq ($(CONFIG_APPS_DIR),)
  47. CONFIG_APPS_DIR = ../apps
  48. endif
  49. APPDIR := $(realpath ${shell if [ -r $(CONFIG_APPS_DIR)/Makefile ]; then echo "$(CONFIG_APPS_DIR)"; fi})
  50. # External code support
  51. # If external/ contains a Kconfig, we define the EXTERNALDIR variable to 'external'
  52. # so that main Kconfig can find it. Otherwise, we redirect it to a dummy Kconfig
  53. # This is due to kconfig inability to do conditional inclusion.
  54. EXTERNALDIR := $(shell if [ -r $(TOPDIR)/external/Kconfig ]; then echo 'external'; else echo 'dummy'; fi)
  55. # CONTEXTDIRS include directories that have special, one-time pre-build
  56. # requirements. Normally this includes things like auto-generation of
  57. # configuration specific files or creation of configurable symbolic links
  58. # CLEANDIRS are the directories that the clean target will executed in.
  59. # These are all directories that we know about.
  60. # CCLEANDIRS are directories that the clean_context target will execute in.
  61. # The clean_context target "undoes" the actions of the context target.
  62. # Only directories known to require cleaning are included.
  63. # KERNDEPDIRS are the directories in which we will build target dependencies.
  64. # If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED or
  65. # CONFIG_BUILD_KERNEL), then this holds only the directories containing
  66. # kernel files.
  67. # USERDEPDIRS. If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED),
  68. # then this holds only the directories containing user files. If
  69. # CONFIG_BUILD_KERNEL is selected, then applications are not build at all.
  70. include tools/Directories.mk
  71. #
  72. # Extra objects used in the final link.
  73. #
  74. # Pass 1 Incremental (relative) link objects should be put into the
  75. # processor-specific source directory (where other link objects will
  76. # be created). If the pass1 object is an archive, it could go anywhere.
  77. ifeq ($(CONFIG_BUILD_2PASS),y)
  78. EXTRA_OBJS += $(CONFIG_PASS1_OBJECT)
  79. endif
  80. # Library build selections
  81. #
  82. # NUTTXLIBS is the list of NuttX libraries that is passed to the
  83. # processor-specific Makefile to build the final NuttX target.
  84. # USERLIBS is the list of libraries used to build the final user-space
  85. # application
  86. # EXPORTLIBS is the list of libraries that should be exported by
  87. # 'make export' is
  88. ifeq ($(CONFIG_BUILD_PROTECTED),y)
  89. include tools/ProtectedLibs.mk
  90. else ifeq ($(CONFIG_BUILD_KERNEL),y)
  91. include tools/KernelLibs.mk
  92. else
  93. include tools/FlatLibs.mk
  94. endif
  95. # LINKLIBS derives from NUTTXLIBS and is simply the same list with the
  96. # subdirectory removed
  97. LINKLIBS = $(patsubst staging/%,%,$(NUTTXLIBS))
  98. # Export tool definitions
  99. MKEXPORT= tools/mkexport.sh
  100. MKEXPORT_ARGS = -t "$(TOPDIR)" -b "$(BOARD_DIR)"
  101. ifneq ($(CONFIG_BUILD_FLAT),y)
  102. MKEXPORT_ARGS += -u
  103. endif
  104. ifneq ($(APPDIR),)
  105. ifneq ($(shell [ -e $(APPDIR)/Makefile ] && echo yes),)
  106. MKEXPORT_ARGS += -a "$(APPDIR)"
  107. MKEXPORT_ARGS += -m "$(MAKE)"
  108. endif
  109. endif
  110. ifeq ($(V),2)
  111. MKEXPORT_ARGS += -d
  112. endif
  113. # This is the name of the final target (relative to the top level directory)
  114. BIN = nuttx$(EXEEXT)
  115. all: $(BIN)
  116. .PHONY: dirlinks context clean_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
  117. .PHONY: pass1 pass1dep
  118. .PHONY: pass2 pass2dep
  119. # Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
  120. # defined, then there is an architecture specific math.h header file
  121. # that will be included indirectly from include/math.h. But first, we
  122. # have to copy math.h from include/nuttx/. to include/. Logic within
  123. # include/nuttx/lib/math.h will hand the redirection to the architecture-
  124. # specific math.h header file.
  125. #
  126. # If the CONFIG_LIBM is defined, the Rhombus libm will be built at libc/math.
  127. # Definitions and prototypes for the Rhombus libm are also contained in
  128. # include/nuttx/lib/math.h and so the file must also be copied in that case.
  129. #
  130. # If neither CONFIG_ARCH_MATH_H nor CONFIG_LIBM is defined, then no math.h
  131. # header file will be provided. You would want that behavior if (1) you
  132. # don't use libm, or (2) you want to use the math.h and libm provided
  133. # within your toolchain.
  134. ifeq ($(CONFIG_ARCH_MATH_H),y)
  135. NEED_MATH_H = y
  136. else ifeq ($(CONFIG_LIBM),y)
  137. NEED_MATH_H = y
  138. endif
  139. ifeq ($(NEED_MATH_H),y)
  140. include/math.h: include/nuttx/lib/math.h .clean_context
  141. $(Q) cp -f include/nuttx/lib/math.h include/math.h
  142. else
  143. include/math.h:
  144. endif
  145. # The float.h header file defines the properties of your floating point
  146. # implementation. It would always be best to use your toolchain's float.h
  147. # header file but if none is available, a default float.h header file will
  148. # provided if this option is selected. However there is no assurance that
  149. # the settings in this float.h are actually correct for your platform!
  150. ifeq ($(CONFIG_ARCH_FLOAT_H),y)
  151. include/float.h: include/nuttx/lib/float.h .clean_context
  152. $(Q) cp -f include/nuttx/lib/float.h include/float.h
  153. else
  154. include/float.h:
  155. endif
  156. # Target used to copy include/nuttx/lib/stdarg.h. If CONFIG_ARCH_STDARG_H is
  157. # defined, then there is an architecture specific stdarg.h header file
  158. # that will be included indirectly from include/lib/stdarg.h. But first, we
  159. # have to copy stdarg.h from include/nuttx/. to include/.
  160. ifeq ($(CONFIG_ARCH_STDARG_H),y)
  161. include/stdarg.h: include/nuttx/lib/stdarg.h .clean_context
  162. $(Q) cp -f include/nuttx/lib/stdarg.h include/stdarg.h
  163. else
  164. include/stdarg.h:
  165. endif
  166. # Target used to copy include/nuttx/lib/setjmp.h. If CONFIG_ARCH_SETJMP_H is
  167. # defined, then there is an architecture specific setjmp.h header file
  168. # that will be included indirectly from include/lib/setjmp.h. But first, we
  169. # have to copy setjmp.h from include/nuttx/. to include/.
  170. ifeq ($(CONFIG_ARCH_SETJMP_H),y)
  171. include/setjmp.h: include/nuttx/lib/setjmp.h .clean_context
  172. $(Q) cp -f include/nuttx/lib/setjmp.h include/setjmp.h
  173. else
  174. include/setjmp.h:
  175. endif
  176. # Targets used to build include/nuttx/version.h. Creation of version.h is
  177. # part of the overall NuttX configuration sequence. Notice that the
  178. # tools/mkversion tool is built and used to create include/nuttx/version.h
  179. tools/mkversion$(HOSTEXEEXT):
  180. $(Q) $(MAKE) -C tools -f Makefile.host mkversion$(HOSTEXEEXT)
  181. # [Re-]create .version if it doesn't already exist.
  182. $(TOPDIR)/.version:
  183. $(Q) echo "Create .version"
  184. $(Q) tools/version.sh $(VERSION_ARG) .version
  185. $(Q) chmod 755 .version
  186. include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT) .clean_context
  187. $(Q) echo "Create version.h"
  188. $(Q) tools/mkversion $(TOPDIR) > $@.tmp
  189. $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
  190. # Targets used to build include/nuttx/config.h. Creation of config.h is
  191. # part of the overall NuttX configuration sequence. Notice that the
  192. # tools/mkconfig tool is built and used to create include/nuttx/config.h
  193. tools/mkconfig$(HOSTEXEEXT):
  194. $(Q) $(MAKE) -C tools -f Makefile.host mkconfig$(HOSTEXEEXT)
  195. include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT) .clean_context
  196. $(Q) tools/mkconfig $(TOPDIR) > $@.tmp
  197. $(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
  198. # Targets used to create dependencies
  199. tools/mkdeps$(HOSTEXEEXT):
  200. $(Q) $(MAKE) -C tools -f Makefile.host mkdeps$(HOSTEXEEXT)
  201. tools/cnvwindeps$(HOSTEXEEXT):
  202. $(Q) $(MAKE) -C tools -f Makefile.host cnvwindeps$(HOSTEXEEXT)
  203. # dirlinks, and helpers
  204. #
  205. # Directories links. Most of establishing the NuttX configuration involves
  206. # setting up symbolic links with 'generic' directory names to specific,
  207. # configured directories.
  208. # Link the arch/<arch-name>/include directory to include/arch
  209. include/arch: .clean_context
  210. @echo "LN: include/arch to $(ARCH_DIR)/include"
  211. $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_DIR)/include include/arch
  212. $(Q) touch $@
  213. # Link the boards/<arch>/<chip>/<board>/include directory to include/arch/board
  214. include/arch/board: include/arch
  215. @echo "LN: include/arch/board to $(BOARD_DIR)/include"
  216. $(Q) $(DIRLINK) $(BOARD_DIR)/include include/arch/board
  217. $(Q) touch $@
  218. ifneq ($(BOARD_COMMON_DIR),)
  219. # Link the boards/<arch>/<chip>/common dir to arch/<arch-name>/src/board
  220. # Link the boards/<arch>/<chip>/<board>/src dir to arch/<arch-name>/src/board/board
  221. $(ARCH_SRC)/board: .clean_context
  222. @echo "LN: $(ARCH_SRC)/board to $(BOARD_COMMON_DIR)"
  223. $(Q) $(DIRLINK) $(BOARD_COMMON_DIR) $(ARCH_SRC)/board
  224. @echo "LN: $(ARCH_SRC)/board/board to $(BOARD_DIR)/src"
  225. $(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board/board
  226. $(Q) touch $@
  227. else
  228. # Link the boards/<arch>/<chip>/<board>/src dir to arch/<arch-name>/src/board
  229. $(ARCH_SRC)/board: .clean_context
  230. @echo "LN: $(ARCH_SRC)/board to $(BOARD_DIR)/src"
  231. $(Q) $(DIRLINK) $(BOARD_DIR)/src $(ARCH_SRC)/board
  232. $(Q) touch $@
  233. endif
  234. # Link the boards/<arch>/<chip>/drivers dir to drivers/platform
  235. drivers/platform: .clean_context
  236. @echo "LN: $(TOPDIR)/drivers/platform to $(BOARD_DRIVERS_DIR)"
  237. $(Q) $(DIRLINK) $(BOARD_DRIVERS_DIR) $(TOPDIR)/drivers/platform
  238. $(Q) touch $@
  239. # Link arch/<arch-name>/src/<chip-name> to arch/<arch-name>/src/chip
  240. $(ARCH_SRC)/chip: .clean_context
  241. ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
  242. @echo "LN: $(ARCH_SRC)/chip to $(CHIP_DIR)"
  243. $(Q) $(DIRLINK) $(CHIP_DIR) $(ARCH_SRC)/chip
  244. else ifneq ($(CONFIG_ARCH_CHIP),)
  245. @echo "LN: $(ARCH_SRC)/chip to $(ARCH_SRC)/$(CONFIG_ARCH_CHIP)"
  246. $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_SRC)/$(CONFIG_ARCH_CHIP) $(ARCH_SRC)/chip
  247. endif
  248. $(Q) cp -f $(CHIP_KCONFIG) $(TOPDIR)/arch/dummy/Kconfig
  249. $(Q) touch $@
  250. # Link arch/<arch-name>/include/<chip-name> to include/arch/chip
  251. include/arch/chip: include/arch
  252. ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
  253. @echo "LN: include/arch/chip to $(CHIP_DIR)/include"
  254. $(Q) $(DIRLINK) $(CHIP_DIR)/include include/arch/chip
  255. else ifneq ($(CONFIG_ARCH_CHIP),)
  256. @echo "LN: include/arch/chip to $(ARCH_INC)/$(CONFIG_ARCH_CHIP)"
  257. $(Q) $(DIRLINK) $(TOPDIR)/$(ARCH_INC)/$(CONFIG_ARCH_CHIP) include/arch/chip
  258. endif
  259. $(Q) touch $@
  260. dirlinks: include/arch include/arch/board include/arch/chip $(ARCH_SRC)/board $(ARCH_SRC)/chip drivers/platform
  261. $(Q) $(MAKE) -C libs/libxx dirlinks
  262. $(Q) $(MAKE) -C boards dirlinks
  263. $(Q) $(MAKE) -C openamp dirlinks
  264. $(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks
  265. # context
  266. #
  267. # The context target is invoked on each target build to assure that NuttX is
  268. # properly configured. The basic configuration steps include creation of the
  269. # the config.h and version.h header files in the include/nuttx directory and
  270. # the establishment of symbolic links to configured directories.
  271. context: include/nuttx/config.h include/nuttx/version.h include/math.h include/float.h include/stdarg.h include/setjmp.h dirlinks
  272. $(Q) mkdir -p staging
  273. $(Q) for dir in $(CONTEXTDIRS) ; do \
  274. $(MAKE) -C $$dir context || exit; \
  275. done
  276. # clean_context
  277. #
  278. # This is part of the distclean target. It removes all of the header files
  279. # and symbolic links created by the context target.
  280. clean_context:
  281. $(Q) for dir in $(CCLEANDIRS) ; do \
  282. if [ -e $$dir/Makefile ]; then \
  283. $(MAKE) -C $$dir clean_context ; \
  284. fi \
  285. done
  286. $(call DELFILE, include/nuttx/config.h)
  287. $(call DELFILE, include/nuttx/version.h)
  288. $(call DELFILE, include/float.h)
  289. $(call DELFILE, include/math.h)
  290. $(call DELFILE, include/stdarg.h)
  291. $(call DELFILE, include/setjmp.h)
  292. $(call DELFILE, arch/dummy/Kconfig)
  293. $(Q) $(DIRUNLINK) include/arch/board
  294. $(Q) $(DIRUNLINK) include/arch/chip
  295. $(Q) $(DIRUNLINK) include/arch
  296. $(Q) $(DIRUNLINK) $(ARCH_SRC)/board/board
  297. $(Q) $(DIRUNLINK) $(ARCH_SRC)/board
  298. $(Q) $(DIRUNLINK) $(ARCH_SRC)/chip
  299. $(Q) $(DIRUNLINK) $(TOPDIR)/drivers/platform
  300. .clean_context: .config
  301. +$(Q) $(MAKE) clean_context
  302. $(Q) touch $@
  303. # Archive targets. The target build sequence will first create a series of
  304. # libraries, one per configured source file directory. The final NuttX
  305. # execution will then be built from those libraries. The following targets
  306. # build those libraries.
  307. include tools/LibTargets.mk
  308. # pass1 and pass2
  309. #
  310. # If the 2 pass build option is selected, then this pass1 target is
  311. # configured to be built before the pass2 target. This pass1 target may, as an
  312. # example, build an extra link object (CONFIG_PASS1_OBJECT) which may be an
  313. # incremental (relative) link object, but could be a static library (archive);
  314. # some modification to this Makefile would be required if CONFIG_PASS1_OBJECT
  315. # is an archive. Exactly what is performed during pass1 or what it generates
  316. # is unknown to this makefile unless CONFIG_PASS1_OBJECT is defined.
  317. pass1: $(USERLIBS)
  318. pass2: $(NUTTXLIBS)
  319. # $(BIN)
  320. #
  321. # Create the final NuttX executable in a two pass build process. In the
  322. # normal case, all pass1 and pass2 dependencies are created then pass1
  323. # and pass2 targets are built. However, in some cases, you may need to build
  324. # pass1 dependencies and pass1 first, then build pass2 dependencies and pass2.
  325. # in that case, execute 'make pass1 pass2' from the command line.
  326. $(BIN): pass1 pass2
  327. ifeq ($(CONFIG_BUILD_2PASS),y)
  328. $(Q) if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
  329. echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
  330. exit 1; \
  331. fi
  332. $(Q) if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
  333. echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
  334. exit 1; \
  335. fi
  336. $(Q) if [ ! -f "$(CONFIG_PASS1_BUILDIR)/Makefile" ]; then \
  337. echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
  338. exit 1; \
  339. fi
  340. $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
  341. endif
  342. $(Q) $(MAKE) -C $(ARCH_SRC) EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" $(BIN)
  343. $(Q) if [ -w /tftpboot ] ; then \
  344. cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \
  345. fi
  346. $(Q) echo $(BIN) > nuttx.manifest
  347. $(Q) printf "%s\n" *.map >> nuttx.manifest
  348. ifeq ($(CONFIG_INTELHEX_BINARY),y)
  349. @echo "CP: nuttx.hex"
  350. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) nuttx.hex
  351. $(Q) echo nuttx.hex >> nuttx.manifest
  352. endif
  353. ifeq ($(CONFIG_MOTOROLA_SREC),y)
  354. @echo "CP: nuttx.srec"
  355. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) nuttx.srec
  356. $(Q) echo nuttx.srec >> nuttx.manifest
  357. endif
  358. ifeq ($(CONFIG_RAW_BINARY),y)
  359. @echo "CP: nuttx.bin"
  360. $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) nuttx.bin
  361. $(Q) echo nuttx.bin >> nuttx.manifest
  362. endif
  363. ifeq ($(CONFIG_UBOOT_UIMAGE),y)
  364. @echo "MKIMAGE: uImage"
  365. $(Q) mkimage -A $(CONFIG_ARCH) -O linux -C none -T kernel -a $(CONFIG_UIMAGE_LOAD_ADDRESS) \
  366. -e $(CONFIG_UIMAGE_ENTRY_POINT) -n $(BIN) -d nuttx.bin uImage
  367. $(Q) if [ -w /tftpboot ] ; then \
  368. cp -f uImage /tftpboot/uImage; \
  369. fi
  370. $(Q) echo "uImage" >> nuttx.manifest
  371. endif
  372. $(call POSTBUILD, $(TOPDIR))
  373. # download
  374. #
  375. # This is a helper target that will rebuild NuttX and download it to the target
  376. # system in one step. The operation of this target depends completely upon
  377. # implementation of the DOWNLOAD command in the user Make.defs file. It will
  378. # generate an error if the DOWNLOAD command is not defined.
  379. download: $(BIN)
  380. $(call DOWNLOAD, $<)
  381. # pass1dep: Create pass1 build dependencies
  382. # pass2dep: Create pass2 build dependencies
  383. pass1dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
  384. $(Q) for dir in $(USERDEPDIRS) ; do \
  385. $(MAKE) -C $$dir depend || exit; \
  386. done
  387. pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
  388. $(Q) for dir in $(KERNDEPDIRS) ; do \
  389. $(MAKE) -C $$dir EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend || exit; \
  390. done
  391. # Configuration targets
  392. #
  393. # These targets depend on the kconfig-frontends packages. To use these, you
  394. # must first download and install the kconfig-frontends package from this
  395. # location: https://bitbucket.org/nuttx/tools/downloads/. See README.txt
  396. # file in the NuttX tools GIT repository for additional information.
  397. config: apps_preconfig
  398. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf Kconfig
  399. oldconfig: apps_preconfig
  400. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --oldconfig Kconfig
  401. olddefconfig: apps_preconfig
  402. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --olddefconfig Kconfig
  403. menuconfig: apps_preconfig
  404. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-mconf Kconfig
  405. nconfig: apps_preconfig
  406. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-nconf Kconfig
  407. qconfig: apps_preconfig
  408. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-qconf Kconfig
  409. gconfig: apps_preconfig
  410. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-gconf Kconfig
  411. savedefconfig: apps_preconfig
  412. $(Q) APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR) kconfig-conf --savedefconfig defconfig.tmp Kconfig
  413. $(Q) kconfig-tweak --file defconfig.tmp -u CONFIG_APPS_DIR
  414. $(Q) grep "CONFIG_ARCH=" .config >> defconfig.tmp
  415. $(Q) grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp; true
  416. $(Q) grep "CONFIG_ARCH_CHIP=" .config >> defconfig.tmp; true
  417. $(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig.tmp; true
  418. $(Q) grep "^CONFIG_ARCH_CUSTOM" .config >> defconfig.tmp; true
  419. $(Q) grep "^CONFIG_ARCH_BOARD_CUSTOM" .config >> defconfig.tmp; true
  420. $(Q) export LC_ALL=C; cat defconfig.tmp | sort | uniq > sortedconfig.tmp
  421. $(Q) echo "#" > warning.tmp
  422. $(Q) echo "# This file is autogenerated: PLEASE DO NOT EDIT IT." >> warning.tmp
  423. $(Q) echo "#" >> warning.tmp
  424. $(Q) echo "# You can use \"make menuconfig\" to make any modifications to the installed .config file." >> warning.tmp
  425. $(Q) echo "# You can then do \"make savedefconfig\" to generate a new defconfig file that includes your" >> warning.tmp
  426. $(Q) echo "# modifications." >> warning.tmp
  427. $(Q) echo "#" >> warning.tmp
  428. $(Q) cat warning.tmp sortedconfig.tmp > defconfig
  429. $(Q) rm -f warning.tmp
  430. $(Q) rm -f defconfig.tmp
  431. $(Q) rm -f sortedconfig.tmp
  432. # export
  433. #
  434. # The export target will package the NuttX libraries and header files into
  435. # an exportable package. Caveats: (1) These needs some extension for the KERNEL
  436. # build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
  437. # in tools/mkexport.sh only supports GCC and, for example, explicitly assumes
  438. # that the archiver is 'ar'
  439. export: $(NUTTXLIBS)
  440. $(Q) MAKE=${MAKE} $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)"
  441. # General housekeeping targets: dependencies, cleaning, etc.
  442. #
  443. # depend: Create both PASS1 and PASS2 dependencies
  444. # clean: Removes derived object files, archives, executables, and
  445. # temporary files, but retains the configuration and context
  446. # files and directories.
  447. # distclean: Does 'clean' then also removes all configuration and context
  448. # files. This essentially restores the directory structure
  449. # to its original, unconfigured stated.
  450. depend: pass1dep pass2dep
  451. $(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
  452. subdir_clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
  453. ifeq ($(CONFIG_BUILD_2PASS),y)
  454. $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) clean
  455. endif
  456. clean: subdir_clean
  457. $(call DELFILE, $(BIN))
  458. $(call DELFILE, nuttx.*)
  459. $(call DELFILE, *.map)
  460. $(call DELFILE, _SAVED_APPS_config)
  461. $(call DELFILE, nuttx-export*.zip)
  462. $(call DELDIR, nuttx-export*)
  463. $(call DELFILE, nuttx_user*)
  464. $(call DELDIR, staging)
  465. $(call DELFILE, uImage)
  466. $(call CLEAN)
  467. $(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
  468. subdir_distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
  469. distclean: clean subdir_distclean clean_context
  470. ifeq ($(CONFIG_BUILD_2PASS),y)
  471. $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) distclean
  472. endif
  473. $(call DELFILE, Make.defs)
  474. $(call DELFILE, defconfig)
  475. $(call DELFILE, .config)
  476. $(call DELFILE, .config.old)
  477. $(call DELFILE, .gdbinit)
  478. $(call DELFILE, .clean_context)
  479. $(Q) $(MAKE) -C tools -f Makefile.host clean
  480. # Application housekeeping targets. The APPDIR variable refers to the user
  481. # application directory. A sample apps/ directory is included with NuttX,
  482. # however, this is not treated as part of NuttX and may be replaced with a
  483. # different application directory. For the most part, the application
  484. # directory is treated like any other build directory in this script. However,
  485. # as a convenience, the following targets are included to support housekeeping
  486. # functions in the user application directory from the NuttX build directory.
  487. #
  488. # apps_preconfig: Prepare applications to be configured
  489. # apps_clean: Perform the clean operation only in the user application
  490. # directory
  491. # apps_distclean: Perform the distclean operation only in the user application
  492. # directory.
  493. apps_preconfig: dirlinks
  494. ifneq ($(APPDIR),)
  495. $(Q) $(MAKE) -C $(APPDIR) preconfig
  496. endif
  497. apps_clean:
  498. ifneq ($(APPDIR),)
  499. $(Q) $(MAKE) -C $(APPDIR) clean
  500. endif
  501. apps_distclean:
  502. ifneq ($(APPDIR),)
  503. $(Q) $(MAKE) -C $(APPDIR) distclean
  504. endif