blob: bd02f48e03dfa27fe6f13072e5b3bd6f59366c3f [file] [log] [blame]
Martin Roth4769cc32016-06-02 16:42:29 -06001##
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
17export SHELL := env bash
18
Piotr Królef676b12018-07-24 02:13:07 +020019# STABLE_COMMIT_ID represent official edk2 release, currently UDK2018
20STABLE_COMMIT_ID=3e72ffe8afdd03f1f89eba65c921cbdcb004cfee
Martin Roth4769cc32016-06-02 16:42:29 -060021TAG-$(CONFIG_TIANOCORE_MASTER)=origin/master
22TAG-$(CONFIG_TIANOCORE_STABLE)=$(STABLE_COMMIT_ID)
Gergely Kissaf152682017-12-24 22:42:14 +010023TAG-$(CONFIG_TIANOCORE_REVISION)=$(CONFIG_TIANOCORE_REVISION_ID)
Martin Roth4769cc32016-06-02 16:42:29 -060024
25project_name=Tianocore
26project_dir=$(CURDIR)/tianocore
27project_git_repo=https://github.com/tianocore/edk2
28
29export EDK_TOOLS_PATH=$(project_dir)/BaseTools
30
31ifeq ($(CONFIG_TIANOCORE_DEBUG),y)
32BUILD_TYPE=DEBUG
33else
34BUILD_TYPE=RELEASE
35endif
36
Lijian Zhaocf9ea552018-09-07 17:58:08 -070037ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
38TIMER=-DUSE_HPET_TIMER
39endif
40
Martin Roth4769cc32016-06-02 16:42:29 -060041ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y)
Lijian Zhaocf9ea552018-09-07 17:58:08 -070042 BUILD_STR=-a IA32 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc -b $(BUILD_TYPE) $(TIMER)
Martin Roth4769cc32016-06-02 16:42:29 -060043else
Lijian Zhaocf9ea552018-09-07 17:58:08 -070044 BUILD_STR=-a IA32 -a X64 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -b $(BUILD_TYPE) $(TIMER)
Martin Roth4769cc32016-06-02 16:42:29 -060045endif
46
47all: build
48
49$(project_dir):
50 echo " Cloning $(project_name) from Git"
51 git clone $(project_git_repo) $(project_dir)
52
53fetch: $(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 Huang285f9f22017-06-26 13:36:57 -060070 for patch in $(CURDIR)/patches/*.patch; do \
71 echo "Applying $$patch"; \
72 cd $(project_dir); \
Piotr Król80346d02018-07-24 02:33:27 +020073 git am --keep-cr --ignore-space-change $$patch || \
Evelyn Huang285f9f22017-06-26 13:36:57 -060074 ( echo " Error when applying patches.\n"; git am --abort; exit 1; ); \
75 done; \
Martin Roth4769cc32016-06-02 16:42:29 -060076 if ! [ "$(TAG-y)" = "origin/master" ] ; then \
77 touch $(project_dir)/.version_$(STABLE_COMMIT_ID); \
78 fi; \
79 fi; \
80
81checktools:
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 Rudolphe66b10f2018-06-16 11:14:16 +020086 ( echo " Not found."; echo "ERROR: please_install uuid-dev (libuuid-devel)"; exit 1 )
Martin Roth4769cc32016-06-02 16:42:29 -060087 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
92build: $(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
106clean:
107 test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
108
109distclean:
110 rm -rf $(project_dir)
111
112.PHONY: all fetch checkout checktools config build clean distclean