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 | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 9 | project_git_branch=uefipayloadpkg |
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 |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 17 | # STABLE revision is MrChromebox's UefiPayloadPkg (ueifpayloadpkg) branch |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 18 | TAG=origin/$(project_git_branch) |
| 19 | endif |
| 20 | |
| 21 | ifneq ($(CONFIG_TIANOCORE_REVISION_ID),) |
| 22 | TAG=$(CONFIG_TIANOCORE_REVISION_ID) |
| 23 | endif |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 24 | |
| 25 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools |
| 26 | |
| 27 | ifeq ($(CONFIG_TIANOCORE_DEBUG),y) |
| 28 | BUILD_TYPE=DEBUG |
| 29 | else |
| 30 | BUILD_TYPE=RELEASE |
| 31 | endif |
| 32 | |
Matt DeVillier | ba7f116 | 2021-06-02 15:19:38 -0500 | [diff] [blame] | 33 | ifeq ($(CONFIG_TIANOCORE_CBMEM_LOGGING),y) |
| 34 | CBMEM=-D USE_CBMEM_FOR_CONSOLE=TRUE |
| 35 | endif |
| 36 | |
Matt DeVillier | 61a3c8a | 2020-11-29 22:11:52 -0600 | [diff] [blame] | 37 | TIMEOUT=-D PLATFORM_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT) |
| 38 | |
Matt DeVillier | ba7f116 | 2021-06-02 15:19:38 -0500 | [diff] [blame] | 39 | BUILD_STR=-q -a IA32 -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -t COREBOOT -b $(BUILD_TYPE) $(TIMEOUT) $(build_flavor) $(CBMEM) |
Matt DeVillier | 4b9b446 | 2020-12-27 20:35:26 -0600 | [diff] [blame] | 40 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 41 | all: clean build |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 42 | |
| 43 | $(project_dir): |
| 44 | echo " Cloning $(project_name) from Git" |
Matt DeVillier | ee69f73 | 2019-03-01 13:10:26 -0600 | [diff] [blame] | 45 | git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 46 | cd $(project_dir); \ |
| 47 | git remote add upstream $(upstream_git_repo) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 48 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 49 | update: $(project_dir) |
| 50 | cd $(project_dir); \ |
| 51 | echo " Fetching new commits from the $(project_name) repo"; \ |
| 52 | git fetch --multiple origin upstream 2>/dev/null; \ |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 53 | if ! git rev-parse --verify -q $(TAG) >/dev/null; then \ |
| 54 | echo " $(TAG) is not a valid git reference"; \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 55 | exit 1; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 56 | fi; \ |
Matt DeVillier | ae48b42 | 2020-04-21 23:54:42 -0500 | [diff] [blame] | 57 | if git status --ignore-submodules=dirty | grep -qv clean; then \ |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 58 | echo " Checking out $(project_name) revision $(TAG)"; \ |
| 59 | git checkout --detach $(TAG); \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 60 | else \ |
| 61 | echo " Working directory not clean; will not overwrite"; \ |
Matt DeVillier | ae48b42 | 2020-04-21 23:54:42 -0500 | [diff] [blame] | 62 | fi; \ |
Benjamin Doron | e51f030 | 2020-07-03 04:39:23 +0000 | [diff] [blame] | 63 | git submodule update --init |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 64 | |
| 65 | checktools: |
| 66 | echo "Checking uuid-dev..." |
| 67 | echo "#include <uuid/uuid.h>" > libtest.c |
| 68 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c |
| 69 | $(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] | 70 | ( 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] | 71 | rm -rf libtest.c libtest |
| 72 | echo "Checking nasm..." |
| 73 | type nasm > /dev/null 2>&1 && echo " found nasm." || \ |
| 74 | ( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) |
| 75 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 76 | build: update checktools |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 77 | unset CC; $(MAKE) -C $(project_dir)/BaseTools |
Lijian Zhao | 16562cb | 2019-07-20 13:06:03 +0800 | [diff] [blame] | 78 | echo " build $(project_name) $(TAG)" |
Matt DeVillier | 98a47ac | 2020-04-29 15:29:27 -0500 | [diff] [blame] | 79 | if [ -n "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" ]; then \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 80 | echo " Copying custom bootsplash image"; \ |
| 81 | case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \ |
| 82 | /*) cp $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 83 | $(project_dir)/MdeModulePkg/Logo/Logo.bmp;; \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 84 | *) cp $(top)/$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
Matt DeVillier | d3b49b4 | 2021-05-10 11:02:13 -0500 | [diff] [blame] | 85 | $(project_dir)/MdeModulePkg/Logo/Logo.bmp;; \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 86 | esac \ |
| 87 | fi; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 88 | cd $(project_dir); \ |
| 89 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools; \ |
| 90 | export WORKSPACE=$(project_dir); \ |
| 91 | . ./edksetup.sh BaseTools; \ |
| 92 | grep -q "COREBOOT" $(project_dir)/Conf/tools_def.txt; \ |
| 93 | if [ $$? -ne 0 ]; then \ |
| 94 | cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \ |
| 95 | fi; \ |
| 96 | build $(BUILD_STR); \ |
Matt DeVillier | c6a3f34 | 2021-06-04 16:09:03 -0500 | [diff] [blame^] | 97 | 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] | 98 | git checkout MdeModulePkg/Logo/Logo.bmp > /dev/null 2>&1 || true |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 99 | |
| 100 | clean: |
| 101 | test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 |
| 102 | |
| 103 | distclean: |
| 104 | rm -rf $(project_dir) |
| 105 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 106 | .PHONY: all update checktools config build clean distclean |