Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / bm / bmake / setup-hook.sh
bloba36d024b111e71aa9f0667b0734732cfb66e1e60
1 # shellcheck shell=bash disable=SC2086,SC2154,SC2206
3 addMakeFlags() {
4 export prefix="$out"
5 export MANDIR="${!outputMan}/share/man"
6 export MANTARGET=man
7 export BINOWN=
8 export STRIP_FLAG=
11 bmakeBuildPhase() {
12 runHook preBuild
14 local flagsArray=(
15 ${enableParallelBuilding:+-j${NIX_BUILD_CORES}}
16 SHELL="$SHELL"
17 $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
18 $buildFlags ${buildFlagsArray+"${buildFlagsArray[@]}"}
21 echoCmd 'build flags' "${flagsArray[@]}"
22 bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
24 runHook postBuild
27 bmakeCheckPhase() {
28 runHook preCheck
30 if [ -z "${checkTarget:-}" ]; then
31 #TODO(@oxij): should flagsArray influence make -n?
32 if bmake -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then
33 checkTarget="check"
34 elif bmake -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then
35 checkTarget="test"
39 if [ -z "${checkTarget:-}" ]; then
40 echo "no test target found in bmake, doing nothing"
41 else
42 local flagsArray=(
43 ${enableParallelChecking:+-j${NIX_BUILD_CORES}}
44 SHELL="$SHELL"
45 # Old bash empty array hack
46 $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
47 ${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
48 ${checkTarget}
51 echoCmd 'check flags' "${flagsArray[@]}"
52 bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
55 runHook postCheck
58 bmakeInstallPhase() {
59 runHook preInstall
61 if [ -n "$prefix" ]; then
62 mkdir -p "$prefix"
65 local flagsArray=(
66 ${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
67 SHELL="$SHELL"
68 # Old bash empty array hack
69 $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
70 $installFlags ${installFlagsArray+"${installFlagsArray[@]}"}
71 ${installTargets:-install}
74 echoCmd 'install flags' "${flagsArray[@]}"
75 bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
77 runHook postInstall
80 bmakeDistPhase() {
81 runHook preDist
83 if [ -n "$prefix" ]; then
84 mkdir -p "$prefix"
87 # Old bash empty array hack
88 local flagsArray=(
89 $distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist}
92 echo 'dist flags: %q' "${flagsArray[@]}"
93 bmake ${makefile:+-f $makefile} "${flagsArray[@]}"
95 if [ "${dontCopyDist:-0}" != 1 ]; then
96 mkdir -p "$out/tarballs"
98 # Note: don't quote $tarballs, since we explicitly permit
99 # wildcards in there.
100 cp -pvd ${tarballs:-*.tar.gz} "$out/tarballs"
103 runHook postDist
106 preConfigureHooks+=(addMakeFlags)
108 if [ -z "${dontUseBmakeBuild-}" ] && [ -z "${buildPhase-}" ]; then
109 buildPhase=bmakeBuildPhase
112 if [ -z "${dontUseBmakeCheck-}" ] && [ -z "${checkPhase-}" ]; then
113 checkPhase=bmakeCheckPhase
116 if [ -z "${dontUseBmakeInstall-}" ] && [ -z "${installPhase-}" ]; then
117 installPhase=bmakeInstallPhase
120 if [ -z "${dontUseBmakeDist-}" ] && [ -z "${distPhase-}" ]; then
121 distPhase=bmakeDistPhase