From 958b46feaae4ec155d322b9fb501f26cc918619f Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Thu, 2 Nov 2023 13:04:20 +0100 Subject: [PATCH] Add build/pkg-install.sh. Compile latest release tag and install it as pkg-config package. --- build/pkg-install.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 build/pkg-install.sh diff --git a/build/pkg-install.sh b/build/pkg-install.sh new file mode 100755 index 00000000..0fcc461b --- /dev/null +++ b/build/pkg-install.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +_IFS="$IFS"; IFS=':' +for dir in $PKG_CONFIG_PATH `pkg-config --variable pc_path pkg-config`; do + if [ -d "${dir}" -a -w "${dir}" -a -d "${dir}/../../include" ]; then + DST="$dir" + break + fi +done +IFS="$_IFS"; unset _IFS + +if [ -z "${DST}" ]; then + echo "no suitable pkg-config directory found." + exit 1 +fi + +if [ `basename $0` = "pkg-install.sh" ]; then + SRC=`dirname $0` + SRC=`(cd $SRC/..; [ -d .git ] && pwd)` +fi + +export DST +cd ${TMPDIR:-/tmp} + +trap 'rm -rf blst.$$' 0 +git clone ${SRC:-"https://github.com/supranational/blst"} blst.$$ +( trap '[ $? -ne 0 ] && rm "${DST}/blst.pc" 2>/dev/null' 0 + cd blst.$$ + tag=`git tag --sort=v:refname | tail -1` + git checkout --detach ${tag} + ./build.sh "$@" + cp libblst.a "${DST}/.." + cp bindings/blst.h* "${DST}/../../include" + cat > "${DST}/blst.pc" << blst.pc +libdir=\${pcfiledir}/.. +incdir=\${pcfiledir}/../../include +Name: blst +Version: $tag +Description: blst core library +Cflags: -I\${incdir} +Libs: -L\${libdir} -lblst +blst.pc +)