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