blob: c280fe1b6df3967acfed10e718c243b153e79e7c [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
19STABLE_COMMIT_ID=315d9d08fd77db1024ccc5307823da8aaed85e2f
20TAG-$(CONFIG_TIANOCORE_MASTER)=origin/master
21TAG-$(CONFIG_TIANOCORE_STABLE)=$(STABLE_COMMIT_ID)
Gergely Kissaf152682017-12-24 22:42:14 +010022TAG-$(CONFIG_TIANOCORE_REVISION)=$(CONFIG_TIANOCORE_REVISION_ID)
Martin Roth4769cc32016-06-02 16:42:29 -060023
24project_name=Tianocore
25project_dir=$(CURDIR)/tianocore
26project_git_repo=https://github.com/tianocore/edk2
27
28export EDK_TOOLS_PATH=$(project_dir)/BaseTools
29
30ifeq ($(CONFIG_TIANOCORE_DEBUG),y)
31BUILD_TYPE=DEBUG
32else
33BUILD_TYPE=RELEASE
34endif
35
Lijian Zhaocf9ea552018-09-07 17:58:08 -070036ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
37TIMER=-DUSE_HPET_TIMER
38endif
39
Martin Roth4769cc32016-06-02 16:42:29 -060040ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y)
Lijian Zhaocf9ea552018-09-07 17:58:08 -070041 BUILD_STR=-a IA32 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32.dsc -b $(BUILD_TYPE) $(TIMER)
Martin Roth4769cc32016-06-02 16:42:29 -060042else
Lijian Zhaocf9ea552018-09-07 17:58:08 -070043 BUILD_STR=-a IA32 -a X64 -t COREBOOT -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -b $(BUILD_TYPE) $(TIMER)
Martin Roth4769cc32016-06-02 16:42:29 -060044endif
45
46all: build
47
48$(project_dir):
49 echo " Cloning $(project_name) from Git"
50 git clone $(project_git_repo) $(project_dir)
51
52fetch: $(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 Huang285f9f22017-06-26 13:36:57 -060069 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 Roth4769cc32016-06-02 16:42:29 -060075 if ! [ "$(TAG-y)" = "origin/master" ] ; then \
76 touch $(project_dir)/.version_$(STABLE_COMMIT_ID); \
77 fi; \
78 fi; \
79
80checktools:
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 Rudolphe66b10f2018-06-16 11:14:16 +020085 ( echo " Not found."; echo "ERROR: please_install uuid-dev (libuuid-devel)"; exit 1 )
Martin Roth4769cc32016-06-02 16:42:29 -060086 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
91build: $(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
105clean:
106 test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
107
108distclean:
109 rm -rf $(project_dir)
110
111.PHONY: all fetch checkout checktools config build clean distclean