top.mk 1.92 KB
Newer Older
1
2
3
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) Arm Limited, 2020
4
5
6
7
8
9
10
11
12
13
#
# Makefile Conventions:
# Variable names:
# TARGET:   U-Boot configuration name; TFA, OP-TEE, and other target
#           configuration names key off the U-Boot configuration; this is a
#           U-Boot oriented tool after all.
# *_PATH:   Full path to project source directories or other assets
# *_OUTPUT: Build directories for each of the sub projects
# *_EXTRA:  Extra parameters to the make call. Gets added to make targets, e.g.
#           "$(MAKE) -C ${PROJECT_PATH} ... ${PROJECT_EXTRA} ..."
14

15
16
17
ifndef TARGET
  $(error TARGET is not set)
endif
18
19

# Set some defaults that can be overridden by the target  makefile include
20
export DT_PATH    := $(CURDIR)/devicetree-rebasing
21
export DT_OUTPUT  := $(DT_PATH)
22
23
export TFA_PATH   := $(CURDIR)/arm-trusted-firmware
export UBOOT_PATH := $(CURDIR)/u-boot
24
25
26
27
28
29
30
31
32
33
34
35

# Give the option of building in a separate directory
ifdef BUILD_OUTPUT
  __BUILD := $(realpath $(BUILD_OUTPUT))
  export TFA_OUTPUT := $(__BUILD)/tfa
  export TFA_EXTRA += BUILD_BASE=$(TFA_OUTPUT)
  export UBOOT_OUTPUT := $(__BUILD)/u-boot
  export UBOOT_EXTRA += KBUILD_OUTPUT=$(UBOOT_OUTPUT)
else
  export TFA_OUTPUT := $(TFA_PATH)/build
  export UBOOT_OUTPUT := $(UBOOT_PATH)
endif
36

37
all: tfa-fip
38

39
clean:
40
	$(MAKE) -C $(UBOOT_PATH) $(UBOOT_EXTRA) mrproper
41
42
43
	cd $(TFA_PATH) && git clean -fdx
	cd $(CURDIR)/mv-ddr && git clean -fdx

44
45
$(UBOOT_OUTPUT)/.config:
	mkdir -p $(UBOOT_OUTPUT)
46
	$(MAKE) -C $(UBOOT_PATH) $(UBOOT_EXTRA) $(TARGET)_defconfig
47
48
49
50
51
	echo CONFIG_CMD_BOOTEFI_HELLO=y >> $(UBOOT_OUTPUT)/.config
	echo CONFIG_CMD_BOOTEFI_SELFTEST=y >> $(UBOOT_OUTPUT)/.config
	echo CONFIG_CMD_NVEDIT_EFI=y >> $(UBOOT_OUTPUT)/.config
	echo CONFIG_CMD_EFIDEBUG=y >> $(UBOOT_OUTPUT)/.config
	echo CONFIG_CMD_GPT=y >> $(UBOOT_OUTPUT)/.config
52
	$(MAKE) -C $(UBOOT_PATH) $(UBOOT_EXTRA) olddefconfig
53

54
55
%: $(UBOOT_OUTPUT)/.config
	$(MAKE) -f scripts/main.mk TARGET=$(TARGET) $@
56
57

.PHONY: $(UBOOT_OUTPUT)/.config