library_builders.sh 5.72 KB
Newer Older
1
# Recipes for building some libaries
Matthew Brett's avatar
Matthew Brett committed
2
OPENBLAS_VERSION="${OPENBLAS_VERSION:-0.2.18}"
3
4
5
6
7
# We use system zlib by default - see build_new_zlib
ZLIB_VERSION="${ZLIB_VERSION:-1.2.8}"
LIBPNG_VERSION="${LIBPNG_VERSION:-1.6.21}"
BZIP2_VERSION="${BZIP2_VERSION:-1.0.6}"
FREETYPE_VERSION="${FREETYPE_VERSION:-2.6.3}"
Matthew Brett's avatar
Matthew Brett committed
8
TIFF_VERSION="${TIFF_VERSION:-4.0.6}"
9
10
11
12
13
14
OPENJPEG_VERSION="${OPENJPEG_VERSION:-2.1}"
LCMS2_VERSION="${LCMS2_VERSION:-2.7}"
GIFLIB_VERSION="${GIFLIB_VERSION:-5.1.3}"
LIBWEBP_VERSION="${LIBWEBP_VERSION:-0.5.0}"
XZ_VERSION="${XZ_VERSION:-5.2.2}"
LIBYAML_VERSION="${LIBYAML_VERSION:-0.1.5}"
Matthew Brett's avatar
Matthew Brett committed
15
16
SZIP_VERSION="${SZIP_VERSION:-2.1}"
HDF5_VERSION="${HDF5_VERSION:-1.8.17}"
17
LIBAEC_VERSION="${LIBAEC_VERSION:-0.3.3}"
Matthew Brett's avatar
Matthew Brett committed
18
BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
19

20
21
22
23
24
if [ $(uname) == "Darwin" ]; then
    ARCH_FLAGS=${ARCH_FLAGS:-"-arch i386 -arch x86_64"}
    export CFLAGS="${CFLAGS} $ARCH_FLAGS"
    IS_OSX=1
fi
25
26
27
28
29
30
31
32
33
34
35
36

function build_simple {
    local name=$1
    local version=$2
    local url=$3
    if [ -e "${name}-stamp" ]; then
        return
    fi
    local name_version="${name}-${version}"
    local targz=${name_version}.tar.gz
    curl -LO $url/$targz
    tar zxf $targz
Matthew Brett's avatar
Matthew Brett committed
37
38
39
40
    (cd $name_version \
        && ./configure --prefix=$BUILD_PREFIX \
        && make \
        && make install)
41
42
43
44
45
46
47
48
49
    touch "${name}-stamp"
}

function build_openblas {
    if [ -e openblas-stamp ]; then return; fi
    git clone https://github.com/xianyi/OpenBLAS
    (cd OpenBLAS \
        && git checkout "v${OPENBLAS_VERSION}" \
        && make DYNAMIC_ARCH=1 USE_OPENMP=0 NUM_THREADS=64 > /dev/null \
Matthew Brett's avatar
Matthew Brett committed
50
        && make PREFIX=$BUILD_PREFIX install)
51
52
53
54
55
56
    touch openblas-stamp
}

function build_zlib {
    # Gives an old but safe version
    if [ -e zlib-stamp ]; then return; fi
57
58
    # OSX has zlib already
    if [ -z "$IS_OSX" ]; then yum install -y zlib-devel; fi
59
60
61
62
63
64
65
66
67
68
69
70
    touch zlib-stamp
}

function build_new_zlib {
    # Careful, this one may cause yum to segfault
    build_simple zlib $ZLIB_VERSION http://zlib.net
}

function build_jpeg {
    if [ -e jpeg-stamp ]; then return; fi
    curl -LO http://ijg.org/files/jpegsrc.v9b.tar.gz
    tar zxf jpegsrc.v9b.tar.gz
Matthew Brett's avatar
Matthew Brett committed
71
72
73
74
    (cd jpeg-9b \
        && ./configure --prefix=$BUILD_PREFIX \
        && make \
        && make install)
75
76
77
78
79
80
81
82
83
84
85
86
    touch jpeg-stamp
}

function build_libpng {
    build_zlib
    build_simple libpng $LIBPNG_VERSION http://download.sourceforge.net/libpng
}

function build_bzip2 {
    if [ -e bzip2-stamp ]; then return; fi
    curl -LO http://bzip.org/${BZIP2_VERSION}/bzip2-${BZIP2_VERSION}.tar.gz
    tar zxf bzip2-${BZIP2_VERSION}.tar.gz
Matthew Brett's avatar
Matthew Brett committed
87
88
89
    (cd bzip2-${BZIP2_VERSION} \
        && make -f Makefile-libbz2_so \
        && make install PREFIX=$BUILD_PREFIX)
90
91
92
93
94
95
96
97
    touch bzip2-stamp
}

