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 | |
Piotr Król | ef676b1 | 2018-07-24 02:13:07 +0200 | [diff] [blame] | 19 | # STABLE_COMMIT_ID represent official edk2 release, currently UDK2018 |
| 20 | STABLE_COMMIT_ID=3e72ffe8afdd03f1f89eba65c921cbdcb004cfee |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 21 | TAG-$(CONFIG_TIANOCORE_MASTER)=origin/master |
| 22 | TAG-$(CONFIG_TIANOCORE_STABLE)=$(STABLE_COMMIT_ID) |
Gergely Kiss | af15268 | 2017-12-24 22:42:14 +0100 | [diff] [blame] | 23 | TAG-$(CONFIG_TIANOCORE_REVISION)=$(CONFIG_TIANOCORE_REVISION_ID) |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 24 | |
| 25 | project_name=Tianocore |
| 26 | project_dir=$(CURDIR)/tianocore |
| 27 | project_git_repo=https://github.com/tianocore/edk2 |
| 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 | |
| 47 | all: build |
| 48 | |
| 49 | $(project_dir): |
| 50 | echo " Cloning $(project_name) from Git" |
| 51 | git clone $(project_git_repo) $(project_dir) |
| 52 | |
| 53 | fetch: $(project_dir) |
| 54 | cd $(project_dir); \ |
| 55 | git show $(TAG-y) >/dev/null 2>&1 ; \ |
| 56 | if [ $$? -ne 0 ] || [ "$(TAG-y)" = "origin/master" ]; then \ |
| 57 | echo " Fetching new commits from the $(project_name) repo"; \ |
| 58 | git fetch; \ |
| 59 | fi |
| 60 | |
| 61 | $(project_dir)/.version_$(TAG-y): fetch |
| 62 | if ! [[ -e $(project_dir)/.version_$(STABLE_COMMIT_ID) ]] || \ |
| 63 | [ "$(TAG-y)" = "origin/master" ] ; then \ |
| 64 | rm -f .version_*; \ |
| 65 | echo " Checking out $(project_name) revision $(TAG-y)"; \ |
| 66 | cd $(project_dir); \ |
| 67 | git checkout master; \ |
| 68 | git branch -D coreboot 2>/dev/null; \ |
| 69 | git checkout -b coreboot $(TAG-y); \ |
Evelyn Huang | 285f9f2 | 2017-06-26 13:36:57 -0600 | [diff] [blame] | 70 | for patch in $(CURDIR)/patches/*.patch; do \ |
| 71 | echo "Applying $$patch"; \ |
| 72 | cd $(project_dir); \ |
Piotr Król | 80346d0 | 2018-07-24 02:33:27 +0200 | [diff] [blame] | 73 | git am --keep-cr --ignore-space-change $$patch || \ |
Evelyn Huang | 285f9f2 | 2017-06-26 13:36:57 -0600 | [diff] [blame] | 74 | ( echo " Error when applying patches.\n"; git am --abort; exit 1; ); \ |
| 75 | done; \ |
Martin Roth | 4769cc3 | 2016-06-02 16:42:29 -0600 | [diff] [blame] | 76 | if ! [ "$(TAG-y)" = "origin/master" ] ; then \ |
| 77 | touch $(project_dir)/.version_$(STABLE_COMMIT_ID); \ |
| 78 | fi; \ |
| 79 | fi; \ |
| 80 | |
| 81 | checktools: |
| 82 | echo "Checking uuid-dev..." |
| 83 | echo "#include <uuid/uuid.h>" > libtest.c |
| 84 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c |
| 85 | $(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] | 86 | ( 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] | 87 | rm -rf libtest.c libtest |
| 88 | echo "Checking nasm..." |
| 89 | type nasm > /dev/null 2>&1 && echo " found nasm." || \ |
| 90 | ( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) |
| 91 | |
| 92 | build: $(project_dir)/.version_$(TAG-y) checktools |
| 93 | unset CC; $(MAKE) -C $(project_dir)/BaseTools |
| 94 | echo " build $(project_name) $(TAG-y)" |
| 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); \ |
| 104 | mv $(project_dir)/Build/CorebootPayloadPkg*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd |
| 105 | |
| 106 | clean: |
| 107 | test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 |
| 108 | |
| 109 | distclean: |
| 110 | rm -rf $(project_dir) |
| 111 | |
| 112 | .PHONY: all fetch checkout checktools config build clean distclean |