aboutsummaryrefslogtreecommitdiff
path: root/vendor/sync
blob: 0b6af953b26e1c764dcea392051e5252a4b734e1 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/sh

# globals

ROOT=~/u
VENDOR=$ROOT/vendor

mkdir -p $ROOT/lib

# ------------------------------------------------------------------------
# OpenBLAS

BLAS_URL="https://github.com/xianyi/OpenBLAS.git"
BLAS_TAG="v0.3.17"

build_blas()
{
    git clone $BLAS_URL blas
    cd blas && 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/blas

    cd $VENDOR
    echo $BLAS_TAG > blas/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.h

    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

    mkdir - p $ROOT/lib/crt

    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

    rm $ROOT/bin/musl-gcc

    cd $VENDOR
    echo $MUSL_TAG > musl/build.tag
}

# ------------------------------------------------------------------------
# musl libc

ZLIB_URL="https://github.com/madler/zlib.git"
ZLIB_TAG="v1.2.11"

build_zlib()
{
    git clone $ZLIB_URL zlib
    cd zlib && git checkout $ZLIB_TAG
    prefix=$ROOT ./configure --static

    make -j2
    make install

    mv $ROOT/include/zlib.h $ROOT/include/zconf.h $ROOT/include/vendor

    cd $VENDOR
    echo $ZLIB_TAG > zlib/build.tag
}

# ------------------------------------------------------------------------
# GLFW

GLFW_URL="https://github.com/glfw/glfw.git"
GLFW_TAG="3.3.4"

build_glfw()
{
    git clone $GLFW_URL glfw
    cd glfw && git checkout $GLFW_TAG && mkdir build && cd build

    cmake \
        -DCMAKE_INSTALL_PREFIX=$ROOT \
        -DBUILD_SHARED_LIBS=OFF \
        -DGLFW_BUILD_EXAMPLES=OFF \
        -DGLFW_BUILD_TESTS=OFF \
        -DGLFW_BUILD_DOCS=OFF \
        -DGLFW_VULKAN_STATIC=OFF \
        -DCMAKE_BUILD_TYPE=Release \
        ..

    make -j2
    make install

    mv $ROOT/include/GLFW $ROOT/include/vendor
    rm -rf $ROOT/lib/cmake
    rm -rf $ROOT/lib/pkgconfig

    cd $VENDOR
    echo $GLFW_TAG > glfw/build.tag
}

# ------------------------------------------------------------------------
# wlroot

WLROOTS_URL="https://github.com/swaywm/wlroots.git"
WLROOTS_TAG="0.14.1"

build_wlroots()
{
    git clone $WLROOTS_URL
    cd wlroots && git checkout $WLROOTS_TAG 
    meson \
        --prefix=$ROOT \
        --includedir=include/vendor \
        --libdir=lib/vendor \
        -Ddefault_library=static \
        build/ \
    && ninja -C build/ \
    && meson install -C build

    mv $ROOT/lib/vendor/pkgconfig/* $ROOT/lib/pkgconfig
    rm -rf $ROOT/lib/vendor/pkgconfig

    cd $VENDOR
    echo $WLROOTS_TAG > wlroots/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 blas $BLAS_TAG

update musl $MUSL_TAG
update zlib $ZLIB_TAG

# update wlroots $WLROOTS_TAG