forked from iputils/iputils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·114 lines (91 loc) · 2.21 KB
/
build.sh
File metadata and controls
executable file
·114 lines (91 loc) · 2.21 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
#!/bin/sh
CFLAGS="${CFLAGS:--Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=return-type -fno-common}"
CC="${CC:-gcc}"
BUILD_DIR="${BUILD_DIR:-builddir}"
PREFIX="${PREFIX:-$HOME/iputils-install}"
BUILD_OPTS="-Dprefix=$PREFIX -DBUILD_RARPD=true -DBUILD_TFTPD=true -DBUILD_TRACEROUTE6=true $EXTRA_BUILD_OPTS"
[ -z "$EXTRA_BUILD_OPTS" ] && BUILD_OPTS="$BUILD_OPTS -DBUILD_HTML_MANS=true"
[ -f "meson.cross" ] && BUILD_OPTS="--cross-file $PWD/meson.cross $BUILD_OPTS"
# NOTE: meson iself checkes for minimal version
# see meson_version in meson.build, it fails if not required
# Meson version is 0.37.1 but project requires >=0.39.
check_build_dependencies()
{
# ninja-build is not detected causes build failing => symlink to ninja
# needed for CentOS 7 but maybe for others
if ! which ninja > /dev/null >&2; then
if which ninja-build > /dev/null >&2; then
ln -sv $(which ninja-build) /usr/local/bin/ninja
else
echo "ninja binary not found (tried ninja and $NINJA on $PATH)" >&2
exit 1
fi
fi
which meson > /dev/null 2>&1 || { echo "meson binary not found" >&2; exit 1; }
}
print_versions()
{
echo "=== compiler version ==="
$CC --version
echo "=== meson version ==="
meson --version
echo "=== ninja version ==="
ninja --version
}
configure()
{
echo "=== configure ==="
echo "Build options: $BUILD_OPTS"
echo "CFLAGS: $CFLAGS"
export CFLAGS
meson $BUILD_DIR $BUILD_OPTS
}
build()
{
echo "=== build ==="
make -j$(getconf _NPROCESSORS_ONLN)
}
install()
{
echo "=== install ==="
make install
}
run_tests()
{
echo "=== tests ==="
cd $BUILD_DIR
meson tests
cd -
}
print_logs()
{
local ret=$1
local log
[ $ret -eq 0 ] && return
log="$BUILD_DIR/meson-logs/meson-log.txt"
if [ -f "$log" ]; then
echo "=== START $log ==="
cat $log
echo "=== END $log ==="
fi
exit $ret
}
cd `dirname $0`
[ -z "$1" -o "$1" = "dependencies" ] && check_build_dependencies
[ -z "$1" -o "$1" = "info" ] && print_versions
if [ -z "$1" -o "$1" = "configure" ]; then
configure
print_logs $?
fi
if [ -z "$1" -o "$1" = "build" ]; then
build
print_logs $?
fi
if [ -z "$1" -o "$1" = "install" ]; then
install
print_logs $?
fi
if [ -z "$1" -o "$1" = "test" ]; then
run_tests
print_logs $?
fi