From d504458ef5157ebb718c149712a5ef9a1a09e92f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Fri, 17 Oct 2025 21:25:10 +0200 Subject: [PATCH] odhcpd: add a simple build script MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Link: https://github.com/openwrt/odhcpd/pull/280 Signed-off-by: Álvaro Fernández Rojas --- .gitignore | 2 +- scripts/devel-build.sh | 104 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100755 scripts/devel-build.sh diff --git a/.gitignore b/.gitignore index 6bf011f..9f220a0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ Makefile cmake_install.cmake install_manifest.txt *.deb - +build diff --git a/scripts/devel-build.sh b/scripts/devel-build.sh new file mode 100755 index 0000000..236b7e4 --- /dev/null +++ b/scripts/devel-build.sh @@ -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 -- 2.30.2