2023-07-23 23:39:44 +02:00
|
|
|
# shellcheck shell=bash disable=SC2086,SC2154,SC2206
|
|
|
|
|
2021-06-06 20:30:46 +02:00
|
|
|
addMakeFlags() {
|
|
|
|
export prefix="$out"
|
|
|
|
export MANDIR="${!outputMan}/share/man"
|
|
|
|
export MANTARGET=man
|
|
|
|
export BINOWN=
|
|
|
|
export STRIP_FLAG=
|
|
|
|
}
|
|
|
|
|
2021-04-13 02:10:06 +02:00
|
|
|
bmakeBuildPhase() {
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
local flagsArray=(
|
|
|
|
${enableParallelBuilding:+-j${NIX_BUILD_CORES}}
|
2023-07-23 23:39:44 +02:00
|
|
|
SHELL="$SHELL"
|
2021-04-13 02:10:06 +02:00
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
$buildFlags ${buildFlagsArray+"${buildFlagsArray[@]}"}
|
|
|
|
)
|
|
|
|
|
|
|
|
echoCmd 'build flags' "${flagsArray[@]}"
|
|
|
|
bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
}
|
|
|
|
|
|
|
|
bmakeCheckPhase() {
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
if [ -z "${checkTarget:-}" ]; then
|
|
|
|
#TODO(@oxij): should flagsArray influence make -n?
|
|
|
|
if bmake -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then
|
2023-07-23 23:39:44 +02:00
|
|
|
checkTarget="check"
|
2021-04-13 02:10:06 +02:00
|
|
|
elif bmake -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then
|
2023-07-23 23:39:44 +02:00
|
|
|
checkTarget="test"
|
2021-04-13 02:10:06 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${checkTarget:-}" ]; then
|
|
|
|
echo "no test target found in bmake, doing nothing"
|
|
|
|
else
|
|
|
|
local flagsArray=(
|
|
|
|
${enableParallelChecking:+-j${NIX_BUILD_CORES}}
|
2023-07-23 23:39:44 +02:00
|
|
|
SHELL="$SHELL"
|
2021-04-13 02:10:06 +02:00
|
|
|
# Old bash empty array hack
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
|
|
|
|
${checkTarget}
|
|
|
|
)
|
|
|
|
|
|
|
|
echoCmd 'check flags' "${flagsArray[@]}"
|
|
|
|
bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
bmakeInstallPhase() {
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
if [ -n "$prefix" ]; then
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
fi
|
|
|
|
|
|
|
|
local flagsArray=(
|
2023-02-21 20:50:48 +01:00
|
|
|
${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
|
2023-07-23 23:39:44 +02:00
|
|
|
SHELL="$SHELL"
|
2021-04-13 02:10:06 +02:00
|
|
|
# Old bash empty array hack
|
|
|
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
|
|
|
$installFlags ${installFlagsArray+"${installFlagsArray[@]}"}
|
|
|
|
${installTargets:-install}
|
|
|
|
)
|
|
|
|
|
|
|
|
echoCmd 'install flags' "${flagsArray[@]}"
|
|
|
|
bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
}
|
|
|
|
|
|
|
|
bmakeDistPhase() {
|
|
|
|
runHook preDist
|
|
|
|
|
|
|
|
if [ -n "$prefix" ]; then
|
|
|
|
mkdir -p "$prefix"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Old bash empty array hack
|
|
|
|
local flagsArray=(
|
|
|
|
$distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist}
|
|
|
|
)
|
|
|
|
|
|
|
|
echo 'dist flags: %q' "${flagsArray[@]}"
|
|
|
|
bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
|
|
|
|
|
|
|
|
if [ "${dontCopyDist:-0}" != 1 ]; then
|
|
|
|
mkdir -p "$out/tarballs"
|
|
|
|
|
|
|
|
# Note: don't quote $tarballs, since we explicitly permit
|
|
|
|
# wildcards in there.
|
|
|
|
cp -pvd ${tarballs:-*.tar.gz} "$out/tarballs"
|
|
|
|
fi
|
|
|
|
|
|
|
|
runHook postDist
|
|
|
|
}
|
|
|
|
|
2023-07-23 23:39:44 +02:00
|
|
|
preConfigureHooks+=(addMakeFlags)
|
|
|
|
|
|
|
|
if [ -z "${dontUseBmakeBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
|
|
buildPhase=bmakeBuildPhase
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${dontUseBmakeCheck-}" ] && [ -z "${checkPhase-}" ]; then
|
|
|
|
checkPhase=bmakeCheckPhase
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${dontUseBmakeInstall-}" ] && [ -z "${installPhase-}" ]; then
|
|
|
|
installPhase=bmakeInstallPhase
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${dontUseBmakeDist-}" ] && [ -z "${distPhase-}" ]; then
|
2021-04-13 02:10:06 +02:00
|
|
|
distPhase=bmakeDistPhase
|
|
|
|
fi
|