Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build/pkg-install.sh. #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions build/pkg-install.sh
Original file line number Diff line number Diff line change
@@ -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
)