forked from ipxe/pipxe
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
78 lines (60 loc) · 2 KB
/
Makefile
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
RASPI_VERSION = RPi4
FW_URL := https://github.com/raspberrypi/firmware/branches/stable/boot
SHELL := /bin/bash
EFI_BUILD := RELEASE
EFI_ARCH := AARCH64
EFI_TOOLCHAIN := GCC5
EFI_TIMEOUT := 3
EFI_FLAGS := --pcd=PcdPlatformBootTimeOut=$(EFI_TIMEOUT)
EFI_DSC := edk2-platforms/Platform/RaspberryPi/$(RASPI_VERSION)/$(RASPI_VERSION).dsc
EFI_FD := Build/$(RASPI_VERSION)/$(EFI_BUILD)_$(EFI_TOOLCHAIN)/FV/RPI_EFI.fd
IPXE_CROSS := aarch64-linux-gnu-
IPXE_SRC := ipxe/src
IPXE_TGT := bin-arm64-efi/snp.efi
IPXE_EFI := $(IPXE_SRC)/$(IPXE_TGT)
SDCARD_MB := 32
export MTOOLSRC := mtoolsrc
all : sdcard sdcard.img sdcard.zip
submodules :
git submodule update --init --recursive
patches :
./patch.sh $(RASPI_VERSION)
firmware :
if [ ! -e firmware ] ; then \
$(RM) -rf firmware-tmp ; \
svn export $(FW_URL) firmware-tmp && \
mv firmware-tmp firmware ; \
fi
efi : $(EFI_FD)
efi-basetools : submodules patches
$(MAKE) -C edk2/BaseTools
$(EFI_FD) : submodules patches efi-basetools
. ./edksetup.sh && \
build -b $(EFI_BUILD) -a $(EFI_ARCH) -t $(EFI_TOOLCHAIN) \
-p $(EFI_DSC) $(EFI_FLAGS)
ipxe : $(IPXE_EFI)
$(IPXE_EFI) : submodules patches
$(MAKE) -C $(IPXE_SRC) CROSS=$(IPXE_CROSS) CONFIG=rpi $(IPXE_TGT)
sdcard : firmware efi ipxe
$(RM) -rf sdcard
mkdir -p sdcard
cp -r $(sort $(filter-out firmware/kernel%,$(wildcard firmware/*))) \
sdcard/
cp config.txt $(EFI_FD) edk2/License.txt sdcard/
mkdir -p sdcard/efi/boot
cp $(IPXE_EFI) sdcard/efi/boot/bootaa64.efi
cp ipxe/COPYING* sdcard/
sdcard.img : sdcard
truncate -s $(SDCARD_MB)M $@
mpartition -I -c -b 32 -s 32 -h 64 -t $(SDCARD_MB) -a "z:"
mformat -v "piPXE" "z:"
mcopy -s sdcard/* "z:"
sdcard.zip : sdcard
$(RM) -f $@
( pushd $< ; zip -q -r ../$@ * ; popd )
update :
git submodule foreach git pull origin master
.PHONY : submodules patches firmware efi efi-basetools $(EFI_FD) ipxe $(IPXE_EFI) sdcard sdcard.img
clean :
$(RM) -rf firmware Build sdcard sdcard.img sdcard.zip
if [ -d $(IPXE_SRC) ] ; then $(MAKE) -C $(IPXE_SRC) clean ; fi