function build_tiff {
    build_zlib
    build_jpeg
    build_openjpeg
    build_xz
Matthew Brett's avatar
Matthew Brett committed
98
    build_simple tiff $TIFF_VERSION http://download.osgeo.org/libtiff
99
100
101
102
}

function build_openjpeg {
    if [ -e openjpeg-stamp ]; then return; fi
Matthew Brett's avatar
Matthew Brett committed
103
    local cmake=cmake
104
105
106
107
    if [ -n "$IS_OSX" ]; then
        brew install cmake
    else
        yum install -y cmake28
Matthew Brett's avatar
Matthew Brett committed
108
        cmake=cmake28
109
    fi
110
111
    curl -LO https://github.com/uclouvain/openjpeg/archive/version.${OPENJPEG_VERSION}.tar.gz
    tar zxf version.${OPENJPEG_VERSION}.tar.gz
Matthew Brett's avatar
Matthew Brett committed
112
113
114
    (cd openjpeg-version.${OPENJPEG_VERSION} \
        && $cmake -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX . \
        && make install)
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    touch openjpeg-stamp
}

function build_lcms2 {
    build_tiff
    build_simple lcms2 $LCMS2_VERSION http://downloads.sourceforge.net/project/lcms/lcms/$LCMS2_VERSION
}

function build_giflib {
    build_simple giflib $GIFLIB_VERSION http://downloads.sourceforge.net/project/giflib
}

function build_xz {
    build_simple xz $XZ_VERSION http://tukaani.org/xz
}

function build_libwebp {
    if [ -e libwebp-stamp ]; then return; fi
    build_libpng
    build_tiff
    build_giflib
    curl -LO https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${LIBWEBP_VERSION}.tar.gz
    tar zxf libwebp-${LIBWEBP_VERSION}.tar.gz
    (cd libwebp-${LIBWEBP_VERSION} && \
Matthew Brett's avatar
Matthew Brett committed
139
140
141
        ./configure --enable-libwebpmux --enable-libwebpdemux --prefix=$BUILD_PREFIX \
        && make \
        && make install)
142
143
144
145
146
147
148
149
150
151
152
153
    touch libwebp-stamp
}

function build_freetype {
    build_libpng
    build_bzip2
    build_simple freetype $FREETYPE_VERSION http://download.savannah.gnu.org/releases/freetype
}

function build_libyaml {
    build_simple yaml $LIBYAML_VERSION http://pyyaml.org/download/libyaml
}
Matthew Brett's avatar
Matthew Brett committed
154
155
156
157
158
159
160
161
162

function build_szip {
    # Build szip without encoding (patent restrictions)
    if [ -e szip-stamp ]; then return; fi
    build_zlib
    local szip_url=https://www.hdfgroup.org/ftp/lib-external/szip/
    curl -sLO ${szip_url}/$SZIP_VERSION/src/szip-$SZIP_VERSION.tar.gz
    tar zxf szip-$SZIP_VERSION.tar.gz
    (cd szip-$SZIP_VERSION \
Matthew Brett's avatar
Matthew Brett committed
163
        && ./configure --enable-encoding=no --prefix=$BUILD_PREFIX \
Matthew Brett's avatar
Matthew Brett committed
164
165
166
167
168
169
170
        && make \
        && make install)
    touch szip-stamp
}

function build_hdf5 {
    if [ -e hdf5-stamp ]; then return; fi
171
172
    # libaec is a drop-in replacement for szip
    build_libaec
Matthew Brett's avatar
Matthew Brett committed
173
174
175
176
    local hdf5_url=https://www.hdfgroup.org/ftp/HDF5/releases
    curl -sLO $hdf5_url/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz
    tar zxf hdf5-$HDF5_VERSION.tar.gz
    (cd hdf5-$HDF5_VERSION \
Matthew Brett's avatar
Matthew Brett committed
177
        && ./configure --with-szlib=$BUILD_PREFIX --prefix=$BUILD_PREFIX \
Matthew Brett's avatar
Matthew Brett committed
178
179
180
181
        && make \
        && make install)
    touch hdf5-stamp
}
182
183
184
185
186
187
188
189
190

function build_libaec {
    if [ -e libaec-stamp ]; then return; fi
    local root_name=libaec-0.3.3
    local tar_name=${root_name}.tar.gz
    # Note URL will change for each version
    curl -LO https://gitlab.dkrz.de/k202009/libaec/uploads/48398bd5b7bc05a3edb3325abfeac864/${tar_name}
    tar zxf $tar_name
    (cd $root_name \
Matthew Brett's avatar
Matthew Brett committed
191
        && ./configure --prefix=$BUILD_PREFIX \
192
193
194
195
        && make \
        && make install)
    touch libaec-stamp
}