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