forked from fvwmorg/fvwm3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·132 lines (114 loc) · 2.47 KB
/
build
File metadata and controls
executable file
·132 lines (114 loc) · 2.47 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
# Released under the same licence as fvwm3.
fflag=0
iflag=0
vflag=0
Dargs=""
buildDir="compile"
tempFile="$(mktemp)"
prefix=""
# Portably determine number of CPU cores on different systems (MacOS, BSD,
# Linux).
nproc() {
NPROCCMD="nproc"
command "$NPROCCMD" >/dev/null 2>&1 || {
NPROCCMD="sysctl -n hw.ncpu"
}
result="$(eval command $NPROCCMD)"
[ -z "$result" -o "$result" -le 0 ] && result="1"
echo "$result"
}
die() {
echo "$@" >&2
[ -s "$tempFile" -a "$vflag" = 0 ] && {
cat $tempFile >&2
echo >&2
echo "Build output available here: $tempFile" >&2
}
exit 1
}
run_cmd() {
[ "$vflag" = 0 ] && {
"$@" >>"$tempFile" 2>&1
return $?
} || {
"$@" | tee -a "$tempFile"
return $?
}
}
usage() {
die "$(cat <<EOF
$(basename $0) [-b builddir] [-f] [-v] [-i] [-m] [-p] [-w] [-D opts]
Where:
-b: Directory to use to build fvwm3, defaults to: 'compile'
-d: Compile all docs (manpages and HTML), implies options '-m' and '-w'
-f: Forces 'meson setup' to rerun, with --reconfigure --wipe
-h: Shows this output
-i: Installs compiled files
-m: Build manual pages
-p: Set the prefix for where the installation path will be
-v: Verbose mode - does not hide output from meson
-w: Build HTML documentation
-D: Can be specified multiple times to pass options to 'meson setup'
EOF
)"
}
# Getopts
while getopts ":dfb:D:himp:vw" o; do
case "$o" in
b)
buildDir="$OPTARG"
;;
d)
Dargs="$Dargs -Dmandoc=true -Dhtmldoc=true"
;;
f)
fflag=1
;;
i)
iflag=1
;;
m)
Dargs="$Dargs -Dmandoc=true"
;;
p)
Dargs="$Dargs -Dprefix=$OPTARG"
prefix="$OPTARG"
;;
v)
vflag=1
;;
w)
Dargs="$Dargs -Dhtmldoc=true"
;;
D)
Dargs="$Dargs -D$OPTARG"
;;
h | * | \?)
usage
;;
esac
done
shift $((OPTIND-1))
# Check to see whether meson is installed.
command -v meson >/dev/null 2>&1 || die "meson not found..."
echo "Tempfile is: $tempFile"
echo "Using build directory: $buildDir"
[ -n "$prefix" ] && {
echo "Prefix is: $prefix"
}
{ [ ! -d "$buildDir" ] || [ "$fflag" = 1 ] ; } && {
echo "Running meson setup..."
run_cmd meson setup --reconfigure --wipe "$buildDir" $Dargs || {
die "Command failed..."
}
}
echo "Compiling..."
run_cmd ninja -j $(nproc) -C "$buildDir" || die "Command failed..."
[ "$iflag" = 1 ] && {
echo "Installing..."
# Don't run via run_cmd() -- stdin won't be available, and we want
# meson to detect whether sudo(1) or doas(1) should be used.
meson install -C "$buildDir" || die "Command failed..."
}
exit 0