Compiling EDK2 UEFI on FreeBSD

I am trying to compile an "Out Of Tree" EDK2 UEFI Github from JMcNeil on FreeBSD 13.4-RELEASE.

We have in ports tree /sysutils/edk2 with flavors. I use rpi3 for testing.

When testing I mean I capture the output from it compiling and save to a file to massage.

When I say massage I mean convert something I can compile the quart64_uefi repository with.
Its instructions are barebone and says run build.sh and that fails.
That is assuming you already have the toolchain installed and working. Also shortcuts to GCC5 and all kinds of prep.

If this were u-boot I would be creating a slave port for my build but edk2 port uses flavors and I dont want to try and add my own flavor.

So please help me line by line as I try and understand what happens at compile time.

My first example is this path-adapted command:
cd /quartz64_uefi/edk2/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli && tar cf - * | tar xf - -C ../../../../BaseTools/Source/C/BrotliCompress/brotli

So It tars a directories files and pipes it to another directory? Is that what I am seeing? What is brotli ?
 
Then it moves build files to the Conf directory.

cp /quartz64_uefi/edk2/BaseTools/Conf/build_rule.template /quartz64_uefi/edk2/Conf/build_rule.txt

cp /quartz64_uefi/edk2/BaseTools/Conf/tools_def.template /quartz64_uefi/edk2/Conf/tools_def.txt

cp /quartz64_uefi/edk2/BaseTools/Conf/target.template /quartz64_uefi/edk2/Conf/target.txt

Then moves to build edk2 directory.
cd /quartz64_uefi/edk2
 
The next part is the actual compile flags. There are a bunch. I adapted to my target paths.
The base edk2 instructions mention setup toolchain with make -C /edk2/BaseTools but that didn't work.
With the rpi3 edk2 port I see I wanted gmake instead.

So this part is untested and I hope to get this compiling on command line.

/usr/bin/env WORKSPACE=/quartz64_uefi/edk2
PACKAGES_PATH=/quartz64_uefi/edk2:/quartz64_uefi/edk2-platforms:/quartz64_uefi/edk2-non-osi
CONF_PATH=/quartz64_uefi/edk2/Conf
EDK_TOOLS_PATH=/quartz64_uefi/edk2/BaseTools
PATH=/quartz64_uefi/edk2/BaseTools/BinWrappers/PosixLike:/quartz64_uefi/edk2/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
PYTHON_COMMAND=python3
PYTHONHASHSEED=1
EXTRA_LDFLAGS=-Wl,-rpath=/usr/local/lib/gcc13
GCC5_AARCH64_PREFIX=aarch64-none-elf-
XDG_DATA_HOME=/quartz64_uefi
XDG_CONFIG_HOME=/quartz64_uefi
DG_CACHE_HOME=/quartz64_uefi/.cache
HOME=/usr/ports/sysutils/edk2/work-rpi4
PKG_CONFIG_LIBDIR=/usr/ports/sysutils/edk2/work-rpi4/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig
MK_DEBUG_FILES=no
MK_KERNEL_SYMBOLS=no
SHELL=/bin/sh
NO_LINT=YES
ADDR2LINE="/usr/local/bin/addr2line"
AR="/usr/local/bin/ar"
AS="/usr/local/bin/as"
CPPFILT="/usr/local/bin/c++filt"
GPROF="/usr/local/bin/gprof"
LD="/usr/local/bin/ld"
NM="/usr/local/bin/nm"
OBJCOPY="/usr/local/bin/objcopy"
OBJDUMP="/usr/local/bin/objdump"
RANLIB="/usr/local/bin/ranlib"
READELF="/usr/local/bin/readelf"
SIZE="/usr/local/bin/size"
STRINGS="/usr/local/bin/strings"
PREFIX=/usr/local
LOCALBASE=/usr/local
CC="gcc13"
CFLAGS="-O2 -pipe -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc13 -fno-strict-aliasing "
CPP="cpp13"
CPPFLAGS=""
LDFLAGS=" -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc13 -L/usr/local/lib/gcc13 "
LIBS=""
CXX="g++13"
CXXFLAGS="-O2 -pipe -fstack-protector-strong -Wl,-rpath=/usr/local/lib/gcc13 -Wl,-rpath=/usr/local/lib/gcc13"
BSD_INSTALL_PROGRAM="install -s -m 555"
BSD_INSTALL_LIB="install -s -m 0644"
BSD_INSTALL_SCRIPT="install -m 555"
BSD_INSTALL_DATA="install -m 0644"
BSD_INSTALL_MAN="install -m 444"

gmake -C edk2/BaseTools -j4)
gmake[1]: Entering directory '/usr/ports/sysutils/edk2/work-rpi4/edk2-edk2-stable202308/BaseTools'

gmake -C Source/C

gmake -C Source/Python

mkdir -p .
mkdir ./libs
mkdir ./bin
gmake -C VfrCompile VfrLexer.h
gmake -C Common

BIN_DIR='.' gmake -C Pccts/dlg
BIN_DIR='.' gmake -C Pccts/antlr
 
The ports Makefile helped me with the first question:

Code:
# We can't have two submodule with the same origin in GH_TUPLE
post-extract:
    (cd ${WRKDIR}/edk2-${GH_TAGNAME}/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli && tar cf - * | tar xf - -C ../../../../BaseTools/Source/C/BrotliCompress/brotli)
 
I went another route and tried to build BaseTools from command prompt as per this:

gmake -C ./BaseTools "PYTHON_COMMAND=python3" "PYTHONHASHSEED=1"

Next up .edksetup and figuring out its needed option flags.
 
Back
Top