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