Makefile 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660
  1. #
  2. # Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. #
  7. # Trusted Firmware Version
  8. #
  9. VERSION_MAJOR := 2
  10. VERSION_MINOR := 8
  11. VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}
  12. # Default goal is build all images
  13. .DEFAULT_GOAL := all
  14. # Avoid any implicit propagation of command line variable definitions to
  15. # sub-Makefiles, like CFLAGS that we reserved for the firmware images'
  16. # usage. Other command line options like "-s" are still propagated as usual.
  17. MAKEOVERRIDES =
  18. MAKE_HELPERS_DIRECTORY := make_helpers/
  19. include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
  20. include ${MAKE_HELPERS_DIRECTORY}build_env.mk
  21. ################################################################################
  22. # Default values for build configurations, and their dependencies
  23. ################################################################################
  24. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  25. # Assertions enabled for DEBUG builds by default
  26. ENABLE_ASSERTIONS := ${DEBUG}
  27. ENABLE_PMF := ${ENABLE_RUNTIME_INSTRUMENTATION}
  28. PLAT := ${DEFAULT_PLAT}
  29. ################################################################################
  30. # Checkpatch script options
  31. ################################################################################
  32. CHECKCODE_ARGS := --no-patch
  33. # Do not check the coding style on imported library files or documentation files
  34. INC_ARM_DIRS_TO_CHECK := $(sort $(filter-out \
  35. include/drivers/arm/cryptocell, \
  36. $(wildcard include/drivers/arm/*)))
  37. INC_ARM_DIRS_TO_CHECK += include/drivers/arm/cryptocell/*.h
  38. INC_DRV_DIRS_TO_CHECK := $(sort $(filter-out \
  39. include/drivers/arm, \
  40. $(wildcard include/drivers/*)))
  41. INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
  42. include/lib/libfdt \
  43. include/lib/libc, \
  44. $(wildcard include/lib/*)))
  45. INC_DIRS_TO_CHECK := $(sort $(filter-out \
  46. include/lib \
  47. include/drivers, \
  48. $(wildcard include/*)))
  49. LIB_DIRS_TO_CHECK := $(sort $(filter-out \
  50. lib/compiler-rt \
  51. lib/libfdt% \
  52. lib/libc, \
  53. lib/zlib \
  54. $(wildcard lib/*)))
  55. ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
  56. lib \
  57. include \
  58. docs \
  59. %.rst, \
  60. $(wildcard *)))
  61. CHECK_PATHS := ${ROOT_DIRS_TO_CHECK} \
  62. ${INC_DIRS_TO_CHECK} \
  63. ${INC_LIB_DIRS_TO_CHECK} \
  64. ${LIB_DIRS_TO_CHECK} \
  65. ${INC_DRV_DIRS_TO_CHECK} \
  66. ${INC_ARM_DIRS_TO_CHECK}
  67. ################################################################################
  68. # Process build options
  69. ################################################################################
  70. # Verbose flag
  71. ifeq (${V},0)
  72. Q:=@
  73. ECHO:=@echo
  74. CHECKCODE_ARGS += --no-summary --terse
  75. else
  76. Q:=
  77. ECHO:=$(ECHO_QUIET)
  78. endif
  79. ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
  80. Q:=@
  81. ECHO:=$(ECHO_QUIET)
  82. endif
  83. export Q ECHO
  84. # The cert_create tool cannot generate certificates individually, so we use the
  85. # target 'certificates' to create them all
  86. ifneq (${GENERATE_COT},0)
  87. FIP_DEPS += certificates
  88. FWU_FIP_DEPS += fwu_certificates
  89. endif
  90. # Process BRANCH_PROTECTION value and set
  91. # Pointer Authentication and Branch Target Identification flags
  92. ifeq (${BRANCH_PROTECTION},0)
  93. # Default value turns off all types of branch protection
  94. BP_OPTION := none
  95. else ifneq (${ARCH},aarch64)
  96. $(error BRANCH_PROTECTION requires AArch64)
  97. else ifeq (${BRANCH_PROTECTION},1)
  98. # Enables all types of branch protection features
  99. BP_OPTION := standard
  100. ENABLE_BTI := 1
  101. ENABLE_PAUTH := 1
  102. else ifeq (${BRANCH_PROTECTION},2)
  103. # Return address signing to its standard level
  104. BP_OPTION := pac-ret
  105. ENABLE_PAUTH := 1
  106. else ifeq (${BRANCH_PROTECTION},3)
  107. # Extend the signing to include leaf functions
  108. BP_OPTION := pac-ret+leaf
  109. ENABLE_PAUTH := 1
  110. else ifeq (${BRANCH_PROTECTION},4)
  111. # Turn on branch target identification mechanism
  112. BP_OPTION := bti
  113. ENABLE_BTI := 1
  114. else
  115. $(error Unknown BRANCH_PROTECTION value ${BRANCH_PROTECTION})
  116. endif
  117. # FEAT_RME
  118. ifeq (${ENABLE_RME},1)
  119. # RME doesn't support PIE
  120. ifneq (${ENABLE_PIE},0)
  121. $(error ENABLE_RME does not support PIE)
  122. endif
  123. # RME doesn't support BRBE
  124. ifneq (${ENABLE_BRBE_FOR_NS},0)
  125. $(error ENABLE_RME does not support BRBE.)
  126. endif
  127. # RME requires AARCH64
  128. ifneq (${ARCH},aarch64)
  129. $(error ENABLE_RME requires AArch64)
  130. endif
  131. # RME requires el2 context to be saved for now.
  132. CTX_INCLUDE_EL2_REGS := 1
  133. CTX_INCLUDE_AARCH32_REGS := 0
  134. ARM_ARCH_MAJOR := 8
  135. ARM_ARCH_MINOR := 5
  136. ENABLE_FEAT_ECV = 1
  137. ENABLE_FEAT_FGT = 1
  138. # RME enables CSV2_2 extension by default.
  139. ENABLE_FEAT_CSV2_2 = 1
  140. endif
  141. # USE_SPINLOCK_CAS requires AArch64 build
  142. ifeq (${USE_SPINLOCK_CAS},1)
  143. ifneq (${ARCH},aarch64)
  144. $(error USE_SPINLOCK_CAS requires AArch64)
  145. endif
  146. endif
  147. # USE_DEBUGFS experimental feature recommended only in debug builds
  148. ifeq (${USE_DEBUGFS},1)
  149. ifeq (${DEBUG},1)
  150. $(warning DEBUGFS experimental feature is enabled.)
  151. else
  152. $(warning DEBUGFS experimental, recommended in DEBUG builds ONLY)
  153. endif
  154. endif
  155. ifneq (${DECRYPTION_SUPPORT},none)
  156. ENC_ARGS += -f ${FW_ENC_STATUS}
  157. ENC_ARGS += -k ${ENC_KEY}
  158. ENC_ARGS += -n ${ENC_NONCE}
  159. FIP_DEPS += enctool
  160. FWU_FIP_DEPS += enctool
  161. endif
  162. ################################################################################
  163. # Toolchain
  164. ################################################################################
  165. HOSTCC := gcc
  166. export HOSTCC
  167. CC := ${CROSS_COMPILE}gcc
  168. CPP := ${CROSS_COMPILE}cpp
  169. AS := ${CROSS_COMPILE}gcc
  170. AR := ${CROSS_COMPILE}ar
  171. LINKER := ${CROSS_COMPILE}ld
  172. OC := ${CROSS_COMPILE}objcopy
  173. OD := ${CROSS_COMPILE}objdump
  174. NM := ${CROSS_COMPILE}nm
  175. PP := ${CROSS_COMPILE}gcc -E
  176. DTC := dtc
  177. # Use ${LD}.bfd instead if it exists (as absolute path or together with $PATH).
  178. ifneq ($(strip $(wildcard ${LD}.bfd) \
  179. $(foreach dir,$(subst :, ,${PATH}),$(wildcard ${dir}/${LINKER}.bfd))),)
  180. LINKER := ${LINKER}.bfd
  181. endif
  182. ifeq (${ARM_ARCH_MAJOR},7)
  183. target32-directive = -target arm-none-eabi
  184. # Will set march32-directive from platform configuration
  185. else
  186. target32-directive = -target armv8a-none-eabi
  187. # Set the compiler's target architecture profile based on
  188. # ARM_ARCH_MAJOR ARM_ARCH_MINOR options
  189. ifeq (${ARM_ARCH_MINOR},0)
  190. march32-directive = -march=armv${ARM_ARCH_MAJOR}-a
  191. march64-directive = -march=armv${ARM_ARCH_MAJOR}-a
  192. else
  193. march32-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
  194. march64-directive = -march=armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a
  195. endif
  196. endif
  197. # Memory tagging is supported in architecture Armv8.5-A AArch64 and onwards
  198. ifeq ($(ARCH), aarch64)
  199. # Check if revision is greater than or equal to 8.5
  200. ifeq "8.5" "$(word 1, $(sort 8.5 $(ARM_ARCH_MAJOR).$(ARM_ARCH_MINOR)))"
  201. mem_tag_arch_support = yes
  202. endif
  203. endif
  204. # Get architecture feature modifiers
  205. arch-features = ${ARM_ARCH_FEATURE}
  206. # Enable required options for memory stack tagging.
  207. # Currently, these options are enabled only for clang and armclang compiler.
  208. ifeq (${SUPPORT_STACK_MEMTAG},yes)
  209. ifdef mem_tag_arch_support
  210. # Check for armclang and clang compilers
  211. ifneq ( ,$(filter $(notdir $(CC)),armclang clang))
  212. # Add "memtag" architecture feature modifier if not specified
  213. ifeq ( ,$(findstring memtag,$(arch-features)))
  214. arch-features := $(arch-features)+memtag
  215. endif # memtag
  216. ifeq ($(notdir $(CC)),armclang)
  217. TF_CFLAGS += -mmemtag-stack
  218. else ifeq ($(notdir $(CC)),clang)
  219. TF_CFLAGS += -fsanitize=memtag
  220. endif # armclang
  221. endif # armclang clang
  222. else
  223. $(error "Error: stack memory tagging is not supported for architecture \
  224. ${ARCH},armv${ARM_ARCH_MAJOR}.${ARM_ARCH_MINOR}-a")
  225. endif # mem_tag_arch_support
  226. endif # SUPPORT_STACK_MEMTAG
  227. # Set the compiler's architecture feature modifiers
  228. ifneq ($(arch-features), none)
  229. # Strip "none+" from arch-features
  230. arch-features := $(subst none+,,$(arch-features))
  231. ifeq ($(ARCH), aarch32)
  232. march32-directive := $(march32-directive)+$(arch-features)
  233. else
  234. march64-directive := $(march64-directive)+$(arch-features)
  235. endif
  236. # Print features
  237. $(info Arm Architecture Features specified: $(subst +, ,$(arch-features)))
  238. endif # arch-features
  239. # Determine if FEAT_RNG is supported
  240. ENABLE_FEAT_RNG = $(if $(findstring rng,${arch-features}),1,0)
  241. # Determine if FEAT_SB is supported
  242. ENABLE_FEAT_SB = $(if $(findstring sb,${arch-features}),1,0)
  243. ifneq ($(findstring clang,$(notdir $(CC))),)
  244. ifneq ($(findstring armclang,$(notdir $(CC))),)
  245. TF_CFLAGS_aarch32 := -target arm-arm-none-eabi $(march32-directive)
  246. TF_CFLAGS_aarch64 := -target aarch64-arm-none-eabi $(march64-directive)
  247. LD := $(LINKER)
  248. else
  249. TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive)
  250. TF_CFLAGS_aarch64 := -target aarch64-elf $(march64-directive)
  251. LD := $(shell $(CC) --print-prog-name ld.lld)
  252. AR := $(shell $(CC) --print-prog-name llvm-ar)
  253. OD := $(shell $(CC) --print-prog-name llvm-objdump)
  254. OC := $(shell $(CC) --print-prog-name llvm-objcopy)
  255. endif
  256. CPP := $(CC) -E $(TF_CFLAGS_$(ARCH))
  257. PP := $(CC) -E $(TF_CFLAGS_$(ARCH))
  258. AS := $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
  259. else ifneq ($(findstring gcc,$(notdir $(CC))),)
  260. TF_CFLAGS_aarch32 = $(march32-directive)
  261. TF_CFLAGS_aarch64 = $(march64-directive)
  262. ifeq ($(ENABLE_LTO),1)
  263. # Enable LTO only for aarch64
  264. ifeq (${ARCH},aarch64)
  265. LTO_CFLAGS = -flto
  266. # Use gcc as a wrapper for the ld, recommended for LTO
  267. LINKER := ${CROSS_COMPILE}gcc
  268. endif
  269. endif
  270. LD = $(LINKER)
  271. else
  272. TF_CFLAGS_aarch32 = $(march32-directive)
  273. TF_CFLAGS_aarch64 = $(march64-directive)
  274. LD = $(LINKER)
  275. endif
  276. # Process Debug flag
  277. $(eval $(call add_define,DEBUG))
  278. ifneq (${DEBUG}, 0)
  279. BUILD_TYPE := debug
  280. TF_CFLAGS += -g -gdwarf-4
  281. ASFLAGS += -g -Wa,-gdwarf-4
  282. # Use LOG_LEVEL_INFO by default for debug builds
  283. LOG_LEVEL := 40
  284. else
  285. BUILD_TYPE := release
  286. # Use LOG_LEVEL_NOTICE by default for release builds
  287. LOG_LEVEL := 20
  288. endif
  289. # Default build string (git branch and commit)
  290. ifeq (${BUILD_STRING},)
  291. BUILD_STRING := $(shell git describe --always --dirty --tags 2> /dev/null)
  292. endif
  293. VERSION_STRING := v${VERSION}(${BUILD_TYPE}):${BUILD_STRING}
  294. ifeq (${AARCH32_INSTRUCTION_SET},A32)
  295. TF_CFLAGS_aarch32 += -marm
  296. else ifeq (${AARCH32_INSTRUCTION_SET},T32)
  297. TF_CFLAGS_aarch32 += -mthumb
  298. else
  299. $(error Error: Unknown AArch32 instruction set ${AARCH32_INSTRUCTION_SET})
  300. endif
  301. TF_CFLAGS_aarch32 += -mno-unaligned-access
  302. TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
  303. ifneq (${BP_OPTION},none)
  304. TF_CFLAGS_aarch64 += -mbranch-protection=${BP_OPTION}
  305. endif
  306. ASFLAGS_aarch32 = $(march32-directive)
  307. ASFLAGS_aarch64 = $(march64-directive)
  308. # General warnings
  309. WARNINGS := -Wall -Wmissing-include-dirs -Wunused \
  310. -Wdisabled-optimization -Wvla -Wshadow \
  311. -Wredundant-decls
  312. # stricter warnings
  313. WARNINGS += -Wextra -Wno-trigraphs
  314. # too verbose for generic build
  315. WARNINGS += -Wno-missing-field-initializers \
  316. -Wno-type-limits -Wno-sign-compare \
  317. # on clang this flag gets reset if -Wextra is set after it. No difference on gcc
  318. WARNINGS += -Wno-unused-parameter
  319. # Additional warnings
  320. # Level 1 - infrequent warnings we should have none of
  321. # full -Wextra
  322. WARNING1 += -Wsign-compare
  323. WARNING1 += -Wtype-limits
  324. WARNING1 += -Wmissing-field-initializers
  325. # Level 2 - problematic warnings that we want
  326. # zlib, compiler-rt, coreboot, and mbdedtls blow up with these
  327. # TODO: disable just for them and move into default build
  328. WARNING2 += -Wold-style-definition
  329. WARNING2 += -Wmissing-prototypes
  330. WARNING2 += -Wmissing-format-attribute
  331. # TF-A aims to comply with this eventually. Effort too large at present
  332. WARNING2 += -Wundef
  333. # currently very involved and many platforms set this off
  334. WARNING2 += -Wunused-const-variable=2
  335. # Level 3 - very pedantic, frequently ignored
  336. WARNING3 := -Wbad-function-cast
  337. WARNING3 += -Waggregate-return
  338. WARNING3 += -Wnested-externs
  339. WARNING3 += -Wcast-align
  340. WARNING3 += -Wcast-qual
  341. WARNING3 += -Wconversion
  342. WARNING3 += -Wpacked
  343. WARNING3 += -Wpointer-arith
  344. WARNING3 += -Wswitch-default
  345. # Setting W is quite verbose and most warnings will be pre-existing issues
  346. # outside of the contributor's control. Don't fail the build on them so warnings
  347. # can be seen and hopefully addressed
  348. ifdef W
  349. ifneq (${W},0)
  350. E ?= 0
  351. endif
  352. endif
  353. ifeq (${W},1)
  354. WARNINGS += $(WARNING1)
  355. else ifeq (${W},2)
  356. WARNINGS += $(WARNING1) $(WARNING2)
  357. else ifeq (${W},3)
  358. WARNINGS += $(WARNING1) $(WARNING2) $(WARNING3)
  359. endif
  360. # Compiler specific warnings
  361. ifeq ($(findstring clang,$(notdir $(CC))),)
  362. # not using clang
  363. WARNINGS += -Wunused-but-set-variable -Wmaybe-uninitialized \
  364. -Wpacked-bitfield-compat -Wshift-overflow=2 \
  365. -Wlogical-op
  366. else
  367. # using clang
  368. WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
  369. -Wlogical-op-parentheses
  370. endif
  371. ifneq (${E},0)
  372. ERRORS := -Werror
  373. endif
  374. CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
  375. $(ERRORS) $(WARNINGS)
  376. ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
  377. -ffreestanding -Wa,--fatal-warnings
  378. TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
  379. -ffunction-sections -fdata-sections \
  380. -ffreestanding -fno-builtin -fno-common \
  381. -Os -std=gnu99
  382. $(eval $(call add_define,SVE_VECTOR_LEN))
  383. ifeq (${SANITIZE_UB},on)
  384. TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover
  385. endif
  386. ifeq (${SANITIZE_UB},trap)
  387. TF_CFLAGS += -fsanitize=undefined -fno-sanitize-recover \
  388. -fsanitize-undefined-trap-on-error
  389. endif
  390. GCC_V_OUTPUT := $(shell $(CC) -v 2>&1)
  391. # LD = armlink
  392. ifneq ($(findstring armlink,$(notdir $(LD))),)
  393. TF_LDFLAGS += --diag_error=warning --lto_level=O1
  394. TF_LDFLAGS += --remove --info=unused,unusedsymbols
  395. TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH))
  396. # LD = gcc (used when GCC LTO is enabled)
  397. else ifneq ($(findstring gcc,$(notdir $(LD))),)
  398. # Pass ld options with Wl or Xlinker switches
  399. TF_LDFLAGS += -Wl,--fatal-warnings -O1
  400. TF_LDFLAGS += -Wl,--gc-sections
  401. TF_LDFLAGS += -Wl,-z,common-page-size=4096 # Configure page size constants
  402. TF_LDFLAGS += -Wl,-z,max-page-size=4096
  403. ifeq ($(ENABLE_LTO),1)
  404. ifeq (${ARCH},aarch64)
  405. TF_LDFLAGS += -flto -fuse-linker-plugin
  406. endif
  407. endif
  408. # GCC automatically adds fix-cortex-a53-843419 flag when used to link
  409. # which breaks some builds, so disable if errata fix is not explicitly enabled
  410. ifneq (${ERRATA_A53_843419},1)
  411. TF_LDFLAGS += -mno-fix-cortex-a53-843419
  412. endif
  413. TF_LDFLAGS += -nostdlib
  414. TF_LDFLAGS += $(subst --,-Xlinker --,$(TF_LDFLAGS_$(ARCH)))
  415. # LD = gcc-ld (ld) or llvm-ld (ld.lld) or other
  416. else
  417. TF_LDFLAGS += -O1
  418. TF_LDFLAGS += --gc-sections
  419. TF_LDFLAGS += -z common-page-size=4096 # Configure page size constants
  420. TF_LDFLAGS += -z max-page-size=4096
  421. # ld.lld doesn't recognize the errata flags,
  422. # therefore don't add those in that case.
  423. # ld.lld reports section type mismatch warnings,
  424. # therefore don't add --fatal-warnings to it.
  425. ifeq ($(findstring ld.lld,$(notdir $(LD))),)
  426. TF_LDFLAGS += $(TF_LDFLAGS_$(ARCH)) --fatal-warnings
  427. endif
  428. endif
  429. DTC_FLAGS += -I dts -O dtb
  430. DTC_CPPFLAGS += -P -nostdinc -Iinclude -Ifdts -undef \
  431. -x assembler-with-cpp $(DEFINES)
  432. ################################################################################
  433. # Common sources and include directories
  434. ################################################################################
  435. include ${MAKE_HELPERS_DIRECTORY}arch_features.mk
  436. include lib/compiler-rt/compiler-rt.mk
  437. BL_COMMON_SOURCES += common/bl_common.c \
  438. common/tf_log.c \
  439. common/${ARCH}/debug.S \
  440. drivers/console/multi_console.c \
  441. lib/${ARCH}/cache_helpers.S \
  442. lib/${ARCH}/misc_helpers.S \
  443. plat/common/plat_bl_common.c \
  444. plat/common/plat_log_common.c \
  445. plat/common/${ARCH}/plat_common.c \
  446. plat/common/${ARCH}/platform_helpers.S \
  447. ${COMPILER_RT_SRCS}
  448. ifeq ($(notdir $(CC)),armclang)
  449. BL_COMMON_SOURCES += lib/${ARCH}/armclang_printf.S
  450. endif
  451. ifeq (${SANITIZE_UB},on)
  452. BL_COMMON_SOURCES += plat/common/ubsan.c
  453. endif
  454. INCLUDES += -Iinclude \
  455. -Iinclude/arch/${ARCH} \
  456. -Iinclude/lib/cpus/${ARCH} \
  457. -Iinclude/lib/el3_runtime/${ARCH} \
  458. ${PLAT_INCLUDES} \
  459. ${SPD_INCLUDES}
  460. include common/backtrace/backtrace.mk
  461. ################################################################################
  462. # Generic definitions
  463. ################################################################################
  464. include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
  465. ifeq (${BUILD_BASE},)
  466. BUILD_BASE := ./build
  467. endif
  468. BUILD_PLAT := $(abspath ${BUILD_BASE})/${PLAT}/${BUILD_TYPE}
  469. SPDS := $(sort $(filter-out none, $(patsubst services/spd/%,%,$(wildcard services/spd/*))))
  470. # Platforms providing their own TBB makefile may override this value
  471. INCLUDE_TBBR_MK := 1
  472. ################################################################################
  473. # Include SPD Makefile if one has been specified
  474. ################################################################################
  475. ifneq (${SPD},none)
  476. ifeq (${ARCH},aarch32)
  477. $(error "Error: SPD is incompatible with AArch32.")
  478. endif
  479. ifdef EL3_PAYLOAD_BASE
  480. $(warning "SPD and EL3_PAYLOAD_BASE are incompatible build options.")
  481. $(warning "The SPD and its BL32 companion will be present but ignored.")
  482. endif
  483. ifeq (${SPD},spmd)
  484. # SPMD is located in std_svc directory
  485. SPD_DIR := std_svc
  486. ifeq ($(SPMD_SPM_AT_SEL2),1)
  487. CTX_INCLUDE_EL2_REGS := 1
  488. ifeq ($(SPMC_AT_EL3),1)
  489. $(error SPM cannot be enabled in both S-EL2 and EL3.)
  490. endif
  491. endif
  492. ifeq ($(findstring optee_sp,$(ARM_SPMC_MANIFEST_DTS)),optee_sp)
  493. DTC_CPPFLAGS += -DOPTEE_SP_FW_CONFIG
  494. endif
  495. ifeq ($(TS_SP_FW_CONFIG),1)
  496. DTC_CPPFLAGS += -DTS_SP_FW_CONFIG
  497. endif
  498. ifneq ($(ARM_BL2_SP_LIST_DTS),)
  499. DTC_CPPFLAGS += -DARM_BL2_SP_LIST_DTS=$(ARM_BL2_SP_LIST_DTS)
  500. endif
  501. ifneq ($(SP_LAYOUT_FILE),)
  502. BL2_ENABLE_SP_LOAD := 1
  503. endif
  504. else
  505. # All other SPDs in spd directory
  506. SPD_DIR := spd
  507. endif
  508. # We expect to locate an spd.mk under the specified SPD directory
  509. SPD_MAKE := $(wildcard services/${SPD_DIR}/${SPD}/${SPD}.mk)
  510. ifeq (${SPD_MAKE},)
  511. $(error Error: No services/${SPD_DIR}/${SPD}/${SPD}.mk located)
  512. endif
  513. $(info Including ${SPD_MAKE})
  514. include ${SPD_MAKE}
  515. # If there's BL32 companion for the chosen SPD, we expect that the SPD's
  516. # Makefile would set NEED_BL32 to "yes". In this case, the build system
  517. # supports two mutually exclusive options:
  518. # * BL32 is built from source: then BL32_SOURCES must contain the list
  519. # of source files to build BL32
  520. # * BL32 is a prebuilt binary: then BL32 must point to the image file
  521. # that will be included in the FIP
  522. # If both BL32_SOURCES and BL32 are defined, the binary takes precedence
  523. # over the sources.
  524. endif
  525. ifeq (${CTX_INCLUDE_EL2_REGS}, 1)
  526. ifeq (${SPD},none)
  527. ifeq (${ENABLE_RME},0)
  528. $(error CTX_INCLUDE_EL2_REGS is available only when SPD or RME is enabled)
  529. endif
  530. endif
  531. endif
  532. ################################################################################
  533. # Include rmmd Makefile if RME is enabled
  534. ################################################################################
  535. ifneq (${ENABLE_RME},0)
  536. ifneq (${ARCH},aarch64)
  537. $(error ENABLE_RME requires AArch64)
  538. endif
  539. ifeq ($(SPMC_AT_EL3),1)
  540. $(error SPMC_AT_EL3 and ENABLE_RME cannot both be enabled.)
  541. endif
  542. include services/std_svc/rmmd/rmmd.mk
  543. $(warning "RME is an experimental feature")
  544. endif
  545. ################################################################################
  546. # Include the platform specific Makefile after the SPD Makefile (the platform
  547. # makefile may use all previous definitions in this file)
  548. ################################################################################
  549. include ${PLAT_MAKEFILE_FULL}
  550. # This internal flag is common option which is set to 1 for scenarios
  551. # when the BL2 is running in EL3 level. This occurs in two scenarios -
  552. # 4 world system running BL2 at EL3 and two world system without BL1 running
  553. # BL2 in EL3
  554. ifeq (${RESET_TO_BL2},1)
  555. BL2_RUNS_AT_EL3 := 1
  556. ifeq (${ENABLE_RME},1)
  557. $(error RESET_TO_BL2=1 and ENABLE_RME=1 configuration is not supported at the moment.)
  558. endif
  559. else ifeq (${ENABLE_RME},1)
  560. BL2_RUNS_AT_EL3 := 1
  561. else
  562. BL2_RUNS_AT_EL3 := 0
  563. endif
  564. $(eval $(call MAKE_PREREQ_DIR,${BUILD_PLAT}))
  565. ifeq (${ARM_ARCH_MAJOR},7)
  566. include make_helpers/armv7-a-cpus.mk
  567. endif
  568. PIE_FOUND := $(findstring --enable-default-pie,${GCC_V_OUTPUT})
  569. ifneq ($(PIE_FOUND),)
  570. TF_CFLAGS += -fno-PIE
  571. ifneq ($(findstring gcc,$(notdir $(LD))),)
  572. TF_LDFLAGS += -no-pie
  573. endif
  574. endif
  575. ifneq ($(findstring gcc,$(notdir $(LD))),)
  576. PIE_LDFLAGS += -Wl,-pie -Wl,--no-dynamic-linker
  577. else
  578. PIE_LDFLAGS += -pie --no-dynamic-linker
  579. endif
  580. ifeq ($(ENABLE_PIE),1)
  581. ifeq ($(RESET_TO_BL2),1)
  582. ifneq ($(BL2_IN_XIP_MEM),1)
  583. BL2_CPPFLAGS += -fpie
  584. BL2_CFLAGS += -fpie
  585. BL2_LDFLAGS += $(PIE_LDFLAGS)
  586. endif
  587. endif
  588. BL31_CPPFLAGS += -fpie
  589. BL31_CFLAGS += -fpie
  590. BL31_LDFLAGS += $(PIE_LDFLAGS)
  591. BL32_CPPFLAGS += -fpie
  592. BL32_CFLAGS += -fpie
  593. BL32_LDFLAGS += $(PIE_LDFLAGS)
  594. endif
  595. ifeq (${ARCH},aarch64)
  596. BL1_CPPFLAGS += -DIMAGE_AT_EL3
  597. ifeq ($(RESET_TO_BL2),1)
  598. BL2_CPPFLAGS += -DIMAGE_AT_EL3
  599. else
  600. BL2_CPPFLAGS += -DIMAGE_AT_EL1
  601. endif
  602. BL2U_CPPFLAGS += -DIMAGE_AT_EL1
  603. BL31_CPPFLAGS += -DIMAGE_AT_EL3
  604. BL32_CPPFLAGS += -DIMAGE_AT_EL1
  605. endif
  606. # Include the CPU specific operations makefile, which provides default
  607. # values for all CPU errata workarounds and CPU specific optimisations.
  608. # This can be overridden by the platform.
  609. include lib/cpus/cpu-ops.mk
  610. ifeq (${ARCH},aarch32)
  611. NEED_BL32 := yes
  612. ################################################################################
  613. # Build `AARCH32_SP` as BL32 image for AArch32
  614. ################################################################################
  615. ifneq (${AARCH32_SP},none)
  616. # We expect to locate an sp.mk under the specified AARCH32_SP directory
  617. AARCH32_SP_MAKE := $(wildcard bl32/${AARCH32_SP}/${AARCH32_SP}.mk)
  618. ifeq (${AARCH32_SP_MAKE},)
  619. $(error Error: No bl32/${AARCH32_SP}/${AARCH32_SP}.mk located)
  620. endif
  621. $(info Including ${AARCH32_SP_MAKE})
  622. include ${AARCH32_SP_MAKE}
  623. endif
  624. endif
  625. ################################################################################
  626. # Include libc if not overridden
  627. ################################################################################
  628. ifeq (${OVERRIDE_LIBC},0)
  629. include lib/libc/libc.mk
  630. endif
  631. ################################################################################
  632. # Check incompatible options
  633. ################################################################################
  634. ifdef EL3_PAYLOAD_BASE
  635. ifdef PRELOADED_BL33_BASE
  636. $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \
  637. incompatible build options. EL3_PAYLOAD_BASE has priority.")
  638. endif
  639. ifneq (${GENERATE_COT},0)
  640. $(error "GENERATE_COT and EL3_PAYLOAD_BASE are incompatible build options.")
  641. endif
  642. ifneq (${TRUSTED_BOARD_BOOT},0)
  643. $(error "TRUSTED_BOARD_BOOT and EL3_PAYLOAD_BASE are incompatible build options.")
  644. endif
  645. endif
  646. ifeq (${NEED_BL33},yes)
  647. ifdef EL3_PAYLOAD_BASE
  648. $(warning "BL33 image is not needed when option \
  649. BL33_PAYLOAD_BASE is used and won't be added to the FIP file.")
  650. endif
  651. ifdef PRELOADED_BL33_BASE
  652. $(warning "BL33 image is not needed when option \
  653. PRELOADED_BL33_BASE is used and won't be added to the FIP \
  654. file.")
  655. endif
  656. endif
  657. # When building for systems with hardware-assisted coherency, there's no need to
  658. # use USE_COHERENT_MEM. Require that USE_COHERENT_MEM must be set to 0 too.
  659. ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1)
  660. $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY)
  661. endif
  662. #For now, BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is 1.
  663. ifeq ($(RESET_TO_BL2)-$(BL2_IN_XIP_MEM),0-1)
  664. $(error "BL2_IN_XIP_MEM is only supported when RESET_TO_BL2 is enabled")
  665. endif
  666. # For RAS_EXTENSION, require that EAs are handled in EL3 first
  667. ifeq ($(RAS_EXTENSION),1)
  668. ifneq ($(HANDLE_EA_EL3_FIRST_NS),1)
  669. $(error For RAS_EXTENSION, HANDLE_EA_EL3_FIRST_NS must also be 1)
  670. endif
  671. endif
  672. # When FAULT_INJECTION_SUPPORT is used, require that RAS_EXTENSION is enabled
  673. ifeq ($(FAULT_INJECTION_SUPPORT),1)
  674. ifneq ($(RAS_EXTENSION),1)
  675. $(error For FAULT_INJECTION_SUPPORT, RAS_EXTENSION must also be 1)
  676. endif
  677. endif
  678. # DYN_DISABLE_AUTH can be set only when TRUSTED_BOARD_BOOT=1
  679. ifeq ($(DYN_DISABLE_AUTH), 1)
  680. ifeq (${TRUSTED_BOARD_BOOT}, 0)
  681. $(error "TRUSTED_BOARD_BOOT must be enabled for DYN_DISABLE_AUTH to be set.")
  682. endif
  683. endif
  684. ifeq ($(MEASURED_BOOT)-$(TRUSTED_BOARD_BOOT),1-1)
  685. # Support authentication verification and hash calculation
  686. CRYPTO_SUPPORT := 3
  687. else ifeq ($(DRTM_SUPPORT)-$(TRUSTED_BOARD_BOOT),1-1)
  688. # Support authentication verification and hash calculation
  689. CRYPTO_SUPPORT := 3
  690. else ifneq ($(filter 1,${MEASURED_BOOT} ${DRTM_SUPPORT}),)
  691. # Support hash calculation only
  692. CRYPTO_SUPPORT := 2
  693. else ifeq (${TRUSTED_BOARD_BOOT},1)
  694. # Support authentication verification only
  695. CRYPTO_SUPPORT := 1
  696. else
  697. CRYPTO_SUPPORT := 0
  698. endif
  699. # SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled.
  700. ifeq ($(SDEI_SUPPORT)-$(SDEI_IN_FCONF),0-1)
  701. $(error "SDEI_IN_FCONF is only supported when SDEI_SUPPORT is enabled")
  702. endif
  703. # If pointer authentication is used in the firmware, make sure that all the
  704. # registers associated to it are also saved and restored.
  705. # Not doing it would leak the value of the keys used by EL3 to EL1 and S-EL1.
  706. ifeq ($(ENABLE_PAUTH),1)
  707. ifeq ($(CTX_INCLUDE_PAUTH_REGS),0)
  708. $(error Pointer Authentication requires CTX_INCLUDE_PAUTH_REGS=1)
  709. endif
  710. endif
  711. ifeq ($(CTX_INCLUDE_PAUTH_REGS),1)
  712. ifneq (${ARCH},aarch64)
  713. $(error CTX_INCLUDE_PAUTH_REGS requires AArch64)
  714. endif
  715. endif
  716. ifeq ($(CTX_INCLUDE_MTE_REGS),1)
  717. ifneq (${ARCH},aarch64)
  718. $(error CTX_INCLUDE_MTE_REGS requires AArch64)
  719. endif
  720. endif
  721. ifeq ($(PSA_FWU_SUPPORT),1)
  722. $(info PSA_FWU_SUPPORT is an experimental feature)
  723. endif
  724. ifeq ($(FEATURE_DETECTION),1)
  725. $(info FEATURE_DETECTION is an experimental feature)
  726. endif
  727. ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
  728. ifeq (${ALLOW_RO_XLAT_TABLES}, 1)
  729. $(error "ALLOW_RO_XLAT_TABLES requires translation tables library v2")
  730. endif
  731. endif
  732. ifneq (${DECRYPTION_SUPPORT},none)
  733. ifeq (${TRUSTED_BOARD_BOOT}, 0)
  734. $(error TRUSTED_BOARD_BOOT must be enabled for DECRYPTION_SUPPORT to be set)
  735. endif
  736. endif
  737. # Ensure that no Aarch64-only features are enabled in Aarch32 build
  738. ifeq (${ARCH},aarch32)
  739. # SME/SVE only supported on AArch64
  740. ifeq (${ENABLE_SME_FOR_NS},1)
  741. $(error "ENABLE_SME_FOR_NS cannot be used with ARCH=aarch32")
  742. endif
  743. ifeq (${ENABLE_SVE_FOR_NS},1)
  744. # Warning instead of error due to CI dependency on this
  745. $(error "ENABLE_SVE_FOR_NS cannot be used with ARCH=aarch32")
  746. endif
  747. # BRBE is not supported in AArch32
  748. ifeq (${ENABLE_BRBE_FOR_NS},1)
  749. $(error "ENABLE_BRBE_FOR_NS cannot be used with ARCH=aarch32")
  750. endif
  751. # FEAT_RNG_TRAP is not supported in AArch32
  752. ifeq (${ENABLE_FEAT_RNG_TRAP},1)
  753. $(error "ENABLE_FEAT_RNG_TRAP cannot be used with ARCH=aarch32")
  754. endif
  755. endif
  756. # Ensure ENABLE_RME is not used with SME
  757. ifeq (${ENABLE_RME},1)
  758. ifeq (${ENABLE_SME_FOR_NS},1)
  759. $(error "ENABLE_SME_FOR_NS cannot be used with ENABLE_RME")
  760. endif
  761. endif
  762. # Secure SME/SVE requires the non-secure component as well
  763. ifeq (${ENABLE_SME_FOR_SWD},1)
  764. ifeq (${ENABLE_SME_FOR_NS},0)
  765. $(error "ENABLE_SME_FOR_SWD requires ENABLE_SME_FOR_NS")
  766. endif
  767. endif
  768. ifeq (${ENABLE_SVE_FOR_SWD},1)
  769. ifeq (${ENABLE_SVE_FOR_NS},0)
  770. $(error "ENABLE_SVE_FOR_SWD requires ENABLE_SVE_FOR_NS")
  771. endif
  772. endif
  773. # SVE and SME cannot be used with CTX_INCLUDE_FPREGS since secure manager does
  774. # its own context management including FPU registers.
  775. ifeq (${CTX_INCLUDE_FPREGS},1)
  776. ifeq (${ENABLE_SME_FOR_NS},1)
  777. $(error "ENABLE_SME_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
  778. endif
  779. ifeq (${ENABLE_SVE_FOR_NS},1)
  780. # Warning instead of error due to CI dependency on this
  781. $(warning "ENABLE_SVE_FOR_NS cannot be used with CTX_INCLUDE_FPREGS")
  782. $(warning "Forced ENABLE_SVE_FOR_NS=0")
  783. override ENABLE_SVE_FOR_NS := 0
  784. endif
  785. endif
  786. ifeq ($(DRTM_SUPPORT),1)
  787. $(info DRTM_SUPPORT is an experimental feature)
  788. endif
  789. ifeq (${ENABLE_RME},1)
  790. ifneq (${SEPARATE_CODE_AND_RODATA},1)
  791. $(error `ENABLE_RME=1` requires `SEPARATE_CODE_AND_RODATA=1`)
  792. endif
  793. endif
  794. ################################################################################
  795. # Process platform overrideable behaviour
  796. ################################################################################
  797. ifdef BL1_SOURCES
  798. NEED_BL1 := yes
  799. endif
  800. ifdef BL2_SOURCES
  801. NEED_BL2 := yes
  802. # Using BL2 implies that a BL33 image also needs to be supplied for the FIP and
  803. # Certificate generation tools. This flag can be overridden by the platform.
  804. ifdef EL3_PAYLOAD_BASE
  805. # If booting an EL3 payload there is no need for a BL33 image
  806. # in the FIP file.
  807. NEED_BL33 := no
  808. else
  809. ifdef PRELOADED_BL33_BASE
  810. # If booting a BL33 preloaded image there is no need of
  811. # another one in the FIP file.
  812. NEED_BL33 := no
  813. else
  814. NEED_BL33 ?= yes
  815. endif
  816. endif
  817. endif
  818. ifdef BL2U_SOURCES
  819. NEED_BL2U := yes
  820. endif
  821. # If SCP_BL2 is given, we always want FIP to include it.
  822. ifdef SCP_BL2
  823. NEED_SCP_BL2 := yes
  824. endif
  825. # For AArch32, BL31 is not currently supported.
  826. ifneq (${ARCH},aarch32)
  827. ifdef BL31_SOURCES
  828. # When booting an EL3 payload, there is no need to compile the BL31 image nor
  829. # put it in the FIP.
  830. ifndef EL3_PAYLOAD_BASE
  831. NEED_BL31 := yes
  832. endif
  833. endif
  834. endif
  835. # Process TBB related flags
  836. ifneq (${GENERATE_COT},0)
  837. # Common cert_create options
  838. ifneq (${CREATE_KEYS},0)
  839. $(eval CRT_ARGS += -n)
  840. $(eval FWU_CRT_ARGS += -n)
  841. ifneq (${SAVE_KEYS},0)
  842. $(eval CRT_ARGS += -k)
  843. $(eval FWU_CRT_ARGS += -k)
  844. endif
  845. endif
  846. # Include TBBR makefile (unless the platform indicates otherwise)
  847. ifeq (${INCLUDE_TBBR_MK},1)
  848. include make_helpers/tbbr/tbbr_tools.mk
  849. endif
  850. endif
  851. ifneq (${FIP_ALIGN},0)
  852. FIP_ARGS += --align ${FIP_ALIGN}
  853. endif
  854. ifdef FDT_SOURCES
  855. NEED_FDT := yes
  856. endif
  857. ################################################################################
  858. # Include libraries' Makefile that are used in all BL
  859. ################################################################################
  860. include lib/stack_protector/stack_protector.mk
  861. ################################################################################
  862. # Auxiliary tools (fiptool, cert_create, etc)
  863. ################################################################################
  864. # Variables for use with Certificate Generation Tool
  865. CRTTOOLPATH ?= tools/cert_create
  866. CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
  867. # Variables for use with Firmware Encryption Tool
  868. ENCTOOLPATH ?= tools/encrypt_fw
  869. ENCTOOL ?= ${ENCTOOLPATH}/encrypt_fw${BIN_EXT}
  870. # Variables for use with Firmware Image Package
  871. FIPTOOLPATH ?= tools/fiptool
  872. FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
  873. # Variables for use with sptool
  874. SPTOOLPATH ?= tools/sptool
  875. SPTOOL ?= ${SPTOOLPATH}/sptool.py
  876. SP_MK_GEN ?= ${SPTOOLPATH}/sp_mk_generator.py
  877. # Variables for use with ROMLIB
  878. ROMLIBPATH ?= lib/romlib
  879. # Variable for use with Python
  880. PYTHON ?= python3
  881. # Variables for use with PRINT_MEMORY_MAP
  882. PRINT_MEMORY_MAP_PATH ?= tools/memory
  883. PRINT_MEMORY_MAP ?= ${PRINT_MEMORY_MAP_PATH}/print_memory_map.py
  884. # Variables for use with documentation build using Sphinx tool
  885. DOCS_PATH ?= docs
  886. # Defination of SIMICS flag
  887. SIMICS_BUILD ?= 0
  888. ################################################################################
  889. # Include BL specific makefiles
  890. ################################################################################
  891. ifeq (${NEED_BL1},yes)
  892. include bl1/bl1.mk
  893. endif
  894. ifeq (${NEED_BL2},yes)
  895. include bl2/bl2.mk
  896. endif
  897. ifeq (${NEED_BL2U},yes)
  898. include bl2u/bl2u.mk
  899. endif
  900. ifeq (${NEED_BL31},yes)
  901. include bl31/bl31.mk
  902. endif
  903. ################################################################################
  904. # Build options checks
  905. ################################################################################
  906. $(eval $(call assert_booleans,\
  907. $(sort \
  908. ALLOW_RO_XLAT_TABLES \
  909. BL2_ENABLE_SP_LOAD \
  910. COLD_BOOT_SINGLE_CPU \
  911. CREATE_KEYS \
  912. CTX_INCLUDE_AARCH32_REGS \
  913. CTX_INCLUDE_FPREGS \
  914. CTX_INCLUDE_EL2_REGS \
  915. DEBUG \
  916. DISABLE_MTPMU \
  917. DYN_DISABLE_AUTH \
  918. EL3_EXCEPTION_HANDLING \
  919. ENABLE_AMU \
  920. ENABLE_AMU_AUXILIARY_COUNTERS \
  921. ENABLE_AMU_FCONF \
  922. AMU_RESTRICT_COUNTERS \
  923. ENABLE_ASSERTIONS \
  924. ENABLE_PIE \
  925. ENABLE_PMF \
  926. ENABLE_PSCI_STAT \
  927. ENABLE_RUNTIME_INSTRUMENTATION \
  928. ENABLE_SME_FOR_NS \
  929. ENABLE_SME_FOR_SWD \
  930. ENABLE_SPE_FOR_LOWER_ELS \
  931. ENABLE_SVE_FOR_NS \
  932. ENABLE_SVE_FOR_SWD \
  933. ERROR_DEPRECATED \
  934. FAULT_INJECTION_SUPPORT \
  935. GENERATE_COT \
  936. GICV2_G0_FOR_EL3 \
  937. HANDLE_EA_EL3_FIRST_NS \
  938. HW_ASSISTED_COHERENCY \
  939. INVERTED_MEMMAP \
  940. MEASURED_BOOT \
  941. DRTM_SUPPORT \
  942. NS_TIMER_SWITCH \
  943. OVERRIDE_LIBC \
  944. PL011_GENERIC_UART \
  945. PLAT_RSS_NOT_SUPPORTED \
  946. PROGRAMMABLE_RESET_ADDRESS \
  947. PSCI_EXTENDED_STATE_ID \
  948. RESET_TO_BL31 \
  949. RESET_TO_BL31_WITH_PARAMS \
  950. SAVE_KEYS \
  951. SEPARATE_CODE_AND_RODATA \
  952. SEPARATE_BL2_NOLOAD_REGION \
  953. SEPARATE_NOBITS_REGION \
  954. SPIN_ON_BL1_EXIT \
  955. SPM_MM \
  956. SPMC_AT_EL3 \
  957. SPMD_SPM_AT_SEL2 \
  958. TRUSTED_BOARD_BOOT \
  959. USE_COHERENT_MEM \
  960. USE_DEBUGFS \
  961. ARM_IO_IN_DTB \
  962. SDEI_IN_FCONF \
  963. SEC_INT_DESC_IN_FCONF \
  964. USE_ROMLIB \
  965. USE_TBBR_DEFS \
  966. WARMBOOT_ENABLE_DCACHE_EARLY \
  967. RESET_TO_BL2 \
  968. BL2_IN_XIP_MEM \
  969. BL2_INV_DCACHE \
  970. USE_SPINLOCK_CAS \
  971. ENCRYPT_BL31 \
  972. ENCRYPT_BL32 \
  973. ERRATA_SPECULATIVE_AT \
  974. RAS_TRAP_NS_ERR_REC_ACCESS \
  975. COT_DESC_IN_DTB \
  976. USE_SP804_TIMER \
  977. PSA_FWU_SUPPORT \
  978. ENABLE_SYS_REG_TRACE_FOR_NS \
  979. ENABLE_MPMM \
  980. ENABLE_MPMM_FCONF \
  981. SIMICS_BUILD \
  982. FEATURE_DETECTION \
  983. TRNG_SUPPORT \
  984. CONDITIONAL_CMO \
  985. )))
  986. $(eval $(call assert_numerics,\
  987. $(sort \
  988. ARM_ARCH_MAJOR \
  989. ARM_ARCH_MINOR \
  990. BRANCH_PROTECTION \
  991. CTX_INCLUDE_PAUTH_REGS \
  992. CTX_INCLUDE_MTE_REGS \
  993. CTX_INCLUDE_NEVE_REGS \
  994. CRYPTO_SUPPORT \
  995. ENABLE_BRBE_FOR_NS \
  996. ENABLE_TRBE_FOR_NS \
  997. ENABLE_BTI \
  998. ENABLE_PAUTH \
  999. ENABLE_FEAT_AMUv1 \
  1000. ENABLE_FEAT_AMUv1p1 \
  1001. ENABLE_FEAT_CSV2_2 \
  1002. ENABLE_FEAT_DIT \
  1003. ENABLE_FEAT_ECV \
  1004. ENABLE_FEAT_FGT \
  1005. ENABLE_FEAT_HCX \
  1006. ENABLE_FEAT_PAN \
  1007. ENABLE_FEAT_RNG \
  1008. ENABLE_FEAT_RNG_TRAP \
  1009. ENABLE_FEAT_SB \
  1010. ENABLE_FEAT_SEL2 \
  1011. ENABLE_FEAT_VHE \
  1012. ENABLE_MPAM_FOR_LOWER_ELS \
  1013. ENABLE_RME \
  1014. ENABLE_TRF_FOR_NS \
  1015. FW_ENC_STATUS \
  1016. NR_OF_FW_BANKS \
  1017. NR_OF_IMAGES_IN_FW_BANK \
  1018. RAS_EXTENSION \
  1019. TWED_DELAY \
  1020. ENABLE_FEAT_TWED \
  1021. SVE_VECTOR_LEN \
  1022. )))
  1023. ifdef KEY_SIZE
  1024. $(eval $(call assert_numeric,KEY_SIZE))
  1025. endif
  1026. ifeq ($(filter $(SANITIZE_UB), on off trap),)
  1027. $(error "Invalid value for SANITIZE_UB: can be one of on, off, trap")
  1028. endif
  1029. ################################################################################
  1030. # Add definitions to the cpp preprocessor based on the current build options.
  1031. # This is done after including the platform specific makefile to allow the
  1032. # platform to overwrite the default options
  1033. ################################################################################
  1034. $(eval $(call add_defines,\
  1035. $(sort \
  1036. ALLOW_RO_XLAT_TABLES \
  1037. ARM_ARCH_MAJOR \
  1038. ARM_ARCH_MINOR \
  1039. BL2_ENABLE_SP_LOAD \
  1040. COLD_BOOT_SINGLE_CPU \
  1041. CTX_INCLUDE_AARCH32_REGS \
  1042. CTX_INCLUDE_FPREGS \
  1043. CTX_INCLUDE_PAUTH_REGS \
  1044. EL3_EXCEPTION_HANDLING \
  1045. CTX_INCLUDE_MTE_REGS \
  1046. CTX_INCLUDE_EL2_REGS \
  1047. CTX_INCLUDE_NEVE_REGS \
  1048. DECRYPTION_SUPPORT_${DECRYPTION_SUPPORT} \
  1049. DISABLE_MTPMU \
  1050. ENABLE_AMU \
  1051. ENABLE_AMU_AUXILIARY_COUNTERS \
  1052. ENABLE_AMU_FCONF \
  1053. AMU_RESTRICT_COUNTERS \
  1054. ENABLE_ASSERTIONS \
  1055. ENABLE_BTI \
  1056. ENABLE_MPAM_FOR_LOWER_ELS \
  1057. ENABLE_PAUTH \
  1058. ENABLE_PIE \
  1059. ENABLE_PMF \
  1060. ENABLE_PSCI_STAT \
  1061. ENABLE_RME \
  1062. ENABLE_RUNTIME_INSTRUMENTATION \
  1063. ENABLE_SME_FOR_NS \
  1064. ENABLE_SME_FOR_SWD \
  1065. ENABLE_SPE_FOR_LOWER_ELS \
  1066. ENABLE_SVE_FOR_NS \
  1067. ENABLE_SVE_FOR_SWD \
  1068. ENCRYPT_BL31 \
  1069. ENCRYPT_BL32 \
  1070. ERROR_DEPRECATED \
  1071. FAULT_INJECTION_SUPPORT \
  1072. GICV2_G0_FOR_EL3 \
  1073. HANDLE_EA_EL3_FIRST_NS \
  1074. HW_ASSISTED_COHERENCY \
  1075. LOG_LEVEL \
  1076. MEASURED_BOOT \
  1077. DRTM_SUPPORT \
  1078. NS_TIMER_SWITCH \
  1079. PL011_GENERIC_UART \
  1080. PLAT_${PLAT} \
  1081. PLAT_RSS_NOT_SUPPORTED \
  1082. PROGRAMMABLE_RESET_ADDRESS \
  1083. PSCI_EXTENDED_STATE_ID \
  1084. RAS_EXTENSION \
  1085. RESET_TO_BL31 \
  1086. RESET_TO_BL31_WITH_PARAMS \
  1087. SEPARATE_CODE_AND_RODATA \
  1088. SEPARATE_BL2_NOLOAD_REGION \
  1089. SEPARATE_NOBITS_REGION \
  1090. RECLAIM_INIT_CODE \
  1091. SPD_${SPD} \
  1092. SPIN_ON_BL1_EXIT \
  1093. SPM_MM \
  1094. SPMC_AT_EL3 \
  1095. SPMD_SPM_AT_SEL2 \
  1096. TRUSTED_BOARD_BOOT \
  1097. CRYPTO_SUPPORT \
  1098. TRNG_SUPPORT \
  1099. USE_COHERENT_MEM \
  1100. USE_DEBUGFS \
  1101. ARM_IO_IN_DTB \
  1102. SDEI_IN_FCONF \
  1103. SEC_INT_DESC_IN_FCONF \
  1104. USE_ROMLIB \
  1105. USE_TBBR_DEFS \
  1106. WARMBOOT_ENABLE_DCACHE_EARLY \
  1107. RESET_TO_BL2 \
  1108. BL2_RUNS_AT_EL3 \
  1109. BL2_IN_XIP_MEM \
  1110. BL2_INV_DCACHE \
  1111. USE_SPINLOCK_CAS \
  1112. ERRATA_SPECULATIVE_AT \
  1113. RAS_TRAP_NS_ERR_REC_ACCESS \
  1114. COT_DESC_IN_DTB \
  1115. USE_SP804_TIMER \
  1116. ENABLE_FEAT_RNG \
  1117. ENABLE_FEAT_RNG_TRAP \
  1118. ENABLE_FEAT_SB \
  1119. ENABLE_FEAT_DIT \
  1120. NR_OF_FW_BANKS \
  1121. NR_OF_IMAGES_IN_FW_BANK \
  1122. PSA_FWU_SUPPORT \
  1123. ENABLE_BRBE_FOR_NS \
  1124. ENABLE_TRBE_FOR_NS \
  1125. ENABLE_SYS_REG_TRACE_FOR_NS \
  1126. ENABLE_TRF_FOR_NS \
  1127. ENABLE_FEAT_HCX \
  1128. ENABLE_MPMM \
  1129. ENABLE_MPMM_FCONF \
  1130. ENABLE_FEAT_FGT \
  1131. ENABLE_FEAT_AMUv1 \
  1132. ENABLE_FEAT_ECV \
  1133. SIMICS_BUILD \
  1134. ENABLE_FEAT_AMUv1p1 \
  1135. ENABLE_FEAT_SEL2 \
  1136. ENABLE_FEAT_VHE \
  1137. ENABLE_FEAT_CSV2_2 \
  1138. ENABLE_FEAT_PAN \
  1139. FEATURE_DETECTION \
  1140. TWED_DELAY \
  1141. ENABLE_FEAT_TWED \
  1142. CONDITIONAL_CMO \
  1143. )))
  1144. ifeq (${SANITIZE_UB},trap)
  1145. $(eval $(call add_define,MONITOR_TRAPS))
  1146. endif
  1147. # Define the EL3_PAYLOAD_BASE flag only if it is provided.
  1148. ifdef EL3_PAYLOAD_BASE
  1149. $(eval $(call add_define,EL3_PAYLOAD_BASE))
  1150. else
  1151. # Define the PRELOADED_BL33_BASE flag only if it is provided and
  1152. # EL3_PAYLOAD_BASE is not defined, as it has priority.
  1153. ifdef PRELOADED_BL33_BASE
  1154. $(eval $(call add_define,PRELOADED_BL33_BASE))
  1155. endif
  1156. endif
  1157. # Define the DYN_DISABLE_AUTH flag only if set.
  1158. ifeq (${DYN_DISABLE_AUTH},1)
  1159. $(eval $(call add_define,DYN_DISABLE_AUTH))
  1160. endif
  1161. ifneq ($(findstring armlink,$(notdir $(LD))),)
  1162. $(eval $(call add_define,USE_ARM_LINK))
  1163. endif
  1164. # Generate and include sp_gen.mk if SPD is spmd and SP_LAYOUT_FILE is defined
  1165. ifeq (${SPD},spmd)
  1166. ifdef SP_LAYOUT_FILE
  1167. -include $(BUILD_PLAT)/sp_gen.mk
  1168. FIP_DEPS += sp
  1169. CRT_DEPS += sp
  1170. NEED_SP_PKG := yes
  1171. else
  1172. ifeq (${SPMD_SPM_AT_SEL2},1)
  1173. $(error "SPMD with SPM at S-EL2 require SP_LAYOUT_FILE")
  1174. endif
  1175. endif
  1176. endif
  1177. ################################################################################
  1178. # Build targets
  1179. ################################################################################
  1180. .PHONY: all msg_start clean realclean distclean cscope locate-checkpatch checkcodebase checkpatch fiptool sptool fip sp fwu_fip certtool dtbs memmap doc enctool
  1181. .SUFFIXES:
  1182. all: msg_start
  1183. msg_start:
  1184. @echo "Building ${PLAT}"
  1185. ifeq (${ERROR_DEPRECATED},0)
  1186. # Check if deprecated declarations and cpp warnings should be treated as error or not.
  1187. ifneq ($(findstring clang,$(notdir $(CC))),)
  1188. CPPFLAGS += -Wno-error=deprecated-declarations
  1189. else
  1190. CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
  1191. endif
  1192. endif # !ERROR_DEPRECATED
  1193. $(eval $(call MAKE_LIB_DIRS))
  1194. $(eval $(call MAKE_LIB,c))
  1195. # Expand build macros for the different images
  1196. ifeq (${NEED_BL1},yes)
  1197. BL1_SOURCES := $(sort ${BL1_SOURCES})
  1198. $(eval $(call MAKE_BL,bl1))
  1199. endif
  1200. ifeq (${NEED_BL2},yes)
  1201. ifeq (${RESET_TO_BL2}, 0)
  1202. FIP_BL2_ARGS := tb-fw
  1203. endif
  1204. BL2_SOURCES := $(sort ${BL2_SOURCES})
  1205. $(if ${BL2}, $(eval $(call TOOL_ADD_IMG,bl2,--${FIP_BL2_ARGS})),\
  1206. $(eval $(call MAKE_BL,bl2,${FIP_BL2_ARGS})))
  1207. endif
  1208. ifeq (${NEED_SCP_BL2},yes)
  1209. $(eval $(call TOOL_ADD_IMG,scp_bl2,--scp-fw))
  1210. endif
  1211. ifeq (${NEED_BL31},yes)
  1212. BL31_SOURCES += ${SPD_SOURCES}
  1213. # Sort BL31 source files to remove duplicates
  1214. BL31_SOURCES := $(sort ${BL31_SOURCES})
  1215. ifneq (${DECRYPTION_SUPPORT},none)
  1216. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw,,$(ENCRYPT_BL31))),\
  1217. $(eval $(call MAKE_BL,bl31,soc-fw,,$(ENCRYPT_BL31))))
  1218. else
  1219. $(if ${BL31}, $(eval $(call TOOL_ADD_IMG,bl31,--soc-fw)),\
  1220. $(eval $(call MAKE_BL,bl31,soc-fw)))
  1221. endif
  1222. endif
  1223. # If a BL32 image is needed but neither BL32 nor BL32_SOURCES is defined, the
  1224. # build system will call TOOL_ADD_IMG to print a warning message and abort the
  1225. # process. Note that the dependency on BL32 applies to the FIP only.
  1226. ifeq (${NEED_BL32},yes)
  1227. # Sort BL32 source files to remove duplicates
  1228. BL32_SOURCES := $(sort ${BL32_SOURCES})
  1229. BUILD_BL32 := $(if $(BL32),,$(if $(BL32_SOURCES),1))
  1230. ifneq (${DECRYPTION_SUPPORT},none)
  1231. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw,,$(ENCRYPT_BL32))),\
  1232. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw,,$(ENCRYPT_BL32))))
  1233. else
  1234. $(if ${BUILD_BL32}, $(eval $(call MAKE_BL,bl32,tos-fw)),\
  1235. $(eval $(call TOOL_ADD_IMG,bl32,--tos-fw)))
  1236. endif
  1237. endif
  1238. # If RMM image is needed but RMM is not defined, Test Realm Payload (TRP)
  1239. # needs to be built from RMM_SOURCES.
  1240. ifeq (${NEED_RMM},yes)
  1241. # Sort RMM source files to remove duplicates
  1242. RMM_SOURCES := $(sort ${RMM_SOURCES})
  1243. BUILD_RMM := $(if $(RMM),,$(if $(RMM_SOURCES),1))
  1244. $(if ${BUILD_RMM}, $(eval $(call MAKE_BL,rmm,rmm-fw)),\
  1245. $(eval $(call TOOL_ADD_IMG,rmm,--rmm-fw)))
  1246. endif
  1247. # Add the BL33 image if required by the platform
  1248. ifeq (${NEED_BL33},yes)
  1249. $(eval $(call TOOL_ADD_IMG,bl33,--nt-fw))
  1250. endif
  1251. ifeq (${NEED_BL2U},yes)
  1252. $(if ${BL2U}, $(eval $(call TOOL_ADD_IMG,bl2u,--ap-fwu-cfg,FWU_)),\
  1253. $(eval $(call MAKE_BL,bl2u,ap-fwu-cfg,FWU_)))
  1254. endif
  1255. # Expand build macros for the different images
  1256. ifeq (${NEED_FDT},yes)
  1257. $(eval $(call MAKE_DTBS,$(BUILD_PLAT)/fdts,$(FDT_SOURCES)))
  1258. endif
  1259. # Add Secure Partition packages
  1260. ifeq (${NEED_SP_PKG},yes)
  1261. $(BUILD_PLAT)/sp_gen.mk: ${SP_MK_GEN} ${SP_LAYOUT_FILE} | ${BUILD_PLAT}
  1262. ${Q}${PYTHON} "$<" "$@" $(filter-out $<,$^) $(BUILD_PLAT) ${COT}
  1263. sp: $(DTBS) $(BUILD_PLAT)/sp_gen.mk $(SP_PKGS)
  1264. @${ECHO_BLANK_LINE}
  1265. @echo "Built SP Images successfully"
  1266. @${ECHO_BLANK_LINE}
  1267. endif
  1268. locate-checkpatch:
  1269. ifndef CHECKPATCH
  1270. $(error "Please set CHECKPATCH to point to the Linux checkpatch.pl file, eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1271. else
  1272. ifeq (,$(wildcard ${CHECKPATCH}))
  1273. $(error "The file CHECKPATCH points to cannot be found, use eg: CHECKPATCH=../linux/scripts/checkpatch.pl")
  1274. endif
  1275. endif
  1276. clean:
  1277. @echo " CLEAN"
  1278. $(call SHELL_REMOVE_DIR,${BUILD_PLAT})
  1279. ifdef UNIX_MK
  1280. ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1281. else
  1282. # Clear the MAKEFLAGS as we do not want
  1283. # to pass the gnumake flags to nmake.
  1284. ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) clean
  1285. endif
  1286. ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
  1287. ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} clean
  1288. ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1289. realclean distclean:
  1290. @echo " REALCLEAN"
  1291. $(call SHELL_REMOVE_DIR,${BUILD_BASE})
  1292. $(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
  1293. ifdef UNIX_MK
  1294. ${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
  1295. else
  1296. # Clear the MAKEFLAGS as we do not want
  1297. # to pass the gnumake flags to nmake.
  1298. ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL)) realclean
  1299. endif
  1300. ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} realclean
  1301. ${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${ENCTOOLPATH} realclean
  1302. ${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
  1303. checkcodebase: locate-checkpatch
  1304. @echo " CHECKING STYLE"
  1305. @if test -d .git ; then \
  1306. git ls-files | grep -E -v 'libfdt|libc|docs|\.rst' | \
  1307. while read GIT_FILE ; \
  1308. do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
  1309. done ; \
  1310. else \
  1311. find . -type f -not -iwholename "*.git*" \
  1312. -not -iwholename "*build*" \
  1313. -not -iwholename "*libfdt*" \
  1314. -not -iwholename "*libc*" \
  1315. -not -iwholename "*docs*" \
  1316. -not -iwholename "*.rst" \
  1317. -exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
  1318. fi
  1319. checkpatch: locate-checkpatch
  1320. @echo " CHECKING STYLE"
  1321. @if test -n "${CHECKPATCH_OPTS}"; then \
  1322. echo " with ${CHECKPATCH_OPTS} option(s)"; \
  1323. fi
  1324. ${Q}COMMON_COMMIT=$$(git merge-base HEAD ${BASE_COMMIT}); \
  1325. for commit in `git rev-list --no-merges $$COMMON_COMMIT..HEAD`; \
  1326. do \
  1327. printf "\n[*] Checking style of '$$commit'\n\n"; \
  1328. git log --format=email "$$commit~..$$commit" \
  1329. -- ${CHECK_PATHS} | \
  1330. ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
  1331. git diff --format=email "$$commit~..$$commit" \
  1332. -- ${CHECK_PATHS} | \
  1333. ${CHECKPATCH} ${CHECKPATCH_OPTS} - || true; \
  1334. done
  1335. certtool: ${CRTTOOL}
  1336. ${CRTTOOL}: FORCE
  1337. ${Q}${MAKE} PLAT=${PLAT} USE_TBBR_DEFS=${USE_TBBR_DEFS} COT=${COT} OPENSSL_DIR=${OPENSSL_DIR} CRTTOOL=${CRTTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${CRTTOOLPATH} all
  1338. @${ECHO_BLANK_LINE}
  1339. @echo "Built $@ successfully"
  1340. @${ECHO_BLANK_LINE}
  1341. ifneq (${GENERATE_COT},0)
  1342. certificates: ${CRT_DEPS} ${CRTTOOL}
  1343. ${Q}${CRTTOOL} ${CRT_ARGS}
  1344. @${ECHO_BLANK_LINE}
  1345. @echo "Built $@ successfully"
  1346. @echo "Certificates can be found in ${BUILD_PLAT}"
  1347. @${ECHO_BLANK_LINE}
  1348. endif
  1349. ${BUILD_PLAT}/${FIP_NAME}: ${FIP_DEPS} ${FIPTOOL}
  1350. $(eval ${CHECK_FIP_CMD})
  1351. ${Q}${FIPTOOL} create ${FIP_ARGS} $@
  1352. ${Q}${FIPTOOL} info $@
  1353. @${ECHO_BLANK_LINE}
  1354. @echo "Built $@ successfully"
  1355. @${ECHO_BLANK_LINE}
  1356. ifneq (${GENERATE_COT},0)
  1357. fwu_certificates: ${FWU_CRT_DEPS} ${CRTTOOL}
  1358. ${Q}${CRTTOOL} ${FWU_CRT_ARGS}
  1359. @${ECHO_BLANK_LINE}
  1360. @echo "Built $@ successfully"
  1361. @echo "FWU certificates can be found in ${BUILD_PLAT}"
  1362. @${ECHO_BLANK_LINE}
  1363. endif
  1364. ${BUILD_PLAT}/${FWU_FIP_NAME}: ${FWU_FIP_DEPS} ${FIPTOOL}
  1365. $(eval ${CHECK_FWU_FIP_CMD})
  1366. ${Q}${FIPTOOL} create ${FWU_FIP_ARGS} $@
  1367. ${Q}${FIPTOOL} info $@
  1368. @${ECHO_BLANK_LINE}
  1369. @echo "Built $@ successfully"
  1370. @${ECHO_BLANK_LINE}
  1371. fiptool: ${FIPTOOL}
  1372. fip: ${BUILD_PLAT}/${FIP_NAME}
  1373. fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
  1374. ${FIPTOOL}: FORCE
  1375. ifdef UNIX_MK
  1376. ${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" FIPTOOL=${FIPTOOL} OPENSSL_DIR=${OPENSSL_DIR} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${FIPTOOLPATH} all
  1377. else
  1378. # Clear the MAKEFLAGS as we do not want
  1379. # to pass the gnumake flags to nmake.
  1380. ${Q}set MAKEFLAGS= && ${MSVC_NMAKE} /nologo /f ${FIPTOOLPATH}/Makefile.msvc FIPTOOLPATH=$(subst /,\,$(FIPTOOLPATH)) FIPTOOL=$(subst /,\,$(FIPTOOL))
  1381. endif
  1382. romlib.bin: libraries FORCE
  1383. ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} ENABLE_BTI=${ENABLE_BTI} ARM_ARCH_MINOR=${ARM_ARCH_MINOR} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
  1384. # Call print_memory_map tool
  1385. memmap: all
  1386. ${Q}${PYTHON} ${PRINT_MEMORY_MAP} ${BUILD_PLAT} ${INVERTED_MEMMAP}
  1387. doc:
  1388. @echo " BUILD DOCUMENTATION"
  1389. ${Q}${MAKE} --no-print-directory -C ${DOCS_PATH} html
  1390. enctool: ${ENCTOOL}
  1391. ${ENCTOOL}: FORCE
  1392. ${Q}${MAKE} PLAT=${PLAT} BUILD_INFO=0 OPENSSL_DIR=${OPENSSL_DIR} ENCTOOL=${ENCTOOL} DEBUG=${DEBUG} V=${V} --no-print-directory -C ${ENCTOOLPATH} all
  1393. @${ECHO_BLANK_LINE}
  1394. @echo "Built $@ successfully"
  1395. @${ECHO_BLANK_LINE}
  1396. cscope:
  1397. @echo " CSCOPE"
  1398. ${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
  1399. ${Q}cscope -b -q -k
  1400. help:
  1401. @echo "usage: ${MAKE} [PLAT=<platform>] [OPTIONS] [TARGET]"
  1402. @echo ""
  1403. @echo "PLAT is used to specify which platform you wish to build."
  1404. @echo "If no platform is specified, PLAT defaults to: ${DEFAULT_PLAT}"
  1405. @echo ""
  1406. @echo "platform = ${PLATFORM_LIST}"
  1407. @echo ""
  1408. @echo "Please refer to the User Guide for a list of all supported options."
  1409. @echo "Note that the build system doesn't track dependencies for build "
  1410. @echo "options. Therefore, if any of the build options are changed "
  1411. @echo "from a previous build, a clean build must be performed."
  1412. @echo ""
  1413. @echo "Supported Targets:"
  1414. @echo " all Build all individual bootloader binaries"
  1415. @echo " bl1 Build the BL1 binary"
  1416. @echo " bl2 Build the BL2 binary"
  1417. @echo " bl2u Build the BL2U binary"
  1418. @echo " bl31 Build the BL31 binary"
  1419. @echo " bl32 Build the BL32 binary. If ARCH=aarch32, then "
  1420. @echo " this builds secure payload specified by AARCH32_SP"
  1421. @echo " certificates Build the certificates (requires 'GENERATE_COT=1')"
  1422. @echo " fip Build the Firmware Image Package (FIP)"
  1423. @echo " fwu_fip Build the FWU Firmware Image Package (FIP)"
  1424. @echo " checkcodebase Check the coding style of the entire source tree"
  1425. @echo " checkpatch Check the coding style on changes in the current"
  1426. @echo " branch against BASE_COMMIT (default origin/master)"
  1427. @echo " clean Clean the build for the selected platform"
  1428. @echo " cscope Generate cscope index"
  1429. @echo " distclean Remove all build artifacts for all platforms"
  1430. @echo " certtool Build the Certificate generation tool"
  1431. @echo " enctool Build the Firmware encryption tool"
  1432. @echo " fiptool Build the Firmware Image Package (FIP) creation tool"
  1433. @echo " sp Build the Secure Partition Packages"
  1434. @echo " sptool Build the Secure Partition Package creation tool"
  1435. @echo " dtbs Build the Device Tree Blobs (if required for the platform)"
  1436. @echo " memmap Print the memory map of the built binaries"
  1437. @echo " doc Build html based documentation using Sphinx tool"
  1438. @echo ""
  1439. @echo "Note: most build targets require PLAT to be set to a specific platform."
  1440. @echo ""
  1441. @echo "example: build all targets for the FVP platform:"
  1442. @echo " CROSS_COMPILE=aarch64-none-elf- make PLAT=fvp all"
  1443. .PHONY: FORCE
  1444. FORCE:;