blob: 46bc2bdffad594b7d592dfbbd4a4119ab7aa6e13 [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
Martin Roth4769cc32016-06-02 16:42:29 -060019project_name=Tianocore
20project_dir=$(CURDIR)/tianocore
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060021project_git_repo=https://github.com/mrchromebox/edk2
22project_git_branch=coreboot_fb
23upstream_git_repo=https://github.com/tianocore/edk2
24
Lijian Zhao16562cb2019-07-20 13:06:03 +080025ifeq ($(CONFIG_TIANOCORE_UEFIPAYLOAD),y)
26bootloader=UefiPayloadPkg
Benjamin Doron3db439e2020-02-25 03:43:02 +000027build_flavor=-D BOOTLOADER=COREBOOT -D PCIE_BASE=$(CONFIG_MMCONF_BASE_ADDRESS) -DPS2_KEYBOARD_ENABLE
Lijian Zhao16562cb2019-07-20 13:06:03 +080028TAG=upstream/master
29else
30bootloader=CorebootPayloadPkg
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060031# STABLE revision is MrChromebox's coreboot framebuffer (coreboot_fb) branch
Lijian Zhao16562cb2019-07-20 13:06:03 +080032TAG=origin/$(project_git_branch)
33endif
34
35ifneq ($(CONFIG_TIANOCORE_REVISION_ID),)
36TAG=$(CONFIG_TIANOCORE_REVISION_ID)
37endif
Martin Roth4769cc32016-06-02 16:42:29 -060038
39export EDK_TOOLS_PATH=$(project_dir)/BaseTools
40
41ifeq ($(CONFIG_TIANOCORE_DEBUG),y)
42BUILD_TYPE=DEBUG
43else
44BUILD_TYPE=RELEASE
45endif
46
Lijian Zhaocf9ea552018-09-07 17:58:08 -070047ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
48TIMER=-DUSE_HPET_TIMER
49endif
50
Martin Roth4769cc32016-06-02 16:42:29 -060051ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y)
Angel Pons6d295ac2020-02-25 21:35:45 +010052 BUILD_STR=-q -a IA32 -t COREBOOT -p $(bootloader)/$(bootloader)Ia32.dsc -b $(BUILD_TYPE) $(TIMER) $(build_flavor)
Martin Roth4769cc32016-06-02 16:42:29 -060053else
Angel Pons6d295ac2020-02-25 21:35:45 +010054 BUILD_STR=-q -a IA32 -a X64 -t COREBOOT -p $(bootloader)/$(bootloader)Ia32X64.dsc -b $(BUILD_TYPE) $(TIMER) $(build_flavor)
Martin Roth4769cc32016-06-02 16:42:29 -060055endif
56
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060057all: clean build
Martin Roth4769cc32016-06-02 16:42:29 -060058
59$(project_dir):
60 echo " Cloning $(project_name) from Git"
Matt DeVillieree69f732019-03-01 13:10:26 -060061 git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060062 cd $(project_dir); \
63 git remote add upstream $(upstream_git_repo)
Martin Roth4769cc32016-06-02 16:42:29 -060064
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060065update: $(project_dir)
66 cd $(project_dir); \
67 echo " Fetching new commits from the $(project_name) repo"; \
68 git fetch --multiple origin upstream 2>/dev/null; \
Lijian Zhao16562cb2019-07-20 13:06:03 +080069 if ! git rev-parse --verify -q $(TAG) >/dev/null; then \
70 echo " $(TAG) is not a valid git reference"; \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060071 exit 1; \
Martin Roth4769cc32016-06-02 16:42:29 -060072 fi; \
Matt DeVillierae48b422020-04-21 23:54:42 -050073 if git status --ignore-submodules=dirty | grep -qv clean; then \
Lijian Zhao16562cb2019-07-20 13:06:03 +080074 echo " Checking out $(project_name) revision $(TAG)"; \
75 git checkout --detach $(TAG); \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060076 else \
77 echo " Working directory not clean; will not overwrite"; \
Matt DeVillierae48b422020-04-21 23:54:42 -050078 fi; \
79 git submodule update --init --recursive
Martin Roth4769cc32016-06-02 16:42:29 -060080
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
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060092build: update checktools
Martin Roth4769cc32016-06-02 16:42:29 -060093 unset CC; $(MAKE) -C $(project_dir)/BaseTools
Lijian Zhao16562cb2019-07-20 13:06:03 +080094 echo " build $(project_name) $(TAG)"
Matt DeVillierff793412019-02-21 22:41:59 -060095 if [ -n $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) ]; then \
96 echo " Copying custom bootsplash image"; \
97 case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \
98 /*) cp $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
99 $(project_dir)/CorebootPayloadPkg/Logo/Logo.bmp;; \
100 *) cp $(top)/$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
101 $(project_dir)/CorebootPayloadPkg/Logo/Logo.bmp;; \
102 esac \
103 fi; \
Martin Roth4769cc32016-06-02 16:42:29 -0600104 cd $(project_dir); \
105 export EDK_TOOLS_PATH=$(project_dir)/BaseTools; \
106 export WORKSPACE=$(project_dir); \
107 . ./edksetup.sh BaseTools; \
108 grep -q "COREBOOT" $(project_dir)/Conf/tools_def.txt; \
109 if [ $$? -ne 0 ]; then \
110 cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \
111 fi; \
112 build $(BUILD_STR); \
Lijian Zhao16562cb2019-07-20 13:06:03 +0800113 mv $(project_dir)/Build/$(bootloader)*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd; \
Matt DeVillier74dec7f2019-03-15 14:18:09 -0500114 git checkout CorebootPayloadPkg/Logo/Logo.bmp > /dev/null 2>&1 || true
Martin Roth4769cc32016-06-02 16:42:29 -0600115
116clean:
117 test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
118
119distclean:
120 rm -rf $(project_dir)
121
Matt DeVillier38b6ccf2019-02-20 23:46:15 -0600122.PHONY: all update checktools config build clean distclean