2019-09-03 11:58:42 +02:00
|
|
|
|
#!/bin/bash
|
2019-09-06 17:38:05 +02:00
|
|
|
|
|
2019-09-07 14:57:07 +02:00
|
|
|
|
# created by vector sigma on July 15 2019
|
|
|
|
|
# github version
|
2019-09-06 17:38:05 +02:00
|
|
|
|
|
|
|
|
|
# Linux users should be able to use this wrapper, although the following are needed:
|
2020-04-11 14:13:11 +02:00
|
|
|
|
# (Ubuntu alike)
|
|
|
|
|
# sudo apt-get install build-essential uuid-dev iasl git gcc-9 nasm python3-distutils
|
2019-09-06 17:38:05 +02:00
|
|
|
|
|
2019-09-07 14:57:07 +02:00
|
|
|
|
# $1 argument override MYTOOLCHAIN variable, in case you want GCC53 for example
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
2019-09-23 12:54:58 +02:00
|
|
|
|
cd "$(dirname $([ -L $0 ] && readlink $0 || echo $0))"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
declare -r CLOVERROOT="$PWD"
|
2019-11-04 22:47:52 +01:00
|
|
|
|
declare -r SYSNAME="$(uname)"
|
2019-09-15 20:06:04 +02:00
|
|
|
|
MYTOOLCHAIN=${1:-GCC53}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
|
pathmunge() {
|
|
|
|
|
if [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
|
|
|
|
|
if [[ "${2:-}" = "after" ]]; then
|
|
|
|
|
export PATH=$PATH:$1
|
|
|
|
|
else
|
|
|
|
|
export PATH=$1:$PATH
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkXCODE() {
|
|
|
|
|
echo "[CHECK XCODE]"
|
|
|
|
|
if [[ ! -x /usr/bin/xcodebuild ]]; then
|
|
|
|
|
echo "ERROR: Install Xcode Tools from Apple before using this script."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ! -d "$(xcode-select --print-path)" ]]; then
|
|
|
|
|
echo "ERROR: Xcode Command Line Tools not selected:"
|
|
|
|
|
echo " open Xcode.app and go in Preferences->Locations,"
|
|
|
|
|
echo " and select the Command Line Tools"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkGETTEXT() {
|
2019-09-22 13:50:13 +02:00
|
|
|
|
exportPaths
|
|
|
|
|
local locations=($(which msgmerge))
|
|
|
|
|
if [ "${#locations[@]}" -eq 0 ]; then
|
|
|
|
|
export GETTEXT_PREFIX="${TOOLCHAIN_DIR}"
|
|
|
|
|
"${CLOVERROOT}"/buildgettext.sh
|
|
|
|
|
else
|
|
|
|
|
# export gettex prefix to ensure buildpkg.sh will use it
|
|
|
|
|
# without the need to install it again
|
|
|
|
|
export GETTEXT_PREFIX="$(dirname "${locations[0]}")"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exportPaths() {
|
2019-11-04 22:47:52 +01:00
|
|
|
|
if [[ "$SYSNAME" == Linux ]]; then
|
|
|
|
|
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-/usr}
|
|
|
|
|
elif [[ "$SYSNAME" == Darwin ]]; then
|
2019-09-06 17:38:05 +02:00
|
|
|
|
pathmunge "$(xcode-select --print-path)"/usr/bin
|
2019-12-01 15:27:34 +01:00
|
|
|
|
if [[ -d ~/src/opt/local ]]; then
|
|
|
|
|
TOOLCHAIN_DIR=~/src/opt/local
|
|
|
|
|
else
|
|
|
|
|
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-"$CLOVERROOT"/toolchain}
|
|
|
|
|
fi
|
2019-09-06 17:38:05 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
pathmunge "$TOOLCHAIN_DIR"/bin
|
|
|
|
|
export TOOLCHAIN_DIR=$TOOLCHAIN_DIR
|
2019-11-04 22:47:52 +01:00
|
|
|
|
export DIR_MAIN=${DIR_MAIN:-"$CLOVERROOT"/toolchain}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
export DIR_TOOLS=${DIR_TOOLS:-$DIR_MAIN/tools}
|
|
|
|
|
export DIR_DOWNLOADS=${DIR_DOWNLOADS:-$DIR_TOOLS/download}
|
|
|
|
|
export DIR_LOGS=${DIR_LOGS:-$DIR_TOOLS/logs}
|
2019-09-22 13:50:13 +02:00
|
|
|
|
export PREFIX=${TOOLCHAIN_DIR}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkTools() {
|
2019-09-22 13:50:13 +02:00
|
|
|
|
# export any env vars before building anything
|
2019-11-04 22:47:52 +01:00
|
|
|
|
if [[ "$SYSNAME" == Darwin ]]; then
|
2019-09-06 17:38:05 +02:00
|
|
|
|
checkXCODE
|
2019-09-22 13:50:13 +02:00
|
|
|
|
exportPaths
|
|
|
|
|
local GCC53_BIN="$PREFIX/cross/bin/x86_64-clover-linux-gnu-gcc"
|
|
|
|
|
if [[ $MYTOOLCHAIN == GCC* ]] && [[ ! -x "${GCC53_BIN}" ]]; then
|
|
|
|
|
if [[ $MYTOOLCHAIN == GCC53 ]]; then
|
|
|
|
|
cd "${CLOVERROOT}"
|
|
|
|
|
./build_gcc9.sh
|
|
|
|
|
else
|
|
|
|
|
MYTOOLCHAIN=XCODE8
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
exportPaths
|
2019-09-06 17:38:05 +02:00
|
|
|
|
fi
|
|
|
|
|
}
|
2019-09-03 11:58:42 +02:00
|
|
|
|
|
2019-09-11 13:13:44 +02:00
|
|
|
|
updateClover() {
|
2019-09-05 13:30:12 +02:00
|
|
|
|
echo "[UPDATE CLOVER]"
|
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-06 17:38:05 +02:00
|
|
|
|
if [[ -d .git ]]; then
|
|
|
|
|
git fetch --all
|
|
|
|
|
git pull origin master
|
|
|
|
|
else
|
|
|
|
|
echo "Error: this is not a git repository, can't update!"
|
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 13:13:44 +02:00
|
|
|
|
updateResetClover() {
|
|
|
|
|
echo "[UPDATE RESET CLOVER]"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-06 17:38:05 +02:00
|
|
|
|
if [[ -d .git ]]; then
|
2019-09-11 13:13:44 +02:00
|
|
|
|
git fetch --all
|
|
|
|
|
git reset --hard origin/master
|
2019-09-06 17:38:05 +02:00
|
|
|
|
git pull origin master
|
|
|
|
|
else
|
|
|
|
|
echo "Error: this is not a git repository, can't update!"
|
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-01 15:27:34 +01:00
|
|
|
|
buildCloverHFSPlus() {
|
|
|
|
|
if [[ -f "${CLOVERROOT}"/FileSystems/HFSPlus/X64/HFSPlus.efi ]]; then
|
|
|
|
|
echo "building Clover with HFSPlus"
|
|
|
|
|
buildClover HFSPlus
|
|
|
|
|
else
|
|
|
|
|
echo "${CLOVERROOT}/FileSystems/HFSPlus/X64/HFSPlus.efi: no such file!"
|
|
|
|
|
sleep 3
|
|
|
|
|
menu
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
buildClover() {
|
|
|
|
|
checkTools
|
|
|
|
|
|
2020-04-11 14:13:11 +02:00
|
|
|
|
# to force recreation of the Conf folder. You can still use a custom CONF_PATH if you don't want recreation.
|
2020-02-18 07:02:44 +01:00
|
|
|
|
rm -rf "$CLOVERROOT"/Conf
|
|
|
|
|
mkdir "$CLOVERROOT"/Conf
|
2019-09-11 13:13:44 +02:00
|
|
|
|
|
2020-02-18 07:02:44 +01:00
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-11 13:13:44 +02:00
|
|
|
|
if [[ -z "$WORKSPACE" ]]; then
|
|
|
|
|
export EDK_TOOLS_PATH="${PWD}"/BaseTools
|
|
|
|
|
set +u
|
|
|
|
|
source ./edksetup.sh BaseTools
|
|
|
|
|
set -u
|
|
|
|
|
cd "$CLOVERROOT"
|
|
|
|
|
WORKSPACE="${PWD}"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
echo "[BUILD CLOVER]"
|
2019-09-11 13:13:44 +02:00
|
|
|
|
# Run a custom build script if exist (~/src/tools/Scripts/build.sh)
|
|
|
|
|
# This allow the user to run ebuild.sh with own parameters
|
|
|
|
|
if [[ -x "${DIR_TOOLS}"/Scripts/build.sh ]]; then
|
|
|
|
|
echo "Running custom build script"
|
|
|
|
|
"${DIR_TOOLS}"/Scripts/build.sh "${CLOVERROOT}" $MYTOOLCHAIN
|
|
|
|
|
else
|
2019-12-01 16:54:35 +01:00
|
|
|
|
local parameter=${1:-none}
|
|
|
|
|
if [[ "${parameter}" == HFSPlus ]]; then
|
2019-12-01 15:27:34 +01:00
|
|
|
|
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED -D USE_APPLE_HFSPLUS_DRIVER -t $MYTOOLCHAIN
|
|
|
|
|
./ebuild.sh -fr -D NO_GRUB_DRIVERS_EMBEDDED -D USE_APPLE_HFSPLUS_DRIVER -t $MYTOOLCHAIN
|
|
|
|
|
else
|
|
|
|
|
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED -t $MYTOOLCHAIN
|
|
|
|
|
./ebuild.sh -fr -D NO_GRUB_DRIVERS_EMBEDDED -t $MYTOOLCHAIN
|
|
|
|
|
fi
|
2019-09-11 13:13:44 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Run a post build script if exist (~/src/tools/Scripts/postbuild.sh)
|
|
|
|
|
if [[ -x "${DIR_TOOLS}"/Scripts/postbuild.sh ]]; then
|
|
|
|
|
echo "Running postbuild script"
|
2019-09-12 11:47:18 +02:00
|
|
|
|
"${DIR_TOOLS}"/Scripts/postbuild.sh "${CLOVERROOT}" $MYTOOLCHAIN
|
2019-09-11 13:13:44 +02:00
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-12 09:24:47 +02:00
|
|
|
|
buildCloverTest() {
|
|
|
|
|
checkTools
|
|
|
|
|
|
|
|
|
|
cd "${CLOVERROOT}"
|
|
|
|
|
|
|
|
|
|
if [[ -z "$WORKSPACE" ]]; then
|
|
|
|
|
export EDK_TOOLS_PATH="${PWD}"/BaseTools
|
|
|
|
|
set +u
|
|
|
|
|
source ./edksetup.sh BaseTools
|
|
|
|
|
set -u
|
|
|
|
|
cd "$CLOVERROOT"
|
|
|
|
|
WORKSPACE="${PWD}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "[BUILD CLOVER TEST]"
|
|
|
|
|
./ebuild.sh -nb -t $MYTOOLCHAIN
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
buildPkg() {
|
2019-11-04 22:47:52 +01:00
|
|
|
|
if [[ "$SYSNAME" == Darwin ]]; then
|
2019-09-15 20:06:04 +02:00
|
|
|
|
cd "${CLOVERROOT}"/CloverPackage
|
|
|
|
|
echo "[BUILD PKG]"
|
|
|
|
|
checkXCODE
|
|
|
|
|
checkGETTEXT
|
|
|
|
|
make pkg
|
|
|
|
|
else
|
|
|
|
|
echo && echo "can't build pkg on a non Darwin OS!"
|
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 23:58:10 +01:00
|
|
|
|
buildApp() {
|
2020-04-08 00:44:44 +02:00
|
|
|
|
local withClover=${1-"none"}
|
2019-11-04 22:47:52 +01:00
|
|
|
|
if [[ "$SYSNAME" == Darwin ]]; then
|
2019-11-06 23:58:10 +01:00
|
|
|
|
if [[ -f "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/CLOVERX64.efi ]]; then
|
2020-04-07 13:48:12 +02:00
|
|
|
|
rm -f "${CLOVERROOT}"/CloverPackage/sym/.withV2
|
2020-04-08 00:44:44 +02:00
|
|
|
|
if [[ $withClover == withV2 ]]; then
|
2020-04-07 13:48:12 +02:00
|
|
|
|
touch "${CLOVERROOT}"/CloverPackage/sym/.withV2
|
|
|
|
|
fi
|
2019-11-06 23:58:10 +01:00
|
|
|
|
cd "${CLOVERROOT}"/CloverApp
|
|
|
|
|
echo "[BUILD APP]"
|
|
|
|
|
checkXCODE
|
|
|
|
|
make
|
|
|
|
|
else
|
|
|
|
|
echo && echo "please, build Clover first!"
|
|
|
|
|
sleep 3
|
|
|
|
|
fi
|
|
|
|
|
else
|
2020-04-11 14:13:11 +02:00
|
|
|
|
echo && echo "Clover.app can only be built in macOS!"
|
2019-11-06 23:58:10 +01:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
buildIso() {
|
|
|
|
|
cd "${CLOVERROOT}"/CloverPackage
|
|
|
|
|
echo "[BUILD ISO]"
|
|
|
|
|
make iso
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkStatus() {
|
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-06 17:38:05 +02:00
|
|
|
|
if [[ -d .git ]]; then
|
|
|
|
|
git fetch origin
|
|
|
|
|
git status
|
|
|
|
|
else
|
|
|
|
|
echo "Error: this is not a git repository, can't get info!"
|
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showdiff() {
|
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-06 17:38:05 +02:00
|
|
|
|
if [[ -d .git ]]; then
|
|
|
|
|
git fetch origin
|
|
|
|
|
git diff
|
|
|
|
|
else
|
|
|
|
|
echo "Error: this is not a git repository, can't get info!"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanBaseTools() {
|
|
|
|
|
cd "${CLOVERROOT}"/BaseTools
|
|
|
|
|
make clean
|
2019-09-03 11:58:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu() {
|
|
|
|
|
echo
|
|
|
|
|
echo '------------------------------------------------------------------------'
|
|
|
|
|
cd "${CLOVERROOT}"
|
2019-09-06 17:38:05 +02:00
|
|
|
|
|
|
|
|
|
local lsha1="not a git repo"
|
|
|
|
|
|
|
|
|
|
if [[ -d .git ]]; then
|
|
|
|
|
lsha1=$(git rev-parse --short HEAD)
|
|
|
|
|
fi
|
|
|
|
|
|
2020-04-10 19:01:41 +02:00
|
|
|
|
echo "buildme, Clover r$(git describe --tags $(git rev-list --tags --max-count=1)) (SHA: $lsha1)"
|
2019-09-22 13:50:13 +02:00
|
|
|
|
echo "TOOLCHAIN: $MYTOOLCHAIN (override example: './buildme XCODE8')"
|
2019-09-03 11:58:42 +02:00
|
|
|
|
echo
|
|
|
|
|
PS3='Please enter your choice: '
|
2019-09-06 17:38:05 +02:00
|
|
|
|
options=( 'build Clover'
|
2019-12-01 15:27:34 +01:00
|
|
|
|
'build Clover with HFSPlus'
|
2019-09-06 17:38:05 +02:00
|
|
|
|
'make pkg'
|
2019-11-06 23:58:10 +01:00
|
|
|
|
'make app'
|
2020-04-07 13:48:12 +02:00
|
|
|
|
'make app (with Clover)'
|
2019-09-06 17:38:05 +02:00
|
|
|
|
'make iso'
|
|
|
|
|
'build all'
|
2019-09-12 09:24:47 +02:00
|
|
|
|
'test build (no autogen, no boot files)'
|
2019-09-06 17:38:05 +02:00
|
|
|
|
'status'
|
2019-09-11 13:13:44 +02:00
|
|
|
|
'update Clover'
|
2019-09-06 17:38:05 +02:00
|
|
|
|
'show diff'
|
|
|
|
|
'open drivers directory'
|
2020-04-13 01:11:14 +02:00
|
|
|
|
'update Clover (reset changes)'
|
2019-09-06 17:38:05 +02:00
|
|
|
|
'clean BaseTools'
|
|
|
|
|
'quit')
|
|
|
|
|
|
2019-09-03 11:58:42 +02:00
|
|
|
|
select opt in "${options[@]}"
|
|
|
|
|
do
|
|
|
|
|
case $opt in
|
|
|
|
|
"build Clover")
|
|
|
|
|
buildClover
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-12-01 15:27:34 +01:00
|
|
|
|
"build Clover with HFSPlus")
|
|
|
|
|
buildCloverHFSPlus
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
"make pkg")
|
|
|
|
|
buildPkg
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-11-06 23:58:10 +01:00
|
|
|
|
"make app")
|
|
|
|
|
buildApp
|
|
|
|
|
break
|
|
|
|
|
;;
|
2020-04-07 13:48:12 +02:00
|
|
|
|
"make app (with Clover)")
|
|
|
|
|
buildApp withV2
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
"make iso")
|
|
|
|
|
buildIso
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
"build all")
|
|
|
|
|
buildClover
|
|
|
|
|
buildPkg
|
|
|
|
|
buildIso
|
2019-11-06 23:58:10 +01:00
|
|
|
|
buildApp
|
2019-09-03 11:58:42 +02:00
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-12 09:24:47 +02:00
|
|
|
|
"test build (no autogen, no boot files)")
|
|
|
|
|
buildCloverTest
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-11 13:13:44 +02:00
|
|
|
|
"update Clover")
|
|
|
|
|
updateClover
|
2019-09-03 11:58:42 +02:00
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-11 13:13:44 +02:00
|
|
|
|
"update Clover (reset changes)")
|
2020-04-14 20:27:42 +02:00
|
|
|
|
read -p "Are you sure? (type y to confirm or any other to negate) " -n 1 -r
|
2020-04-13 01:11:14 +02:00
|
|
|
|
echo
|
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
|
|
updateResetClover
|
|
|
|
|
fi
|
2019-09-03 11:58:42 +02:00
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
"status")
|
|
|
|
|
checkStatus
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
"show diff")
|
|
|
|
|
showdiff
|
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-06 17:38:05 +02:00
|
|
|
|
"open drivers directory")
|
|
|
|
|
if [[ -d "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers ]]; then
|
|
|
|
|
open "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers
|
|
|
|
|
else
|
|
|
|
|
echo && echo "Directory not found. Compile Clover first!!"
|
|
|
|
|
sleep 2
|
|
|
|
|
fi
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
"clean BaseTools")
|
2020-04-14 20:27:42 +02:00
|
|
|
|
read -p "Are you sure? (type y to confirm or any other to negate) " -n 1 -r
|
2020-04-13 01:11:14 +02:00
|
|
|
|
echo
|
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
|
|
cleanBaseTools
|
|
|
|
|
fi
|
2019-09-06 17:38:05 +02:00
|
|
|
|
break
|
|
|
|
|
;;
|
2019-09-03 11:58:42 +02:00
|
|
|
|
"quit")
|
2020-04-11 12:53:59 +02:00
|
|
|
|
exit 0
|
2019-09-03 11:58:42 +02:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "invalid option $REPLY"
|
|
|
|
|
break
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
menu
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Main
|
|
|
|
|
set -e
|
2019-09-12 20:04:50 +02:00
|
|
|
|
if [[ "$2" == travis ]]; then
|
|
|
|
|
buildClover
|
|
|
|
|
buildPkg
|
|
|
|
|
buildIso
|
|
|
|
|
else
|
|
|
|
|
menu
|
|
|
|
|
fi
|