star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

clipper2.mk.in (2960B)


      1 # Copyright (C) 2023-2025 |Méso|Star> (contact@meso-star.com)
      2 #
      3 # This program is free software: you can redistribute it and/or modify
      4 # it under the terms of the GNU General Public License as published by
      5 # the Free Software Foundation, either version 3 of the License, or
      6 # (at your option) any later version.
      7 #
      8 # This program is distributed in the hope that it will be useful,
      9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11 # GNU General Public License for more details.
     12 #
     13 # You should have received a copy of the GNU General Public License
     14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     15 
     16 # Configuration macros
     17 CLIPPER2_TAG=TAG
     18 CLIPPER2_URL_ONLINE = https://github.com/AngusJohnson/Clipper2
     19 CLIPPER2_URL_OFFLINE = $(MIRROR)/Clipper2
     20 CLIPPER2_URL = $(CLIPPER2_URL_$(NETWORK))
     21 
     22 # Helper macros
     23 CLIPPER2_DIR=$(CACHE)/clipper2/$(CLIPPER2_TAG)
     24 CLIPPER2_CMAKE_OPTIONS =\
     25  ifelse(TAG, Clipper2_1.1.1, -DCMAKE_CXX_FLAGS=-Wno-template-id-cdtor)\
     26  -DCMAKE_BUILD_TYPE=Release\
     27  -DCMAKE_INSTALL_LIBDIR="lib"\
     28  -DCLIPPER2_TESTS=0\
     29  -DCLIPPER2_UTILS=0\
     30  -DCLIPPER2_EXAMPLES=0\
     31  -DBUILD_SHARED_LIBS=1
     32 
     33 clipper2: build_clipper2
     34 	@prefix="$$(cat .prefix)" && \
     35 	cd -- "$(CLIPPER2_DIR)/CPP/build" && \
     36 	cmake -DCMAKE_INSTALL_PREFIX="$${prefix}" .. > /dev/null 2>&1 && \
     37 	$(MAKE) install
     38 
     39 build_clipper2: $(CLIPPER2_DIR) $(CLIPPER2_DIR)/patch
     40 	@cd -- "$(CLIPPER2_DIR)/CPP/build" && \
     41 	cmake $(CLIPPER2_CMAKE_OPTIONS) .. && \
     42 	$(MAKE)
     43 
     44 $(CLIPPER2_DIR):
     45 	@git clone --branch "$(CLIPPER2_TAG)" --depth 1 "$(CLIPPER2_URL)" $@
     46 	@mkdir -p "$@/CPP/build"
     47 
     48 $(CLIPPER2_DIR)/patch: $(CLIPPER2_DIR)
     49 	# Version number is wrong
     50 	sed -i 's/ VERSION 1\.1\.0 / VERSION 1.1.1 /' \
     51 		"$(CLIPPER2_DIR)/CPP/CMakeLists.txt"
     52 	# Missing LIBRARY DESTINATION for targets (cmake fails)
     53 	re="install(TARGETS Clipper2 Clipper2Z"; \
     54 	sed -i "s/^$${re}$$/$${re} LIBRARY DESTINATION \$${CMAKE_INSTALL_LIBDIR}/" \
     55 		"$(CLIPPER2_DIR)/CPP/CMakeLists.txt"
     56 	# Missing cstdint (compilation fails)
     57 	re="#include <climits>"; \
     58 	sed -i "s/^$${re}$$/$${re}\n#include <cstdint>/" \
     59 		"$(CLIPPER2_DIR)/CPP/Clipper2Lib/include/clipper2/clipper.core.h"
     60 	echo "done" > "$@"
     61 
     62 clean_clipper2:
     63 	if [ -d "$(CLIPPER2_DIR)/CPP/build" ]; then \
     64 		cd -- "$(CLIPPER2_DIR)/CPP/build" && $(MAKE) clean; \
     65 	fi
     66 
     67 uninstall_clipper2: $(CLIPPER2_DIR)
     68 	@prefix="$$(cat .prefix)" && \
     69 	cd -- "$(CLIPPER2_DIR)/CPP/build" && \
     70 	cmake $(CLIPPER2_CMAKE_OPTIONS) -DCMAKE_INSTALL_PREFIX="$${prefix}" .. && \
     71 	$(MAKE) install
     72 	xargs rm -f < "$(CLIPPER2_DIR)/CPP/build/install_manifest.txt"
     73 
     74 mirror_clipper2:
     75 	repo="$$(echo "$(CLIPPER2_URL)" | sed 's/[\/]\{0,\}$$//g')" && \
     76 	repo="$(MIRROR)/$${repo##*/}" && \
     77 	rm -rf "$${repo}" && \
     78 	git clone --bare --branch "$(CLIPPER2_TAG)" $(MIRROR_GIT_OPT) \
     79 	  $(CLIPPER2_URL) "$${repo}"
     80 
     81 clean_all: clean_clipper2
     82 install_all: clipper2
     83 uninstall_all: uninstall_clipper2
     84 mirror_all: mirror_clipper2