Makefile 49 KB

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