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