1#/* @file
2#  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
3#
4#  SPDX-License-Identifier: BSD-2-Clause-Patent
5#
6#*/
7
8# Define the following variable to specify an alternative toolchain to the one located in your PATH:
9# - RVCT_TOOLS_PATH: for RVCT and RVCTLINUX toolchains
10
11EDK2_TOOLCHAIN ?= RVCTLINUX
12EDK2_ARCH ?= ARM
13EDK2_BUILD ?= DEBUG
14
15ifeq ($(EDK2_DSC),"")
16  $(error The Makfile macro 'EDK2_DSC' must be defined with an EDK2 DSC file.)
17endif
18ifeq ("$(EDK2_DSC)","ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc")
19  BUILD_FIP=1
20  BUILD_PATH=$(WORKSPACE)/Build/ArmVExpress-FVP-AArch64
21  UEFI_BIN=FVP_AARCH64_EFI.fd
22endif
23
24ifeq ("$(OS)","Windows_NT")
25export WORKSPACE?=$(PWD)
26export EDK_TOOLS_PATH ?= $(WORKSPACE)\BaseTools
27endif
28
29SHELL := /bin/bash
30SILENT ?= @
31ECHO ?= echo
32MAKE ?= make -i -k
33RM ?= rm -f
34
35.PHONY: all clean
36
37EDK2_CONF = Conf/BuildEnv.sh Conf/build_rule.txt Conf/target.txt Conf/tools_def.txt
38
39#
40# FIP Support
41#
42ifeq ($(BUILD_FIP),"1")
43  ifeq ($(FIP_BIN),"")
44    $(info Define location of the FIP to automatically update the package after building UEFI.)
45  endif
46endif
47
48all: $(EDK2_CONF)
49ifeq ("$(OS)","Windows_NT")
50	build -a $(EDK2_ARCH) -p $(EDK2_DSC) -t $(EDK2_TOOLCHAIN) -b $(EDK2_BUILD) $(EDK2_MACROS)
51else
52	. ./edksetup.sh; build -a $(EDK2_ARCH) -p $(EDK2_DSC) -t $(EDK2_TOOLCHAIN) -b $(EDK2_BUILD) $(EDK2_MACROS)
53endif
54ifeq ("$(BUILD_FIP)","1")
55ifneq ($(FIP_BIN),"")
56	$(SILENT)which fip_create ; \
57	if [ $$? -ne 0 ]; then \
58	  $(ECHO) "Warning: 'fip_create' tool is not in the PATH. The UEFI binary will not be added in the Firmware Image Package (FIP)."; \
59	else \
60	  fip_create --bl33 $(BUILD_PATH)/$(EDK2_BUILD)_$(EDK2_TOOLCHAIN)/FV/$(UEFI_BIN) --dump $(FIP_BIN); \
61	fi
62endif
63endif
64
65$(EDK2_CONF):
66ifeq ("$(OS)","Windows_NT")
67	copy $(EDK_TOOLS_PATH)\Conf\build_rule.template Conf\build_rule.txt
68	copy $(EDK_TOOLS_PATH)\Conf\FrameworkDatabase.template Conf\FrameworkDatabase.txt
69	copy $(EDK_TOOLS_PATH)\Conf\target.template Conf\target.txt
70	copy $(EDK_TOOLS_PATH)\Conf\tools_def.template Conf\tools_def.txt
71else
72	. ./edksetup.sh; $(MAKE) -C BaseTools
73endif
74
75clean:
76ifeq ("$(OS)","Windows_NT")
77	build -a $(EDK2_ARCH) -p $(EDK2_DSC) -t $(EDK2_TOOLCHAIN) -b $(EDK2_BUILD) $(EDK2_MACROS) cleanall
78else
79	. ./edksetup.sh; build -a $(EDK2_ARCH) -p $(EDK2_DSC) -t $(EDK2_TOOLCHAIN) -b $(EDK2_BUILD) $(EDK2_MACROS) cleanall; \
80	rm -Rf $(EDK2_CONF) Conf/.cache
81endif
82