aboutsummaryrefslogtreecommitdiff
path: root/vendor/sync
blob: fa019cdd9e504c0e11ca54a0eb20c012e7c6f013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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