odhcpd: add a simple build script

Inspired from the ci script and the scripts I've been using. Should make it a
little bit easier for people who want to contribute to odhcpd.

Signed-off-by: David Härdeman <david@hardeman.nu>
Link: https://github.com/openwrt/odhcpd/pull/280
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
David Härdeman
2025-10-17 21:25:10 +02:00
committed by Álvaro Fernández Rojas
parent 4ee309a540
commit d504458ef5
2 changed files with 105 additions and 1 deletions

2
.gitignore vendored
View File

@@ -11,4 +11,4 @@ Makefile
cmake_install.cmake
install_manifest.txt
*.deb
build

104
scripts/devel-build.sh Executable file
View File

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