blob: eaae557ade3c3f15679ca162c7bfe67d27214609 (
plain)
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
|
#!/bin/bash
set -euxo pipefail
cd "${0%/*}"
cd ..
# Sanity checks
if [ ! -e "CMakeLists.txt" ] || [ ! -e "src/odhcp6c.c" ]; then
echo "odhcp6c checkout not found" >&2
exit 1
fi
if [ $# -eq 0 ]; then
BUILD_ARGS=""
else
BUILD_ARGS="$@"
fi
# Create build dirs
ODHCP6CDIR="$(pwd)"
BUILDDIR="${ODHCP6CDIR}/build"
DEPSDIR="${BUILDDIR}/depends"
[ -e "${BUILDDIR}" ] || mkdir "${BUILDDIR}"
[ -e "${DEPSDIR}" ] || mkdir "${DEPSDIR}"
# Download deps
cd "${DEPSDIR}"
[ -e "json-c" ] || git clone https://github.com/json-c/json-c.git
[ -e "libubox" ] || git clone https://github.com/openwrt/libubox.git
[ -e "ubus" ] || git clone https://github.com/openwrt/ubus.git
# Build json-c
cd "${DEPSDIR}/json-c"
cmake \
-S . \
-B . \
-DCMAKE_PREFIX_PATH="${BUILDDIR}" \
-DBUILD_SHARED_LIBS=OFF \
-DDISABLE_EXTRA_LIBS=ON \
-DBUILD_TESTING=OFF \
--install-prefix "${BUILDDIR}"
make
make install
# Build libubox
cd "${DEPSDIR}/libubox"
cmake \
-S . \
-B . \
-DCMAKE_PREFIX_PATH="${BUILDDIR}" \
-DBUILD_LUA=OFF \
-DBUILD_EXAMPLES=OFF \
--install-prefix "${BUILDDIR}"
make
make install
# Build ubus
cd "${DEPSDIR}/ubus"
cmake \
-S . \
-B . \
-DCMAKE_PREFIX_PATH="${BUILDDIR}" \
-DBUILD_LUA=OFF \
-DBUILD_EXAMPLES=OFF \
--install-prefix "${BUILDDIR}"
make
make install
# Build odhcp6c
cd "${ODHCP6CDIR}"
cmake \
-S . \
-B "${BUILDDIR}" \
-DCMAKE_PREFIX_PATH="${BUILDDIR}" \
-DUBUS=ON \
${BUILD_ARGS}
make -C "${BUILDDIR}"
set +x
echo "✅ Success - the odhcp6c binary is available at ${BUILDDIR}/odhcp6c"
echo "👷 You can rebuild odhcp6c by running 'make -C build'"
exit 0
|