Patrick Georgi | 8480c0b | 2020-05-08 22:50:46 +0200 | [diff] [blame] | 1 | ## SPDX-License-Identifier: GPL-2.0-only |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 2 | |
| 3 | # force the shell to bash - the edksetup.sh script doesn't work with dash |
| 4 | export SHELL := env bash |
| 5 | |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 6 | project_name=Tianocore |
| 7 | project_dir=$(CURDIR)/tianocore |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 8 | project_git_repo=https://github.com/mrchromebox/edk2 |
Matt DeVillier | 94aa18f | 2021-07-21 17:49:58 -0500 | [diff] [blame] | 9 | project_git_branch=uefipayload_202107 |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 10 | upstream_git_repo=https://github.com/tianocore/edk2 |
| 11 | |
Benjamin Doron | 3db439e | 2020-02-25 03:43:02 +0000 | [diff] [blame] | 12 | build_flavor=-D BOOTLOADER=COREBOOT -D PCIE_BASE=$(CONFIG_MMCONF_BASE_ADDRESS) -DPS2_KEYBOARD_ENABLE |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 13 | |
| 14 | ifeq ($(CONFIG_TIANOCORE_UPSTREAM),y) |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 15 | TAG=upstream/master |
| 16 | else |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 17 | TAG=origin/$(project_git_branch) |
| 18 | endif |
| 19 | |
| 20 | ifneq ($(CONFIG_TIANOCORE_REVISION_ID),) |
| 21 | TAG=$(CONFIG_TIANOCORE_REVISION_ID) |
| 22 | endif |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 23 | |
| 24 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools |
| 25 | |
| 26 | ifeq ($(CONFIG_TIANOCORE_DEBUG),y) |
| 27 | BUILD_TYPE=DEBUG |
| 28 | else |
| 29 | BUILD_TYPE=RELEASE |
| 30 | endif |
| 31 | |
Matt DeVillier | ba7f116 | 2021-06-02 15:19:38 -0500 | [diff] [blame] | 32 | ifeq ($(CONFIG_TIANOCORE_CBMEM_LOGGING),y) |
| 33 | CBMEM=-D USE_CBMEM_FOR_CONSOLE=TRUE |
| 34 | endif |
| 35 | |
Sean Rhodes | 766e481 | 2021-07-12 19:35:51 +0100 | [diff] [blame] | 36 | ifeq ($(CONFIG_TIANOCORE_ABOVE_4G_MEMORY),y) |
| 37 | 4G=-D ABOVE_4G_MEMORY=TRUE |
| 38 | else |
| 39 | 4G=-D ABOVE_4G_MEMORY=FALSE |
| 40 | endif |
| 41 | |
Matt DeVillier | 61a3c8a | 2020-11-29 22:11:52 -0600 | [diff] [blame] | 42 | TIMEOUT=-D PLATFORM_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT) |
| 43 | |
Sean Rhodes | 766e481 | 2021-07-12 19:35:51 +0100 | [diff] [blame] | 44 | BUILD_STR=-q -a IA32 -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -t COREBOOT -b $(BUILD_TYPE) $(TIMEOUT) $(build_flavor) $(CBMEM) $(4G) |
Matt DeVillier | 4b9b446 | 2020-12-27 20:35:26 -0600 | [diff] [blame] | 45 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 46 | all: clean build |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 47 | |
| 48 | $(project_dir): |
| 49 | echo " Cloning $(project_name) from Git" |
Matt DeVillier | ee69f73 | 2019-03-01 13:10:26 -0600 | [diff] [blame] | 50 | git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 51 | cd $(project_dir); \ |
| 52 | git remote add upstream $(upstream_git_repo) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 53 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 54 | update: $(project_dir) |
| 55 | cd $(project_dir); \ |
| 56 | echo " Fetching new commits from the $(project_name) repo"; \ |
| 57 | git fetch --multiple origin upstream 2>/dev/null; \ |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 58 | if ! git rev-parse --verify -q $(TAG) >/dev/null; then \ |
| 59 | echo " $(TAG) is not a valid git reference"; \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 60 | exit 1; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 61 | fi; \ |
Matt DeVillier | ae48b42 | 2020-04-21 23:54:42 -0500 | [diff] [blame] | 62 | if git status --ignore-submodules=dirty | grep -qv clean; then \ |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 63 | echo " Checking out $(project_name) revision $(TAG)"; \ |
| 64 | git checkout --detach $(TAG); \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 65 | else \ |
| 66 | echo " Working directory not clean; will not overwrite"; \ |
Matt DeVillier | ae48b42 | 2020-04-21 23:54:42 -0500 | [diff] [blame] | 67 | fi; \ |
Benjamin Doron | e51f030 | 2020-07-03 04:39:23 +0000 | [diff] [blame] | 68 | git submodule update --init |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 69 | |
| 70 | checktools: |
| 71 | echo "Checking uuid-dev..." |
| 72 | echo "#include <uuid/uuid.h>" > libtest.c |
| 73 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c |
| 74 | $(HOSTCC) $(HOSTCCFLAGS) libtest.c -o libtest >/dev/null 2>&1 && echo " found uuid-dev." || \ |
Patrick Rudolph | e66b10f | 2018-06-16 11:14:16 +0200 | [diff] [blame] | 75 | ( echo " Not found."; echo "ERROR: please_install uuid-dev (libuuid-devel)"; exit 1 ) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 76 | rm -rf libtest.c libtest |
| 77 | echo "Checking nasm..." |
| 78 | type nasm > /dev/null 2>&1 && echo " found nasm." || \ |
| 79 | ( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) |
| 80 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 81 | build: update checktools |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 82 | unset CC; $(MAKE) -C $(project_dir)/BaseTools |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 83 | echo " build $(project_name) $(TAG)" |
Matt DeVillier | 98a47ac | 2020-04-29 15:29:27 -0500 | [diff] [blame] | 84 | if [ -n "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" ]; then \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 85 | echo " Copying custom bootsplash image"; \ |
| 86 | case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \ |
| 87 | /*) cp $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 88 | $(project_dir)/MdeModulePkg/Logo/Logo.bmp;; \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 89 | *) cp $(top)/$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 90 | $(project_dir)/MdeModulePkg/Logo/Logo.bmp;; \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 91 | esac \ |
| 92 | fi; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 93 | cd $(project_dir); \ |
| 94 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools; \ |
| 95 | export WORKSPACE=$(project_dir); \ |
| 96 | . ./edksetup.sh BaseTools; \ |
| 97 | grep -q "COREBOOT" $(project_dir)/Conf/tools_def.txt; \ |
| 98 | if [ $$? -ne 0 ]; then \ |
| 99 | cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \ |
| 100 | fi; \ |
| 101 | build $(BUILD_STR); \ |
Matt DeVillier | c6a3f34 | 2021-06-04 16:09:03 -0500 | [diff] [blame] | 102 | mv $(project_dir)/Build/UefiPayloadPkg*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd; \ |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 103 | git checkout MdeModulePkg/Logo/Logo.bmp > /dev/null 2>&1 || true |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 104 | |
| 105 | clean: |
| 106 | test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 |
| 107 | |
| 108 | distclean: |
| 109 | rm -rf $(project_dir) |
| 110 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 111 | .PHONY: all update checktools config build clean distclean |