blob: 7e83388ba6e27b5962d022f690ab4d43c70f5759 [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##
Patrick Georgi8480c0b2020-05-08 22:50:46 +02006## SPDX-License-Identifier: GPL-2.0-only
Martin Roth4769cc32016-06-02 16:42:29 -06007
8# force the shell to bash - the edksetup.sh script doesn't work with dash
9export SHELL := env bash
10
Martin Roth4769cc32016-06-02 16:42:29 -060011project_name=Tianocore
12project_dir=$(CURDIR)/tianocore
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060013project_git_repo=https://github.com/mrchromebox/edk2
14project_git_branch=coreboot_fb
15upstream_git_repo=https://github.com/tianocore/edk2
16
Lijian Zhao16562cb2019-07-20 13:06:03 +080017ifeq ($(CONFIG_TIANOCORE_UEFIPAYLOAD),y)
18bootloader=UefiPayloadPkg
Matt DeVillierb4a0ec52020-04-22 02:03:30 -050019logo_pkg=MdeModulePkg
Benjamin Doron3db439e2020-02-25 03:43:02 +000020build_flavor=-D BOOTLOADER=COREBOOT -D PCIE_BASE=$(CONFIG_MMCONF_BASE_ADDRESS) -DPS2_KEYBOARD_ENABLE
Lijian Zhao16562cb2019-07-20 13:06:03 +080021TAG=upstream/master
22else
23bootloader=CorebootPayloadPkg
Matt DeVillierb4a0ec52020-04-22 02:03:30 -050024logo_pkg=CorebootPayloadPkg
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060025# STABLE revision is MrChromebox's coreboot framebuffer (coreboot_fb) branch
Lijian Zhao16562cb2019-07-20 13:06:03 +080026TAG=origin/$(project_git_branch)
27endif
28
29ifneq ($(CONFIG_TIANOCORE_REVISION_ID),)
30TAG=$(CONFIG_TIANOCORE_REVISION_ID)
31endif
Martin Roth4769cc32016-06-02 16:42:29 -060032
33export EDK_TOOLS_PATH=$(project_dir)/BaseTools
34
35ifeq ($(CONFIG_TIANOCORE_DEBUG),y)
36BUILD_TYPE=DEBUG
37else
38BUILD_TYPE=RELEASE
39endif
40
Lijian Zhaocf9ea552018-09-07 17:58:08 -070041ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
42TIMER=-DUSE_HPET_TIMER
43endif
44
Martin Roth4769cc32016-06-02 16:42:29 -060045ifeq ($(CONFIG_TIANOCORE_TARGET_IA32), y)
Angel Pons6d295ac2020-02-25 21:35:45 +010046 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 -060047else
Angel Pons6d295ac2020-02-25 21:35:45 +010048 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 -060049endif
50
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060051all: clean build
Martin Roth4769cc32016-06-02 16:42:29 -060052
53$(project_dir):
54 echo " Cloning $(project_name) from Git"
Matt DeVillieree69f732019-03-01 13:10:26 -060055 git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060056 cd $(project_dir); \
57 git remote add upstream $(upstream_git_repo)
Martin Roth4769cc32016-06-02 16:42:29 -060058
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060059update: $(project_dir)
60 cd $(project_dir); \
61 echo " Fetching new commits from the $(project_name) repo"; \
62 git fetch --multiple origin upstream 2>/dev/null; \
Lijian Zhao16562cb2019-07-20 13:06:03 +080063 if ! git rev-parse --verify -q $(TAG) >/dev/null; then \
64 echo " $(TAG) is not a valid git reference"; \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060065 exit 1; \
Martin Roth4769cc32016-06-02 16:42:29 -060066 fi; \
Matt DeVillierae48b422020-04-21 23:54:42 -050067 if git status --ignore-submodules=dirty | grep -qv clean; then \
Lijian Zhao16562cb2019-07-20 13:06:03 +080068 echo " Checking out $(project_name) revision $(TAG)"; \
69 git checkout --detach $(TAG); \
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060070 else \
71 echo " Working directory not clean; will not overwrite"; \
Matt DeVillierae48b422020-04-21 23:54:42 -050072 fi; \
73 git submodule update --init --recursive
Martin Roth4769cc32016-06-02 16:42:29 -060074
75checktools:
76 echo "Checking uuid-dev..."
77 echo "#include <uuid/uuid.h>" > libtest.c
78 echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" >> libtest.c
79 $(HOSTCC) $(HOSTCCFLAGS) libtest.c -o libtest >/dev/null 2>&1 && echo " found uuid-dev." || \
Patrick Rudolphe66b10f2018-06-16 11:14:16 +020080 ( echo " Not found."; echo "ERROR: please_install uuid-dev (libuuid-devel)"; exit 1 )
Martin Roth4769cc32016-06-02 16:42:29 -060081 rm -rf libtest.c libtest
82 echo "Checking nasm..."
83 type nasm > /dev/null 2>&1 && echo " found nasm." || \
84 ( echo " Not found."; echo "Error: Please install nasm."; exit 1 )
85
Matt DeVillier38b6ccf2019-02-20 23:46:15 -060086build: update checktools
Martin Roth4769cc32016-06-02 16:42:29 -060087 unset CC; $(MAKE) -C $(project_dir)/BaseTools
Lijian Zhao16562cb2019-07-20 13:06:03 +080088 echo " build $(project_name) $(TAG)"
Matt DeVillier98a47ac2020-04-29 15:29:27 -050089 if [ -n "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" ]; then \
Matt DeVillierff793412019-02-21 22:41:59 -060090 echo " Copying custom bootsplash image"; \
91 case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \
92 /*) cp $(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
Matt DeVillierb4a0ec52020-04-22 02:03:30 -050093 $(project_dir)/$(logo_pkg)/Logo/Logo.bmp;; \
Matt DeVillierff793412019-02-21 22:41:59 -060094 *) cp $(top)/$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
Matt DeVillierb4a0ec52020-04-22 02:03:30 -050095 $(project_dir)/$(logo_pkg)/Logo/Logo.bmp;; \
Matt DeVillierff793412019-02-21 22:41:59 -060096 esac \
97 fi; \
Martin Roth4769cc32016-06-02 16:42:29 -060098 cd $(project_dir); \
99 export EDK_TOOLS_PATH=$(project_dir)/BaseTools; \
100 export WORKSPACE=$(project_dir); \
101 . ./edksetup.sh BaseTools; \
102 grep -q "COREBOOT" $(project_dir)/Conf/tools_def.txt; \
103 if [ $$? -ne 0 ]; then \
104 cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \
105 fi; \
106 build $(BUILD_STR); \
Lijian Zhao16562cb2019-07-20 13:06:03 +0800107 mv $(project_dir)/Build/$(bootloader)*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd; \
Matt DeVillierb4a0ec52020-04-22 02:03:30 -0500108 git checkout $(logo_pkg)/Logo/Logo.bmp > /dev/null 2>&1 || true
Martin Roth4769cc32016-06-02 16:42:29 -0600109
110clean:
111 test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
112
113distclean:
114 rm -rf $(project_dir)
115
Matt DeVillier38b6ccf2019-02-20 23:46:15 -0600116.PHONY: all update checktools config build clean distclean