Makefile.unix 21 KB

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