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 | |
| 19 | STABLE_COMMIT_ID=315d9d08fd77db1024ccc5307823da8aaed85e2f |
| 20 | TAG-$(CONFIG_TIANOCORE_MASTER)=origin/master |
| 21 | TAG-$(CONFIG_TIANOCORE_STABLE)=$(STABLE_COMMIT_ID) |
Gergely Kiss | af15268 | 2017-12-24 22:42:14 +0100 | [diff] [blame] | 22 | TAG-$(CONFIG_TIANOCORE_REVISION)=$(CONFIG_TIANOCORE_REVISION_ID) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 23 | |
| 24 | project_name=Tianocore |
| 25 | project_dir=$(CURDIR)/tianocore |
| 26 | project_git_repo=https://github.com/tianocore/edk2 |
| 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 | |
| 36 | ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y) |
| 37 | BUILD_STR=-a IA32 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc -b $(BUILD_TYPE) |
| 38 | else |
| 39 | BUILD_STR=-a IA32 -a X64 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -b $(BUILD_TYPE) |
| 40 | endif |
| 41 | |
| 42 | all: build |
| 43 | |
| 44 | $(project_dir): |
| 45 | echo " Cloning $(project_name) from Git" |
| 46 | git clone $(project_git_repo) $(project_dir) |
| 47 | |
| 48 | fetch: $(project_dir) |
| 49 | cd $(project_dir); \ |
| 50 | git show $(TAG-y) >/dev/null 2>&1 ; \ |
| 51 | if [ $$? -ne 0 ] || [ "$(TAG-y)" = "origin/master" ]; then \ |
| 52 | echo " Fetching new commits from the $(project_name) repo"; \ |
| 53 | git fetch; \ |
| 54 | fi |
| 55 | |
| 56 | $(project_dir)/.version_$(TAG-y): fetch |
| 57 | if ! [[ -e $(project_dir)/.version_$(STABLE_COMMIT_ID) ]] || \ |
| 58 | [ "$(TAG-y)" = "origin/master" ] ; then \ |
| 59 | rm -f .version_*; \ |
| 60 | echo " Checking out $(project_name) revision $(TAG-y)"; \ |
| 61 | cd $(project_dir); \ |
| 62 | git checkout master; \ |
| 63 | git branch -D coreboot 2>/dev/null; \ |
| 64 | git checkout -b coreboot $(TAG-y); \ |
Evelyn Huang | 285f9f2 | 2017-06-26 13:36:57 -0600 | [diff] [blame] | 65 | for patch in $(CURDIR)/patches/*.patch; do \ |
| 66 | echo "Applying $$patch"; \ |
| 67 | cd $(project_dir); \ |
| 68 | git am --keep-cr $$patch || \ |
| 69 | ( echo " Error when applying patches.\n"; git am --abort; exit 1; ); \ |
| 70 | done; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 71 | if ! [ "$(TAG-y)" = "origin/master" ] ; then \ |
| 72 | touch $(project_dir)/.version_$(STABLE_COMMIT_ID); \ |
| 73 | fi; \ |
| 74 | fi; \ |
| 75 | |
| 76 | checktools: |
| 77 | echo "Checking uuid-dev..." |
| 78 | echo "#include <uuid/uuid.h>" > libtest.c |
| 79 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c |
| 80 | $(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^] | 81 | ( 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] | 82 | rm -rf libtest.c libtest |
| 83 | echo "Checking nasm..." |
| 84 | type nasm > /dev/null 2>&1 && echo " found nasm." || \ |
| 85 | ( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) |
| 86 | |
| 87 | build: $(project_dir)/.version_$(TAG-y) checktools |
| 88 | unset CC; $(MAKE) -C $(project_dir)/BaseTools |
| 89 | echo " build $(project_name) $(TAG-y)" |
| 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); \ |
| 99 | mv $(project_dir)/Build/CorebootPayloadPkg*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd |
| 100 | |
| 101 | clean: |
| 102 | test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 |
| 103 | |
| 104 | distclean: |
| 105 | rm -rf $(project_dir) |
| 106 | |
| 107 | .PHONY: all fetch checkout checktools config build clean distclean |