aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a6a4e1a37c20b5e0ef1d2e054b98f75079dc640d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# directories
DESTDIR	?=
prefix	?= /usr/local
datadir	:= $(DESTDIR)$(prefix)/share/qemu-firmware


#############################################################################
# cross compiler auto detection

path := $(subst :, ,$(PATH))
system := $(shell uname -s | tr "A-Z" "a-z")

# first find cross binutils in path
find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path))))
# then check we have cross gcc too
find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1)))))
# finally strip off path + toolname so we get the prefix
find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1))))

powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64)
powerpc_cross_prefix := $(call find-cross-prefix,powerpc)
x86_64_cross_prefix := $(call find-cross-prefix,x86_64)
arm_cross_prefix := $(call find-cross-prefix,arm)
aarch64_cross_prefix := $(call find-cross-prefix,aarch64)


#############################################################################
# help text, common rules and targets

default help:
	@echo
	@echo "nothing is done by default"
	@echo
	@echo "build targets:"
	@echo "  edk2           -- build UEFI firmware"
	@echo
	@echo "other targets:"
	@echo "  clean          -- cleanup"
	@echo "  install        -- install blobs to $(datadir)"
	@echo
	@echo "You can set DESTDIR and prefix on the command line to"
	@echo "to change the install target directory, for example:"
	@echo "$ make prefix=/usr install"
	@echo

install:
	mkdir -p $(datadir)
	cp -avr blobs/edk2-* $(datadir)

clean: edk2-clean

submodule-%:
	git submodule update --init repos/$*


#############################################################################
# edk2 build rules

edk2 uefi: edk2-i386 edk2-x86_64 edk2-arm edk2-aarch64

edk2-i386: submodule-edk2
	sh scripts/compile-edk2.sh i386 $(x86_64_cross_prefix)

edk2-x86_64: submodule-edk2
	sh scripts/compile-edk2.sh x86_64 $(x86_64_cross_prefix)

edk2-arm: submodule-edk2
	sh scripts/compile-edk2.sh arm $(arm_cross_prefix)

edk2-aarch64: submodule-edk2
	sh scripts/compile-edk2.sh aarch64 $(aarch64_cross_prefix)

edk2-tools: submodule-edk2
	make -C repos/edk2/BaseTools

edk2-clean:
	make -C repos/edk2/BaseTools clean
	rm -rf repos/edk2/Build
	rm -rf repos/edk2/Conf/BuildEnv.sh
	rm -rf repos/edk2/Conf/build_rule.txt
	rm -rf repos/edk2/Conf/target.txt
	rm -rf repos/edk2/Conf/tools_def.txt