buildsystem.rst 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. .. _develop_buildsystem:
  2. Build System based on Makefile
  3. ==============================
  4. Nuclei SDK's build system is based on Makefile, user can build,
  5. run ordebug application in Windows and Linux.
  6. .. _develop_buildsystem_structure:
  7. Makefile Structure
  8. ------------------
  9. Nuclei SDK's Makefiles mainly placed in **<NUCLEI_SDK_ROOT>/Build** directory and
  10. an extra *Makefile* located in **<NUCLEI_SDK_ROOT>/Makefile**.
  11. This extra **<NUCLEI_SDK_ROOT>/Makefile** introduce a new Make variable called
  12. **PROGRAM** to provide the ability to build or run application in **<NUCLEI_SDK_ROOT>**.
  13. For example, if you want to *rebuild and upload* application **application/baremetal/timer_test**,
  14. you can run ``make PROGRAM=application/baremetal/timer_test clean upload`` to achieve it.
  15. The **<NUCLEI_SDK_ROOT>/Build** directory content list as below:
  16. .. code-block:: text
  17. gmsl/
  18. Makefile.base
  19. Makefile.conf
  20. Makefile.core
  21. Makefile.files
  22. Makefile.files.gd32vf103
  23. Makefile.files.hbird
  24. Makefile.global -> Created by user
  25. Makefile.misc
  26. Makefile.rtos
  27. Makefile.rtos.FreeRTOS
  28. Makefile.rtos.UCOSII
  29. Makefile.rules
  30. Makefile.soc
  31. Makefile.soc.gd32vf103
  32. Makefile.soc.hbird
  33. The file or directory is used explained as below:
  34. .. _develop_buildsystem_makefile_base:
  35. Makefile.base
  36. ~~~~~~~~~~~~~
  37. This **Makefile.base** file is used as Nuclei SDK build system entry file,
  38. application's Makefile need to include this file to use all the features of
  39. Nuclei SDK build system.
  40. It will expose Make variables or options such as **BOARD** or **SOC** passed
  41. by ``make`` command, click :ref:`develop_buildsystem_exposed_make_vars`
  42. to learn more.
  43. This file will include optional :ref:`develop_buildsystem_makefile_global`
  44. and :ref:`develop_buildsystem_makefile_local` which allow user to set custom
  45. global Makefile configurations and local application Makefile configurations.
  46. This file will include the following makefiles:
  47. * :ref:`develop_buildsystem_gmsl`: additional library functions provided via gmsl
  48. * :ref:`develop_buildsystem_makefile_misc`: misc functions and OS check helpers
  49. * :ref:`develop_buildsystem_makefile_conf`: main Makefile configuration entry
  50. * :ref:`develop_buildsystem_makefile_rules`: make rules of this build system
  51. .. _develop_buildsystem_gmsl:
  52. gmsl
  53. ~~~~
  54. The **gmsl** directory consist of the `GNU Make Standard Library (GMSL)`_,
  55. which is an a library of functions to be used with GNU Make's $(call) that
  56. provides functionality not available in standard GNU Make.
  57. We use this **gmsl** tool to make sure we help us achieve some linux command
  58. which is only supported in Linux.
  59. .. _develop_buildsystem_makefile_misc:
  60. Makefile.misc
  61. ~~~~~~~~~~~~~
  62. This **Makefile.misc** file mainly provide these functions:
  63. * Define **get_csrcs**, **get_asmsrcs**, **get_cxxsrcs** and **check_item_exist** make functions
  64. - **get_csrcs**: Function to get ``*.c or *.C`` source files from a list of directories, no ability to
  65. do recursive match. e.g. ``$(call get_csrcs, csrc csrc/abc)`` will return c source files in
  66. ``csrc`` and ``csrc/abc`` directories.
  67. - **get_asmsrcs**: Function to get ``*.s or *.S`` source files from a list of directories, no ability to
  68. do recursive match. e.g. ``$(call get_asmsrcs, asmsrc asmsrc/abc)`` will return asm source files in
  69. ``asmsrc`` and ``asmsrc/abc`` directories.
  70. - **get_cxxsrcs**: Function to get ``*.cpp or *.CPP`` source files from a list of directories, no ability
  71. to do recursive match. e.g. ``$(call get_cxxsrcs, cppsrc cppsrc/abc)`` will return cpp source files in
  72. ``cppsrc`` and ``cppsrc/abc`` directories.
  73. - **check_item_exist**: Function to check if item existed in a set of items. e.g.
  74. ``$(call check_item_exist, flash, flash ilm flashxip)`` will check ``flash`` whether existed in
  75. ``flash ilm flashxip``, if existed, return ``flash``, otherwise return empty.
  76. * Check and define OS related functions, and also a set of trace print functions.
  77. .. _develop_buildsystem_makefile_conf:
  78. Makefile.conf
  79. ~~~~~~~~~~~~~
  80. This **Makefile.conf** file will define the following items:
  81. * Toolchain related variables used during compiling
  82. * Debug related variables
  83. * Include :ref:`develop_buildsystem_makefile_files` and :ref:`develop_buildsystem_makefile_rtos`
  84. * Collect all the C/C++/ASM compiling and link options
  85. .. _develop_buildsystem_makefile_rules:
  86. Makefile.rules
  87. ~~~~~~~~~~~~~~
  88. This **Makefile.rules** file will do the following things:
  89. * Collect all the sources during compiling
  90. * Define all the rules used for building, uploading and debugging
  91. * Print help message for build system
  92. .. _develop_buildsystem_makefile_files:
  93. Makefile.files
  94. ~~~~~~~~~~~~~~
  95. This **Makefile.files** file will do the following things:
  96. * Define common C/C++/ASM source and include directories
  97. * Define common C/C++/ASM macros
  98. * Include **Makefile.files.<SOC>** which will include all the source
  99. code related to the :ref:`develop_buildsystem_var_soc` and
  100. :ref:`develop_buildsystem_var_board`
  101. - **Makefile.files.gd32vf103**: Used to include source code for
  102. :ref:`design_soc_gd32vf103`
  103. - **Makefile.files.hbird**: Used to include source code for
  104. :ref:`design_soc_hbird`
  105. .. _develop_buildsystem_makefile_soc:
  106. Makefile.soc
  107. ~~~~~~~~~~~~
  108. This **Makefile.soc** will just include **Makefile.soc.<SOC>** according
  109. to the :ref:`develop_buildsystem_var_soc` makefile variable setting.
  110. It will define the following items:
  111. * **DOWNLOAD** and **CORE** variables
  112. - For :ref:`design_soc_hbird`, we can support all the modes defined in
  113. :ref:`develop_buildsystem_var_download`, and **CORE** list defined in
  114. :ref:`develop_buildsystem_makefile_core`
  115. - For :ref:`design_soc_gd32vf103`, The **CORE** is fixed to N205, since
  116. it is a real SoC chip, and only **FlashXIP** download mode is supported
  117. * Linker script used according to the **DOWNLOAD** mode settings
  118. * OpenOCD debug configuration file used for the SoC and Board
  119. * Some extra compiling or debugging options
  120. .. _develop_buildsystem_makefile_rtos:
  121. Makefile.rtos
  122. ~~~~~~~~~~~~~
  123. This **Makefile.rtos** will include **Makefile.rtos.<RTOS>** file
  124. according to our :ref:`develop_buildsystem_var_rtos` variable.
  125. If no :ref:`develop_buildsystem_var_rtos` is chosen, then RTOS
  126. code will not be included during compiling, user will develop
  127. baremetal application.
  128. If **FreeRTOS** or **UCOSII** RTOS is chosen, then FreeRTOS or UCOSII
  129. source code will be included during compiling, and user can develop
  130. RTOS application.
  131. * **Makefile.rtos.FreeRTOS**: Include FreeRTOS related source code and header
  132. directories
  133. * **Makefile.rtos.UCOSII**: Include UCOSII related source code and header
  134. directories
  135. .. _develop_buildsystem_makefile_core:
  136. Makefile.core
  137. ~~~~~~~~~~~~~
  138. This **Makefile.core** is used to define the RISC-V ARCH and ABI used during
  139. compiling of the CORE list supported.
  140. If you want to add a new **CORE**, you need to add a new line before **SUPPORTED_CORES**,
  141. and append the new **CORE** to **SUPPORTED_CORES**.
  142. For example, if you want to add a new **CORE** called **n308**, and the **n308**'s
  143. **ARCH** and **ABI** are ``rv32imafdc`` and ``ilp32d``, then you can add a new line
  144. like this ``N308_CORE_ARCH_ABI = rv32imafdc ilp32d``, and append **n308** to **SUPPORTED_CORES**
  145. like this ``SUPPORTED_CORES = n201 n201e n203 n203e n205 n205e n305 n307 n307fd n308 nx600``
  146. .. note::
  147. * The appended new **CORE** need to lower-case, e.g. *n308*
  148. * The new defined variable **N308_CORE_ARCH_ABI** need to be all upper-case.
  149. .. _develop_buildsystem_makefile_global:
  150. Makefile.global
  151. ~~~~~~~~~~~~~~~
  152. This **Makefile.global** file is an optional file, and will not be tracked by git,
  153. user can create own **Makefile.global** in **<NUCLEI_SDK_ROOT>/Build** directory.
  154. In this file, user can define custom **SOC**, **BOARD**, **DOWNLOAD** options to
  155. overwrite the default configuration.
  156. For example, if you will use only the :ref:`design_board_gd32vf103v_rvstar`, you can
  157. create the **<NUCLEI_SDK_ROOT>/Build/Makefile.global** as below:
  158. .. code-block:: Makefile
  159. SOC ?= gd32vf103
  160. BOARD ?= gd32vf103v_rvstar
  161. DOWNLOAD ?= flashxip
  162. .. note::
  163. * If you add above file, then you can build, run, debug application without passing
  164. **SOC**, **BOARD** and **DOWNLOAD** variables using make command for
  165. :ref:`design_board_gd32vf103v_rvstar` board, e.g.
  166. - Build and run application for :ref:`design_board_gd32vf103v_rvstar`: ``make run``
  167. - Debug application for :ref:`design_board_gd32vf103v_rvstar`: ``make debug``
  168. * The :ref:`design_board_gd32vf103v_rvstar` only support ``FlashXIP`` download mode.
  169. * If you create the **Makefile.global** like above sample code, you will also be able
  170. to use Nuclei SDK build system as usually, it will only change the default **SOC**,
  171. **BOARD** and **DOWNLOAD**, but you can still override the default variable using
  172. make command, such as ``make SOC=hbird BOARD=hbird_eval DOWNLOAD=ilm``
  173. .. _develop_buildsystem_makefile_local:
  174. Makefile.local
  175. ~~~~~~~~~~~~~~
  176. As the :ref:`develop_buildsystem_makefile_global` is used to override the default Makefile
  177. configurations, and the **Makefile.local** is used to override application level Makefile
  178. configurations, and also this file will not be tracked by git.
  179. User can create ``Makefile.local`` file in any of the application folder, placed together with
  180. the application Makefile, for example, you can create ``Makefile.local`` in ``application/baremetal/helloworld``
  181. to override default make configuration for this **helloworld** application.
  182. If you want to change the default board for **helloworld** to use :ref:`design_board_gd32vf103v_rvstar`,
  183. you can create ``application/baremetal/helloworld/Makefile.local`` as below:
  184. .. code-block:: Makefile
  185. SOC ?= gd32vf103
  186. BOARD ?= gd32vf103v_rvstar
  187. DOWNLOAD ?= flashxip
  188. .. note::
  189. * This local make configuration will override global and default make configuration.
  190. * If you just want to change only some applications' makefile configuration, you can
  191. add and update ``Makefile.local`` for those applications.
  192. .. _develop_buildsystem_make_targets:
  193. Makefile targets of make command
  194. --------------------------------
  195. Here is a list of the :ref:`table_dev_buildsystem_4`.
  196. .. _table_dev_buildsystem_4:
  197. .. list-table:: Make targets supported by Nuclei SDK Build System
  198. :widths: 20 80
  199. :header-rows: 1
  200. :align: center
  201. * - target
  202. - description
  203. * - help
  204. - display help message of Nuclei SDK build system
  205. * - info
  206. - display selected configuration information
  207. * - all
  208. - build application with selected configuration
  209. * - clean
  210. - clean application with selected configuration
  211. * - dasm
  212. - build and dissemble application with selected configuration
  213. * - bin
  214. - build and generate application binary with selected configuration
  215. * - upload
  216. - build and upload application with selected configuration
  217. * - run_openocd
  218. - run openocd server with selected configuration
  219. * - run_gdb
  220. - build and start gdb process with selected configuration
  221. * - debug
  222. - build and debug application with selected configuration
  223. .. note::
  224. * The selected configuration is controlled by
  225. :ref:`develop_buildsystem_exposed_make_vars`
  226. .. _develop_buildsystem_exposed_make_vars:
  227. Makefile variables passed by make command
  228. -----------------------------------------
  229. In Nuclei SDK build system, we exposed the following Makefile variables
  230. which can be passed via make command.
  231. * :ref:`develop_buildsystem_var_soc`
  232. * :ref:`develop_buildsystem_var_board`
  233. * :ref:`develop_buildsystem_var_download`
  234. * :ref:`develop_buildsystem_var_core`
  235. * :ref:`develop_buildsystem_var_simulation`
  236. * :ref:`develop_buildsystem_var_v`
  237. * :ref:`develop_buildsystem_var_silent`
  238. .. note::
  239. * These variables can also be used and defined in application Makefile
  240. * If you just want to fix your running board of your application, you can
  241. just define these variables in application Makefile, if defined, then
  242. you can simply use ``make clean``, ``make upload`` or ``make debug``, etc.
  243. .. _develop_buildsystem_var_soc:
  244. SOC
  245. ~~~
  246. **SOC** variable is used to declare which SoC is used in application during compiling.
  247. You can easily find the supported SoCs in the **<NUCLEI_SDK_ROOT>/SoC** directory.
  248. Currently we support the following SoCs, see :ref:`table_dev_buildsystem_1`.
  249. .. _table_dev_buildsystem_1:
  250. .. list-table:: Supported SoCs
  251. :widths: 10, 60
  252. :header-rows: 1
  253. :align: center
  254. * - **SOC**
  255. - Reference
  256. * - gd32vf103
  257. - :ref:`design_soc_gd32vf103`
  258. * - hbird
  259. - :ref:`design_soc_hbird`
  260. .. _develop_buildsystem_var_board:
  261. BOARD
  262. ~~~~~
  263. **Board** variable is used to declare which Board is used in application during compiling.
  264. The **BOARD** variable should match the supported boards of chosen **SOC**.
  265. You can easily find the supported Boards in the **<NUCLEI_SDK_ROOT>/<SOC>/Board/** directory.
  266. * :ref:`table_dev_buildsystem_2`
  267. * :ref:`table_dev_buildsystem_3`
  268. Currently we support the following SoCs.
  269. .. _table_dev_buildsystem_2:
  270. .. list-table:: Supported Boards when SOC=gd32vf103
  271. :widths: 20, 60
  272. :header-rows: 1
  273. :align: center
  274. * - **BOARD**
  275. - Reference
  276. * - gd32vf103v_rvstar
  277. - :ref:`design_board_gd32vf103v_rvstar`
  278. * - gd32vf103v_eval
  279. - :ref:`design_board_gd32vf103v_eval`
  280. .. _table_dev_buildsystem_3:
  281. .. list-table:: Supported Boards when SOC=hbird
  282. :widths: 10 60
  283. :header-rows: 1
  284. :align: center
  285. * - **BOARD**
  286. - Reference
  287. * - hbird_eval
  288. - :ref:`design_board_hbird_eval`
  289. .. note::
  290. * If you only specify **SOC** variable in make command, it will use default **BOARD**
  291. and **CORE** option defined in Makefile.soc.<SOC>
  292. .. _develop_buildsystem_var_download:
  293. DOWNLOAD
  294. ~~~~~~~~
  295. **DOWNLOAD** variable is used to declare the download mode of the application,
  296. currently it has these modes supported as described in table
  297. :ref:`table_dev_buildsystem_5`
  298. .. _table_dev_buildsystem_5:
  299. .. list-table:: Supported download modes
  300. :widths: 10 70
  301. :header-rows: 1
  302. :align: center
  303. * - **DOWNLOAD**
  304. - Description
  305. * - ilm
  306. - | Program will be download into ilm/ram and
  307. | run directly in ilm/ram, program lost when poweroff
  308. * - flash
  309. - | Program will be download into flash, when running,
  310. | program will be copied to ilm/ram and run in ilm/ram
  311. * - flashxip
  312. - Program will to be download into flash and run directly in Flash
  313. .. note::
  314. * :ref:`design_soc_gd32vf103` only support **DOWNLOAD=flashxip**
  315. * :ref:`design_soc_hbird` support all the download modes.
  316. * **flashxip** mode in :ref:`design_soc_hbird` is very slow due to
  317. the CORE frequency is very slow, and Flash speed is slow
  318. .. _develop_buildsystem_var_core:
  319. CORE
  320. ~~~~
  321. **CORE** variable is used to declare the Nuclei processor core
  322. of the application.
  323. Currently it has these cores supported as described in table
  324. :ref:`table_dev_buildsystem_6`.
  325. .. _table_dev_buildsystem_6:
  326. .. table:: Supported Nuclei Processor cores
  327. :widths: 20 20 20
  328. :align: center
  329. ======== ========== =======
  330. **CORE** **ARCH** **ABI**
  331. n201 rv32iac ilp32
  332. n201e rv32eac ilp32e
  333. n203 rv32imac ilp32
  334. n203e rv32emac ilp32e
  335. n205 rv32imac ilp32
  336. n205e rv32emac ilp32e
  337. n305 rv32imac ilp32
  338. n307 rv32imafc ilp32f
  339. n307fd rv32imafdc ilp32d
  340. nx600 rv64imac lp64
  341. ======== ========== =======
  342. .. _develop_buildsystem_var_simulation:
  343. SIMULATION
  344. ~~~~~~~~~~
  345. If **SIMULATION=1**, it means the program is optimized for hardware simulation environment.
  346. Currently if **SIMULATION=1**, it will pass compile option **-DCFG_SIMULATION**,
  347. application can use this **CFG_SIMULATION** to optimize program for hardware
  348. simulation environment.
  349. .. note::
  350. * Currently the benchmark applications in **application/baremetal/benchmark** used this optimization
  351. .. _develop_buildsystem_var_v:
  352. V
  353. ~
  354. If **V=1**, it will display compiling message in verbose including compiling options.
  355. By default, no compiling options will be displayed in make console message just to print
  356. less message and make the console message cleaner. If you want to see what compiling option
  357. is used, please pass **V=1** in your make command.
  358. .. _develop_buildsystem_var_silent:
  359. SILENT
  360. ~~~~~~
  361. If **SILENT=1**, it will not display any compiling messsage.
  362. If you don't want to see any compiling message, you can pass **SILENT=1** in your make command.
  363. .. _develop_buildsystem_app_make_vars:
  364. Makefile variables used only in Application Makefile
  365. ----------------------------------------------------
  366. The following variables should be used in application Makefile at your demand,
  367. e.g. ``application/baremetal/timer_test/Makefile``.
  368. * :ref:`develop_buildsystem_var_target`
  369. * :ref:`develop_buildsystem_var_nuclei_sdk_root`
  370. * :ref:`develop_buildsystem_var_rtos`
  371. * :ref:`develop_buildsystem_var_pfloat`
  372. * :ref:`develop_buildsystem_var_newlib`
  373. * :ref:`develop_buildsystem_var_nogc`
  374. .. _develop_buildsystem_var_target:
  375. TARGET
  376. ~~~~~~
  377. This is a necessary variable which must be defined in application Makefile.
  378. It is used to set the name of the application, it will affect the generated
  379. target filenames.
  380. .. _develop_buildsystem_var_nuclei_sdk_root:
  381. NUCLEI_SDK_ROOT
  382. ~~~~~~~~~~~~~~~
  383. This is a necessary variable which must be defined in application Makefile.
  384. It is used to set the path of Nuclei SDK Root, usually it should be set as
  385. relative path, but you can also set absolute path to point to Nuclei SDK.
  386. .. _develop_buildsystem_var_rtos:
  387. RTOS
  388. ~~~~
  389. **RTOS** variable is used to choose which RTOS will be used in this application.
  390. You can easily find the supported RTOSes in the **<NUCLEI_SDK_ROOT>/OS** directory.
  391. * If **RTOS** is not defined, then baremetal service will be enabled with this application.
  392. See examples in ``application/baremetal``.
  393. * If **RTOS** is set the the following values, RTOS service will be enabled with this application.
  394. - ``FreeRTOS``: FreeRTOS service will be enabled, you can include FreeRTOS header files now, and
  395. use FreeRTOS API, for ``FreeRTOS`` application, you need to have an ``FreeRTOSConfig.h`` header file
  396. prepared in you application. See examples in ``application/freertos``.
  397. - ``UCOSII``: UCOSII service will be enabled, you can include UCOSII header files now, and
  398. use UCOSII API, for ``UCOSII`` application, you need to have an ``app_cfg.h`` header file
  399. prepared in you application. See examples in ``application/ucosii``.
  400. .. _develop_buildsystem_var_pfloat:
  401. PFLOAT
  402. ~~~~~~
  403. **PFLOAT** variable is used to enable floating point value print when using the newlib nano(**NEWLIB=nano**).
  404. If you don't use newlib nano, this variable will have no affect.
  405. .. _develop_buildsystem_var_newlib:
  406. NEWLIB
  407. ~~~~~~
  408. **NEWLIB** variable is used to select which newlib version will be chosen.
  409. If **NEWLIB=nano**, then newlib nano will be selected. About newlib, please
  410. visit https://sourceware.org/newlib/README.
  411. If **NEWLIB=**, then normal newlib will be used.
  412. .. _develop_buildsystem_var_nogc:
  413. NOGC
  414. ~~~~
  415. **NOGC** variable is used to control whether to enable gc sections to reduce program
  416. code size or not, by default GC is enabled to reduce code size.
  417. When GC is enabled, these options will be added:
  418. * Adding to compiler options: ``-ffunction-sections -fdata-sections``
  419. * Adding to linker options: ``-Wl,--gc-sections -Wl,--check-sections``
  420. If you don't want disable this GC feature, you can set **NOGC=1**, GC feature will
  421. remove sections for you, but sometimes it might remove sections that are useful,
  422. e.g. For Nuclei SDK test cases, we use ctest framework, and we need to set **NOGC=1**
  423. to disable GC feature.
  424. .. _develop_buildsystem_app_build_vars:
  425. Build Related Makefile variables used only in Application Makefile
  426. ------------------------------------------------------------------
  427. If you want to specify additional compiler flags, please follow this guidance
  428. to modify your application Makefile.
  429. Nuclei SDK build system defined the following variables to control the
  430. build options or flags.
  431. * :ref:`develop_buildsystem_var_incdirs`
  432. * :ref:`develop_buildsystem_var_c_incdirs`
  433. * :ref:`develop_buildsystem_var_cxx_incdirs`
  434. * :ref:`develop_buildsystem_var_asm_incdirs`
  435. * :ref:`develop_buildsystem_var_srcdirs`
  436. * :ref:`develop_buildsystem_var_c_srcdirs`
  437. * :ref:`develop_buildsystem_var_cxx_srcdirs`
  438. * :ref:`develop_buildsystem_var_asm_srcdirs`
  439. * :ref:`develop_buildsystem_var_c_srcs`
  440. * :ref:`develop_buildsystem_var_cxx_srcs`
  441. * :ref:`develop_buildsystem_var_asm_srcs`
  442. * :ref:`develop_buildsystem_var_common_flags`
  443. * :ref:`develop_buildsystem_var_cflags`
  444. * :ref:`develop_buildsystem_var_cxxflags`
  445. * :ref:`develop_buildsystem_var_asmflags`
  446. * :ref:`develop_buildsystem_var_ldflags`
  447. * :ref:`develop_buildsystem_var_ldlibs`
  448. * :ref:`develop_buildsystem_var_libdirs`
  449. * :ref:`develop_buildsystem_var_linker_script`
  450. .. _develop_buildsystem_var_incdirs:
  451. INCDIRS
  452. ~~~~~~~
  453. This **INCDIRS** is used to pass C/CPP/ASM include directories.
  454. e.g. To include current directory ``.`` and ``inc`` for C/CPP/ASM
  455. .. code-block:: makefile
  456. INCDIRS = . inc
  457. .. _develop_buildsystem_var_c_incdirs:
  458. C_INCDIRS
  459. ~~~~~~~~~
  460. This **C_INCDIRS** is used to pass C only include directories.
  461. e.g. To include current directory ``.`` and ``cinc`` for C only
  462. .. code-block:: makefile
  463. C_INCDIRS = . cinc
  464. .. _develop_buildsystem_var_cxx_incdirs:
  465. CXX_INCDIRS
  466. ~~~~~~~~~~~
  467. This **CXX_INCDIRS** is used to pass CPP only include directories.
  468. e.g. To include current directory ``.`` and ``cppinc`` for CPP only
  469. .. code-block:: makefile
  470. CXX_INCDIRS = . cppinc
  471. .. _develop_buildsystem_var_asm_incdirs:
  472. ASM_INCDIRS
  473. ~~~~~~~~~~~
  474. This **ASM_INCDIRS** is used to pass ASM only include directories.
  475. e.g. To include current directory ``.`` and ``asminc`` for ASM only
  476. .. code-block:: makefile
  477. ASM_INCDIRS = . asminc
  478. .. _develop_buildsystem_var_srcdirs:
  479. SRCDIRS
  480. ~~~~~~~
  481. This **SRCDIRS** is used to set the source directories used to search
  482. the C/CPP/ASM source code files, it will not do recursively.
  483. e.g. To search C/CPP/ASM source files in directory ``.`` and ``src``
  484. .. code-block:: makefile
  485. SRCDIRS = . src
  486. .. _develop_buildsystem_var_c_srcdirs:
  487. C_SRCDIRS
  488. ~~~~~~~~~
  489. This **C_SRCDIRS** is used to set the source directories used to search
  490. the C only source code files(*.c, *.C), it will not do recursively.
  491. e.g. To search C only source files in directory ``.`` and ``csrc``
  492. .. code-block:: makefile
  493. C_SRCDIRS = . csrc
  494. .. _develop_buildsystem_var_cxx_srcdirs:
  495. CXX_SRCDIRS
  496. ~~~~~~~~~~~
  497. This **CXX_SRCDIRS** is used to set the source directories used to search
  498. the CPP only source code files(*.cpp, *.CPP), it will not do recursively.
  499. e.g. To search CPP only source files in directory ``.`` and ``cppsrc``
  500. .. code-block:: makefile
  501. CXX_SRCDIRS = . cppsrc
  502. .. _develop_buildsystem_var_asm_srcdirs:
  503. ASM_SRCDIRS
  504. ~~~~~~~~~~~
  505. This **ASM_SRCDIRS** is used to set the source directories used to search
  506. the ASM only source code files(*.s, *.S), it will not do recursively.
  507. e.g. To search ASM only source files in directory ``.`` and ``asmsrc``
  508. .. code-block:: makefile
  509. ASM_SRCDIRS = . asmsrc
  510. .. _develop_buildsystem_var_c_srcs:
  511. C_SRCS
  512. ~~~~~~
  513. If you just want to include a few of C source files in directories, you can use this
  514. **C_SRCS** variable.
  515. e.g. To include ``main.c`` and ``src/hello.c``
  516. .. code-block:: makefile
  517. C_SRCS = main.c src/hello.c
  518. .. _develop_buildsystem_var_cxx_srcs:
  519. CXX_SRCS
  520. ~~~~~~~~
  521. If you just want to include a few of CPP source files in directories, you can use this
  522. **CXX_SRCS** variable.
  523. e.g. To include ``main.cpp`` and ``src/hello.cpp``
  524. .. code-block:: makefile
  525. CXX_SRCS = main.cpp src/hello.cpp
  526. .. _develop_buildsystem_var_asm_srcs:
  527. ASM_SRCS
  528. ~~~~~~~~
  529. If you just want to include a few of ASM source files in directories, you can use this
  530. **ASM_SRCS** variable.
  531. e.g. To include ``asm.s`` and ``src/test.s``
  532. .. code-block:: makefile
  533. ASM_SRCS = asm.s src/test.s
  534. .. _develop_buildsystem_var_common_flags:
  535. COMMON_FLAGS
  536. ~~~~~~~~~~~~
  537. This **COMMON_FLAGS** variable is used to define common compiler flags to all c/asm/cpp compiler.
  538. For example, you can add a newline ``COMMON_FLAGS += -O3 -funroll-loops -fpeel-loops``
  539. in your application Makefile and these options will be passed to C/ASM/CPP compiler.
  540. .. _develop_buildsystem_var_cflags:
  541. CFLAGS
  542. ~~~~~~
  543. Different to **COMMON_FLAGS**, this **CFLAGS** variable is used to define common compiler flags to C compiler only.
  544. For example, you can add a newline ``CFLAGS += -O3 -funroll-loops -fpeel-loops``
  545. in your application Makefile and these options will be passed to C compiler.
  546. .. _develop_buildsystem_var_cxxflags:
  547. CXXFLAGS
  548. ~~~~~~~~
  549. Different to **COMMON_FLAGS**, this **CXXFLAGS** variable is used to define common compiler flags to cpp compiler only.
  550. For example, you can add a newline ``CXXFLAGS += -O3 -funroll-loops -fpeel-loops``
  551. in your application Makefile and these options will be passed to cpp compiler.
  552. .. _develop_buildsystem_var_asmflags:
  553. ASMFLAGS
  554. ~~~~~~~~
  555. Different to **COMMON_FLAGS**, this **ASMFLAGS** variable is used to define common compiler flags to asm compiler only.
  556. For example, you can add a newline ``ASMFLAGS += -O3 -funroll-loops -fpeel-loops``
  557. in your application Makefile and these options will be passed to asm compiler.
  558. .. _develop_buildsystem_var_ldflags:
  559. LDFLAGS
  560. ~~~~~~~
  561. This **LDFLAGS** is used to pass extra linker flags, for example,
  562. if you want to link extra math library, you can add a newline
  563. ``LDFLAGS += -lm`` in you application Makefile.
  564. Libraries (-lfoo) could also be added to the LDLIBS variable instead.
  565. .. _develop_buildsystem_var_ldlibs:
  566. LDLIBS
  567. ~~~~~~
  568. This **LDLIBS** variable is library flags or names given to compilers
  569. when they are supposed to invoke the linker.
  570. Non-library linker flags, such as -L, should go in the **LDFLAGS** variable.
  571. .. _develop_buildsystem_var_libdirs:
  572. LIBDIRS
  573. ~~~~~~~
  574. This **LIBDIRS** variable is used to store the library directories, which could
  575. be used together with **LDLIBS**.
  576. For example, if you have a library located in **$(NUCLEI_SDK_ROOT)/Library/DSP/libdsp.a**,
  577. and you want to link it, then you can define these lines:
  578. .. code-block:: makefile
  579. LDLIBS = -ldsp
  580. LIBDIRS = $(NUCLEI_SDK_ROOT)/Library/DSP
  581. .. _develop_buildsystem_var_linker_script:
  582. LINKER_SCRIPT
  583. ~~~~~~~~~~~~~
  584. This **LINKER_SCRIPT** variable could be used to set the link script of the application.
  585. By default, there is no need to set this variable, since the build system will define
  586. a default linker script for application according to the build configuration. If you want
  587. to define your own linker script, you can set this variable.
  588. For example, ``LINKER_SCRIPT := gcc.ld``.
  589. .. _GNU Make Standard Library (GMSL): http://sourceforge.net/projects/gmsl/