commit 768432f086a467b0849d18a77a146fd73de835fb
parent aa5c9837165382f4f1c9f303fdee3ea8590dda1b
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 6 May 2024 18:37:52 +0200
clipper2: complete rewriting of the build script
It no longer relies on pre-compiled binaries. Instead, Clipper2 is now
built directly on the target machine from its sources, because it's fast
and doesn't rely on heavy dependencies. What's more, it avoids the risk
of a corrupted package.
Diffstat:
2 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/src/clipper2.mk.in b/src/clipper2.mk.in
@@ -0,0 +1,77 @@
+# Copyright (C) 2023, 2024 |Méso|Star> (contact@meso-star.com)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Configuration macros
+CLIPPER2_TAG=@TAG@
+CLIPPER2_URL=https://github.com/AngusJohnson/Clipper2
+
+# Helper macros
+CLIPPER2_DIR=clipper2/$(CLIPPER2_TAG)
+CLIPPER2_CMAKE_OPTIONS =\
+ -DCMAKE_BUILD_TYPE=Release\
+ -DCMAKE_INSTALL_LIBDIR="lib"\
+ -DCLIPPER2_TESTS=0\
+ -DCLIPPER2_UTILS=0\
+ -DCLIPPER2_EXAMPLES=0\
+ -DBUILD_SHARED_LIBS=1
+
+clipper2: build_clipper2
+ @prefix="$$(cat .prefix)" && \
+ cd -- "$(CLIPPER2_DIR)/CPP/build" && \
+ cmake -DCMAKE_INSTALL_PREFIX="$${prefix}" .. > /dev/null 2>&1 && \
+ $(MAKE) install
+
+build_clipper2: $(CLIPPER2_DIR) $(CLIPPER2_DIR)/patch
+ @cd -- "$(CLIPPER2_DIR)/CPP/build" && \
+ cmake $(CLIPPER2_CMAKE_OPTIONS) .. && \
+ $(MAKE)
+
+$(CLIPPER2_DIR):
+ @git clone --branch "$(CLIPPER2_TAG)" --depth 1 "$(CLIPPER2_URL)" $@
+ @mkdir -p "$@/CPP/build"
+
+$(CLIPPER2_DIR)/patch: $(CLIPPER2_DIR)
+ # Version number is wrong
+ sed -i 's/ VERSION 1\.1\.0 / VERSION 1.1.1 /' \
+ "$(CLIPPER2_DIR)/CPP/CMakeLists.txt"
+ # Missing LIBRARY DESTINATION for targets (cmake fails)
+ re="install(TARGETS Clipper2 Clipper2Z"; \
+ sed -i "s/^$${re}$$/$${re} LIBRARY DESTINATION $${CMAKE_INSTALL_LIBDIR}/" \
+ "$(CLIPPER2_DIR)/CPP/CMakeLists.txt"
+ # Missing cstdint (compilation fails)
+ re="#include <climits>"; \
+ sed -i "s/^$${re}$$/$${re}\n#include <cstdint>/" \
+ "$(CLIPPER2_DIR)/CPP/Clipper2Lib/include/clipper2/clipper.core.h"
+ echo "done" > "$@"
+
+clean_clipper2:
+ if [ -d "$(CLIPPER2_DIR)/CPP/build" ]; then \
+ cd -- "$(CLIPPER2_DIR)/CPP/build" && $(MAKE) clean; \
+ fi
+
+uninstall_clipper2:
+ @prefix="$$(cat .prefix)" && \
+ cd -- "$(CLIPPER2_DIR)/CPP/build" && \
+ cmake -DCMAKE_INSTALL_PREFIX="$${prefix}" .. && \
+ $(MAKE) install
+ xargs rm -f < "$(CLIPPER2_DIR)/CPP/build/install_manifest.txt"
+
+distclean_clipper2:
+ rm -rf clipper2
+
+clean_all: clean_clipper2
+distclean_all: distclean_clipper2
+install_all: clipper2
+uninstall_all: uninstall_clipper2
diff --git a/src/clipper2_1.1.1.sh b/src/clipper2_1.1.1.sh
@@ -20,8 +20,10 @@ set -e
[ -n "${CLIPPER2_SH}" ] && return
export CLIPPER2_SH=1
-. "build.sh"
+tag="Clipper2_1.1.1"
-name="clipper2"
-url="$\(REPO_BIN\)/clipper2_1.1.1_gnu_linux64.tgz"
-bin_spkg
+sed "s/@TAG@/${tag}/" "src/clipper2.mk.in"
+
+# Add the template file as a prerequisite for the script invoked
+# i.e. the build file
+printf "%s: src/clipper.mk.in\n" "$0"