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