aboutsummaryrefslogtreecommitdiff
path: root/init
blob: 32b810d24d9a5b4e894161d4c25c7635d259692f (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
#!/bin/sh

# this script should only be run once per initialization of the repo
# it's job is to pull in code external to the source tree
# after it completes, simply run make

# TODO: set up cross compiling directories

inc=$PWD/include/vendor
lib=$PWD/lib
root=$PWD

if [ -d vendor -a -z $1 ]; then
    echo already initialized, remove vendor directory or force argument to rerun 
else
    # setup directories
    mkdir -p vendor 1>&2 2>/dev/null
    mkdir -p $lib 1>&2 2>/dev/null
    mkdir -p $inc 1>&2 2>/dev/null

    # install musl
    # dependencies: nil
    if [ -d $inc/libc ]; then
        echo libc found, skipping 
    else
        git clone git://git.musl-libc.org/musl vendor/musl
        cd vendor/musl && ./configure && make

        cp -r obj/include $inc/libc
        cp -r obj/crt $lib/crt
        cp -r lib/*.a $lib
    fi

    cd $root

    # install OpenBLAS
    # dependencies: gfortran
    # warning: this is a _monster_
    if [ -d $inc/blas ]; then
        echo blas found, skipping
    else
        git clone https://github.com/xianyi/OpenBLAS.git vendor/blas 
        cd vendor/blas && make USE_THREAD=0 -j4

        cp libopenblas_*.a $lib/libblas.a
        mkdir -p $inc/blas
        cp cblas.h common*.h config.h param.h $inc/blas

        # install LAPACKE ...ugh...
        cd lapack-netlib && cp make.inc.example make.inc && make -j4
        cd LAPACKE && make && cd ..
        cp liblapack.a liblapacke.a $lib
        cp LAPACKE/include/lapack*.h $inc/blas
    fi

    cd $root
fi