Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
| 4 | ## Copyright (C) 2017 Google Inc. |
| 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
| 8 | ## the Free Software Foundation; version 2 of the License. |
| 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
| 15 | |
| 16 | # force the shell to bash - the edksetup.sh script doesn't work with dash |
| 17 | export SHELL := env bash |
| 18 | |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 19 | project_name=Tianocore |
| 20 | project_dir=$(CURDIR)/tianocore |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 21 | project_git_repo=https://github.com/mrchromebox/edk2 |
| 22 | project_git_branch=coreboot_fb |
| 23 | upstream_git_repo=https://github.com/tianocore/edk2 |
| 24 | |
| 25 | # STABLE revision is MrChromebox's coreboot framebuffer (coreboot_fb) branch |
| 26 | TAG-$(CONFIG_TIANOCORE_STABLE)=origin/$(project_git_branch) |
| 27 | TAG-$(CONFIG_TIANOCORE_REVISION)=$(CONFIG_TIANOCORE_REVISION_ID) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 28 | |
| 29 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools |
| 30 | |
| 31 | ifeq ($(CONFIG_TIANOCORE_DEBUG),y) |
| 32 | BUILD_TYPE=DEBUG |
| 33 | else |
| 34 | BUILD_TYPE=RELEASE |
| 35 | endif |
| 36 | |
Lijian Zhao | cf9ea55 | 2018-09-07 17:58:08 -0700 | [diff] [blame] | 37 | ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y) |
| 38 | TIMER=-DUSE_HPET_TIMER |
| 39 | endif |
| 40 | |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 41 | ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y) |
Lijian Zhao | cf9ea55 | 2018-09-07 17:58:08 -0700 | [diff] [blame] | 42 | BUILD_STR=-a IA32 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc -b $(BUILD_TYPE) $(TIMER) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 43 | else |
Lijian Zhao | cf9ea55 | 2018-09-07 17:58:08 -0700 | [diff] [blame] | 44 | BUILD_STR=-a IA32 -a X64 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -b $(BUILD_TYPE) $(TIMER) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 45 | endif |
| 46 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 47 | all: clean build |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 48 | |
| 49 | $(project_dir): |
| 50 | echo " Cloning $(project_name) from Git" |
Matt DeVillier | ee69f73 | 2019-03-01 13:10:26 -0600 | [diff] [blame^] | 51 | git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 52 | cd $(project_dir); \ |
| 53 | git remote add upstream $(upstream_git_repo) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 54 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 55 | update: $(project_dir) |
| 56 | cd $(project_dir); \ |
| 57 | echo " Fetching new commits from the $(project_name) repo"; \ |
| 58 | git fetch --multiple origin upstream 2>/dev/null; \ |
| 59 | if ! git rev-parse --verify -q $(TAG-y) >/dev/null; then \ |
| 60 | echo " $(TAG-y) is not a valid git reference"; \ |
| 61 | exit 1; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 62 | fi; \ |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 63 | if git describe --all --dirty | grep -qv dirty; then \ |
| 64 | echo " Checking out $(project_name) revision $(TAG-y)"; \ |
| 65 | git checkout --detach $(TAG-y); \ |
| 66 | else \ |
| 67 | echo " Working directory not clean; will not overwrite"; \ |
| 68 | fi |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 69 | |
| 70 | checktools: |
| 71 | echo "Checking uuid-dev..." |
| 72 | echo "#include <uuid/uuid.h>" > libtest.c |
| 73 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c |
| 74 | $(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] | 75 | ( 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] | 76 | rm -rf libtest.c libtest |
| 77 | echo "Checking nasm..." |
| 78 | type nasm > /dev/null 2>&1 && echo " found nasm." || \ |
| 79 | ( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) |
| 80 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 81 | build: update checktools |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 82 | unset CC; $(MAKE) -C $(project_dir)/BaseTools |
| 83 | echo " build $(project_name) $(TAG-y)" |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 84 | if [ -n $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) ]; then \ |
| 85 | echo " Copying custom bootsplash image"; \ |
| 86 | case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \ |
| 87 | /*) cp $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
| 88 | $(project_dir)/CorebootPayloadPkg/Logo/Logo.bmp;; \ |
| 89 | *) cp $(top)/$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \ |
| 90 | $(project_dir)/CorebootPayloadPkg/Logo/Logo.bmp;; \ |
| 91 | esac \ |
| 92 | fi; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 93 | cd $(project_dir); \ |
| 94 | export EDK_TOOLS_PATH=$(project_dir)/BaseTools; \ |
| 95 | export WORKSPACE=$(project_dir); \ |
| 96 | . ./edksetup.sh BaseTools; \ |
| 97 | grep -q "COREBOOT" $(project_dir)/Conf/tools_def.txt; \ |
| 98 | if [ $$? -ne 0 ]; then \ |
| 99 | cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \ |
| 100 | fi; \ |
| 101 | build $(BUILD_STR); \ |
Matt DeVillier | ff79341 | 2019-02-21 22:41:59 -0600 | [diff] [blame] | 102 | mv $(project_dir)/Build/CorebootPayloadPkg*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd; \ |
| 103 | git checkout CorebootPayloadPkg/Logo/Logo.bmp > /dev/null 2>&1 |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 104 | |
| 105 | clean: |
| 106 | test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 |
| 107 | |
| 108 | distclean: |
| 109 | rm -rf $(project_dir) |
| 110 | |
Matt DeVillier | 38b6ccf | 2019-02-20 23:46:15 -0600 | [diff] [blame] | 111 | .PHONY: all update checktools config build clean distclean |