From 8c0475f97675245d1bcbb112dc79c9f490fad361 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 3 Sep 2021 14:53:35 -0700 Subject: feat: added script to synchronize external dependencies --- vendor/sync | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 vendor/sync (limited to 'vendor') diff --git a/vendor/sync b/vendor/sync new file mode 100755 index 0000000..fa019cd --- /dev/null +++ b/vendor/sync @@ -0,0 +1,126 @@ +#!/bin/sh + +# globals + +ROOT=~/root +VENDOR=$ROOT/vendor + +# ------------------------------------------------------------------------ +# OpenBLAS + +BLAS_URL="https://github.com/xianyi/OpenBLAS.git" +BLAS_TAG="v0.3.17" + +build_blas() +{ + git clone $BLAS_URL blas + cd OpenBLAS && git checkout $BLAS_TAG + NO_SHARED=1 TARGET=GENERIC PREFIX=$ROOT make -j2 + NO_SHARED=1 make install PREFIX=$ROOT + + rm -rf $ROOT/lib/cmake + rm -rf $ROOT/lib/pkgconfig + + mv $ROOT/include/lapacke.h \ + $ROOT/include/lapack.h \ + $ROOT/include/cblas.h \ + $ROOT/include/f77blas.h \ + $ROOT/include/lapacke_utils.h \ + $ROOT/include/openblas_config.h \ + $ROOT/include/lapacke_config.h \ + $ROOT/include/lapacke_mangling.h \ + $ROOT/include/vendor/OpenBLAS + + cd $VENDOR + echo $BLAS_TAG > OpenBLAS/build.tag +} + +# ------------------------------------------------------------------------ +# NLOpt + +NLOPT_URL="https://github.com/stevengj/nlopt.git" +NLOPT_TAG="v2.7.0" + +build_nlopt() +{ + git clone $NLOPT_URL + cd nlopt && git checkout $NLOPT_TAG && mkdir build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX=$ROOT \ + -DBUILD_SHARED_LIBS=OFF \ + -DNLOPT_PYTHON=OFF \ + -DNLOPT_MATLAB=OFF \ + -DNLOPT_OCTAVE=OFF \ + -DNLOPT_CXX=OFF \ + -DNLOPT_GUILE=OFF \ + -DNLOPT_SWIG=OFF \ + -DNLOPT_FORTRAN=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + .. + make -j2 + sed -i -n '/nlopt.[ah]$/p' install_manifest.txt + make install + + # remove unwanted files + rm -f $ROOT/nlopt.hpp + rm -f $ROOT/nlopt.f + rm -rf $ROOT/lib/cmake + # rm -rf $ROOT/man + + mv $ROOT/include/nlopt.h $ROOT/include/vendor/nlopt + + cd $VENDOR + echo $NLOPT_TAG > nlopt/build.tag +} + +# ------------------------------------------------------------------------ +# musl libc + +MUSL_URL="git://git.musl-libc.org/musl" +MUSL_TAG="v1.2.2" + +build_musl() +{ + git clone $MUSL_URL + cd musl && git checkout $MUSL_TAG + ./configure \ + --prefix=$ROOT \ + --includedir=$ROOT/include/vendor/libc \ + --disable-shared + + make -j2 + make install + mv $ROOT/lib/rcrt1.o \ + $ROOT/lib/crt1.o \ + $ROOT/lib/Scrt1.o \ + $ROOT/lib/musl-gcc.specs \ + $ROOT/lib/crt + mv $ROOT/lib/crti.o $ROOT/lib/crtn.o $ROOT/lib/crt/x86_64 + + rm $ROOT/bin/musl-gcc + + cd $VENDOR + echo $MUSL_TAG > musl/build.tag +} + +# ------------------------------------------------------------------------ +# utility functions + +update() +{ + base=$1 + tag=$2 + + if [ -d $base ] && [ `cat $base/build.tag` = $tag ]; then + echo "$base: up to date" + else + build_$base + fi +} + +# ------------------------------------------------------------------------ +# main point of entry + +update nlopt $NLOPT_TAG +update musl $MUSL_TAG +update blas $BLAS_TAG -- cgit v1.2.1