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