-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlkhh-kernel-make
More file actions
executable file
·92 lines (80 loc) · 2.11 KB
/
lkhh-kernel-make
File metadata and controls
executable file
·92 lines (80 loc) · 2.11 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! /bin/bash
_rootdir=${_rootdir:-"$(dirname "$(readlink -f "$0")")"}
_ver="0.0.1-dev"
#_author="Wei Peng <me@1pengw.com>"
source "${_rootdir}/_shared_prologue"
#
# parameters
#
declare -i instance=${instance:-1}
declare target=${target:-help}
declare -i jobs=${jobs:-$((2+$(nproc)))}
# see also: http://nickdesaulniers.github.io/blog/2018/06/02/speeding-up-linux-kernel-builds-with-ccache/
declare -i deterministic=${deterministic:-0}
#
# getopt processing
#
function my_getopt_cont () {
local n_shift=1 # number of shifts in the outer loop; shift by 1 by default
case "$1" in
-i|--instance)
shift
instance=$1
n_shift=2
;;
-t|--target)
shift
target=$1
n_shift=2
;;
-j|--jobs)
shift
jobs=$1
n_shift=2
;;
-d|--deterministic)
deterministic=1
n_shift=1
;;
esac
return $n_shift
}
my_getopt "i:t:j:d" "instance:,target:,jobs:,deterministic" "my_getopt_cont" "Make kernel instance." "$(
cat <<END
[-i|--instance=<instance>] [-t|--target=<target>] [-j|--jobs=<jobs>]
[-d|--deterministic]
END
)" "$(
cat <<END
-i --instance Maximal number of kernel instances to prepare (default: $instance).
-t --target Makefile target to make (default: $target).
-j --jobs Number of parallel make jobs (default: $jobs).
-d --deterministic Deterministic build to leverage, e.g., ccache (default: $deterministic).
END
)" "$@"
ret=$?
eval set -- "$_getopt"
shift $ret
# sanity check
vecho 0 <<END
$(
dumpparam <<END1
$(
for name in instance target jobs deterministic; do
echo "$name=$(echo $(eval "echo \$$name"))"
done
)
END1
)
END
build_dir="$LKHH_ARENA/build/$instance"
[[ -d "$build_dir" ]] || die 1 <<END
ERROR: $build_dir does not exist; consider "lkhh-init -i $instance" first.
END
vecho 0 <<END
make -C "$LKHH_LINUX" "O=$build_dir" -j $jobs "$@" "$target"
END
if (( deterministic > 0 )); then
export KBUILD_BUILD_TIMESTAMP="1991-08-25" # Happy Birthday, Linux
fi
make -C "$LKHH_LINUX" "O=$build_dir" -j $jobs "$@" "$target"