You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by la...@apache.org on 2018/12/13 01:14:26 UTC

[incubator-mxnet] branch master updated: Scripts for building dependency libraries of MXNet (#13282)

This is an automated email from the ASF dual-hosted git repository.

lanking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 439f167  Scripts for building dependency libraries of MXNet (#13282)
439f167 is described below

commit 439f167db225af5ca9e27f53e4b6bfc3abd03acb
Author: Sheng Zha <sz...@users.noreply.github.com>
AuthorDate: Wed Dec 12 17:14:13 2018 -0800

    Scripts for building dependency libraries of MXNet (#13282)
    
    * openblas script
    
    * ps-lite dependencies
    
    * USE_S3 dependencies
    
    * image libraries
    
    * license
---
 tools/dependencies/README.md       |  14 +++
 tools/dependencies/cityhash.sh     |  32 +++++++
 tools/dependencies/curl.sh         |  64 +++++++++++++
 tools/dependencies/eigen.sh        |  34 +++++++
 tools/dependencies/libpng.sh       |  40 ++++++++
 tools/dependencies/libtiff.sh      |  32 +++++++
 tools/dependencies/libturbojpeg.sh |  47 +++++++++
 tools/dependencies/libz.sh         |  36 +++++++
 tools/dependencies/lz4.sh          |  31 ++++++
 tools/dependencies/openblas.sh     |  35 +++++++
 tools/dependencies/opencv.sh       | 191 +++++++++++++++++++++++++++++++++++++
 tools/dependencies/openssl.sh      |  38 ++++++++
 tools/dependencies/protobuf.sh     |  41 ++++++++
 tools/dependencies/zmq.sh          |  38 ++++++++
 14 files changed, 673 insertions(+)

diff --git a/tools/dependencies/README.md b/tools/dependencies/README.md
new file mode 100644
index 0000000..cfe3d6c
--- /dev/null
+++ b/tools/dependencies/README.md
@@ -0,0 +1,14 @@
+# Overview
+
+This folder contains scripts for building the dependencies from source. The static libraries from
+the build artifacts can be used to create self-contained shared object for mxnet through static
+linking.
+
+# Settings
+
+The scripts use the following environment variables for setting behavior:
+
+`DEPS_PATH`: the location in which the libraries are downloaded, built, and installed.
+`PLATFORM`: name of the OS in lower case. Supported options are 'linux' and 'darwin'.
+
+It also expects the following build tools in path: make, cmake, tar, unzip, autoconf, nasm
diff --git a/tools/dependencies/cityhash.sh b/tools/dependencies/cityhash.sh
new file mode 100755
index 0000000..81cc9cb
--- /dev/null
+++ b/tools/dependencies/cityhash.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of cityhash that can be used as dependency of mxnet.
+CITYHASH_VERSION=1.1.1
+if [[ ! -f $DEPS_PATH/lib/libcityhash.a ]]; then
+    # Download and build cityhash
+    >&2 echo "Building cityhash..."
+    git clone https://github.com/google/cityhash $DEPS_PATH/cityhash-$CITYHASH_VERSION
+    cd $DEPS_PATH/cityhash-$CITYHASH_VERSION
+    git reset --hard 8af9b8c2b889d80c22d6bc26ba0df1afb79a30db
+    ./configure -prefix=$DEPS_PATH --enable-sse4.2
+    make CXXFLAGS="-g -O3 -msse4.2"
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/curl.sh b/tools/dependencies/curl.sh
new file mode 100755
index 0000000..9633edb
--- /dev/null
+++ b/tools/dependencies/curl.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of libcurl that can be used as dependency of mxnet.
+LIBCURL_VERSION=7.61.0
+if [[ ! -f $DEPS_PATH/lib/libcurl.a ]]; then
+    # download and build libcurl
+    >&2 echo "Building libcurl..."
+    curl -s -L https://curl.haxx.se/download/curl-$LIBCURL_VERSION.zip -o $DEPS_PATH/libcurl.zip
+    unzip -q $DEPS_PATH/libcurl.zip -d $DEPS_PATH
+    cd $DEPS_PATH/curl-$LIBCURL_VERSION
+    if [[ $PLATFORM == 'linux' ]]; then
+        CONFIG_FLAG=""
+    elif [[ $PLATFORM == 'darwin' ]]; then
+        CONFIG_FLAG="--with-darwinssl"
+    fi
+    ./configure $CONFIG_FLAG \
+                --with-zlib \
+                --with-nghttps2 \
+                --without-zsh-functions-dir \
+                --without-librtmp \
+                --without-libssh2 \
+                --disable-debug \
+                --disable-curldebug \
+                --enable-symbol-hiding=yes \
+                --enable-optimize=yes \
+                --enable-shared=no \
+                --enable-http=yes \
+                --enable-ipv6=yes \
+                --disable-ftp \
+                --disable-ldap \
+                --disable-ldaps \
+                --disable-rtsp \
+                --disable-proxy \
+                --disable-dict \
+                --disable-telnet \
+                --disable-tftp \
+                --disable-pop3 \
+                --disable-imap \
+                --disable-smb \
+                --disable-smtp \
+                --disable-gopher \
+                --disable-manual \
+                --prefix=$DEPS_PATH
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/eigen.sh b/tools/dependencies/eigen.sh
new file mode 100755
index 0000000..ac2f75a
--- /dev/null
+++ b/tools/dependencies/eigen.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script imports the headers from eigen3 that can be used to in opencv.
+EIGEN_VERSION=3.3.4
+if [[ ! -d $DEPS_PATH/include/eigen3 ]]; then
+    # download eigen
+    >&2 echo "Loading eigen..."
+    curl -s -L https://github.com/eigenteam/eigen-git-mirror/archive/$EIGEN_VERSION.zip -o $DEPS_PATH/eigen.zip
+    unzip -q $DEPS_PATH/eigen.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/eigen-git-mirror-$EIGEN_VERSION/build
+    cd $DEPS_PATH/eigen-git-mirror-$EIGEN_VERSION/build
+    cmake \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH ..
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/libpng.sh b/tools/dependencies/libpng.sh
new file mode 100755
index 0000000..d1523c6
--- /dev/null
+++ b/tools/dependencies/libpng.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of libpng that can be used as dependency of mxnet/opencv.
+PNG_VERSION=1.6.34
+if [[ ! -f $DEPS_PATH/lib/libpng.a ]]; then
+    # download and build libpng
+    >&2 echo "Building libpng..."
+    curl -s -L https://github.com/glennrp/libpng/archive/v$PNG_VERSION.zip -o $DEPS_PATH/libpng.zip
+    unzip -q $DEPS_PATH/libpng.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/libpng-$PNG_VERSION/build
+    cd $DEPS_PATH/libpng-$PNG_VERSION/build
+    cmake \
+          -D PNG_SHARED=OFF \
+          -D PNG_STATIC=ON \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH \
+          -D CMAKE_C_FLAGS=-fPIC ..
+    make
+    make install
+    mkdir -p $DEPS_PATH/include/libpng
+    ln -s $DEPS_PATH/include/png.h $DEPS_PATH/include/libpng/png.h
+    cd -
+fi
diff --git a/tools/dependencies/libtiff.sh b/tools/dependencies/libtiff.sh
new file mode 100755
index 0000000..14dcb2d
--- /dev/null
+++ b/tools/dependencies/libtiff.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of libtiff that can be used as dependency of mxnet/opencv.
+TIFF_VERSION="4-0-9"
+if [[ ! -f $DEPS_PATH/lib/libtiff.a ]]; then
+    # download and build libtiff
+    >&2 echo "Building libtiff..."
+    curl -s -L https://gitlab.com/libtiff/libtiff/-/archive/Release-v$TIFF_VERSION/libtiff-Release-v$TIFF_VERSION.zip -o $DEPS_PATH/libtiff.zip
+    unzip -q $DEPS_PATH/libtiff.zip -d $DEPS_PATH
+    cd $DEPS_PATH/libtiff-Release-v$TIFF_VERSION
+    ./configure --quiet --disable-shared --disable-jpeg --disable-zlib --disable-jbig --disable-lzma --prefix=$DEPS_PATH
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/libturbojpeg.sh b/tools/dependencies/libturbojpeg.sh
new file mode 100755
index 0000000..4991906
--- /dev/null
+++ b/tools/dependencies/libturbojpeg.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of libturbojpeg that can be used as dependency of
+# mxnet/opencv.
+TURBO_JPEG_VERSION=1.5.90
+if [[ $PLATFORM == 'darwin' ]]; then
+    JPEG_NASM_OPTION="-D CMAKE_ASM_NASM_COMPILER=/usr/local/bin/nasm"
+fi
+
+if [[ ! -f $DEPS_PATH/lib/libjpeg.a ]] || [[ ! -f $DEPS_PATH/lib/libturbojpeg.a ]]; then
+    # download and build libjpeg
+    >&2 echo "Building libjpeg-turbo..."
+    curl -s -L https://github.com/libjpeg-turbo/libjpeg-turbo/archive/$TURBO_JPEG_VERSION.zip -o $DEPS_PATH/libjpeg.zip
+    unzip -q $DEPS_PATH/libjpeg.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/libjpeg-turbo-$TURBO_JPEG_VERSION/build
+    cd $DEPS_PATH/libjpeg-turbo-$TURBO_JPEG_VERSION/build
+    cmake \
+          -G"Unix Makefiles" \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH \
+          -D CMAKE_C_FLAGS=-fPIC \
+          -D WITH_JAVA=FALSE \
+          -D WITH_JPEG7=TRUE \
+          -D WITH_JPEG8=TRUE \
+          $JPEG_NASM_OPTION \
+          -D ENABLE_SHARED=FALSE ..
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/libz.sh b/tools/dependencies/libz.sh
new file mode 100755
index 0000000..927f1de
--- /dev/null
+++ b/tools/dependencies/libz.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of libz that can be used as dependency of mxnet.
+ZLIB_VERSION=1.2.6
+if [[ ! -f $DEPS_PATH/lib/libz.a ]]; then
+    # Download and build zlib
+    >&2 echo "Building zlib..."
+    curl -s -L https://github.com/LuaDist/zlib/archive/$ZLIB_VERSION.zip -o $DEPS_PATH/zlib.zip
+    unzip -q $DEPS_PATH/zlib.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/zlib-$ZLIB_VERSION/build
+    cd $DEPS_PATH/zlib-$ZLIB_VERSION/build
+    cmake \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH \
+          -D BUILD_SHARED_LIBS=OFF ..
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/lz4.sh b/tools/dependencies/lz4.sh
new file mode 100755
index 0000000..a4269bf
--- /dev/null
+++ b/tools/dependencies/lz4.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of lz4 that can be used as dependency of mxnet.
+LZ4_VERSION=r130
+if [[ ! -f $DEPS_PATH/lib/liblz4.a ]]; then
+    # Download and build lz4
+    >&2 echo "Building lz4..."
+    curl -s -L https://github.com/lz4/lz4/archive/$LZ4_VERSION.zip -o $DEPS_PATH/lz4.zip
+    unzip -q $DEPS_PATH/lz4.zip -d $DEPS_PATH
+    cd $DEPS_PATH/lz4-$LZ4_VERSION
+    make
+    make PREFIX=$DEPS_PATH install
+    cd -
+fi
diff --git a/tools/dependencies/openblas.sh b/tools/dependencies/openblas.sh
new file mode 100755
index 0000000..9463e33
--- /dev/null
+++ b/tools/dependencies/openblas.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of openblas that can be used as dependency of mxnet.
+OPENBLAS_VERSION=0.3.3
+if [[ ! -e $DEPS_PATH/lib/libopenblas.a ]]; then
+    # download and build openblas
+    >&2 echo "Building openblas..."
+
+    curl -s -L https://github.com/xianyi/OpenBLAS/archive/v$OPENBLAS_VERSION.zip -o $DEPS_PATH/openblas.zip
+    unzip -q $DEPS_PATH/openblas.zip -d $DEPS_PATH
+    cd $DEPS_PATH/OpenBLAS-$OPENBLAS_VERSION
+
+    make DYNAMIC_ARCH=1 NO_SHARED=1 USE_OPENMP=1
+    make PREFIX=$DEPS_PATH install
+    cd -
+    ln -s libopenblas.a $DEPS_PATH/lib/libcblas.a
+    ln -s libopenblas.a $DEPS_PATH/lib/liblapack.a
+fi
diff --git a/tools/dependencies/opencv.sh b/tools/dependencies/opencv.sh
new file mode 100755
index 0000000..98ff115
--- /dev/null
+++ b/tools/dependencies/opencv.sh
@@ -0,0 +1,191 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of opencv that can be used as dependency of mxnet.
+# It expects openblas, libjpeg, libpng, libtiff, eigen, etc., to be in $DEPS_PATH.
+OPENCV_VERSION=3.4.2
+if [[ $PLATFORM == 'linux' ]]; then
+    OPENCV_LAPACK_OPTIONS=" \
+          -D OpenBLAS_HOME=$DEPS_PATH \
+          -D OpenBLAS_INCLUDE_DIR=$DEPS_PATH/include \
+          -D OpenBLAS_LIB=$DEPS_PATH/lib/libopenblas.a \
+          -D LAPACK_INCLUDE_DIR=$DEPS_PATH/include \
+          -D LAPACK_LINK_LIBRARIES=$DEPS_PATH/lib/ \
+          -D LAPACK_LIBRARIES=$DEPS_PATH/lib/libopenblas.a \
+          -D LAPACK_CBLAS_H='cblas.h' \
+          -D LAPACK_LAPACKE_H='lapacke.h' \
+          -D LAPACK_IMPL='OpenBLAS' \
+          -D HAVE_LAPACK=1"
+fi
+
+if [[ ! -f $DEPS_PATH/lib/libopencv_core.a ]] || [[ ! -f $DEPS_PATH/lib/libopencv_imgcodecs.a ]] || [[ ! -f $DEPS_PATH/lib/libopencv_imgproc.a ]]; then
+    # download and build opencv since we need the static library
+    >&2 echo "Building opencv..."
+    curl -s -L https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -o $DEPS_PATH/opencv.zip
+    unzip -q $DEPS_PATH/opencv.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/opencv-$OPENCV_VERSION/build
+    cd $DEPS_PATH/opencv-$OPENCV_VERSION/build
+    cmake \
+          -D OPENCV_ENABLE_NONFREE=OFF \
+          -D WITH_1394=OFF \
+          -D WITH_ARAVIS=OFF \
+          -D WITH_AVFOUNDATION=OFF \
+          -D WITH_CAROTENE=OFF \
+          -D WITH_CLP=OFF \
+          -D WITH_CSTRIPES=OFF \
+          -D WITH_CPUFEATURES=OFF \
+          -D WITH_CUBLAS=OFF \
+          -D WITH_CUDA=OFF \
+          -D WITH_CUFFT=OFF \
+          -D WITH_DIRECTX=OFF \
+          -D WITH_DSHOW=OFF \
+          -D WITH_EIGEN=ON \
+          -D WITH_FFMPEG=OFF \
+          -D WITH_GDAL=OFF \
+          -D WITH_GDCM=OFF \
+          -D WITH_GIGEAPI=OFF \
+          -D WITH_GPHOTO2=OFF \
+          -D WITH_GSTREAMER=OFF \
+          -D WITH_GSTREAMER_0_10=OFF \
+          -D WITH_GTK=OFF \
+          -D WITH_GTK_2_X=OFF \
+          -D WITH_HALIDE=OFF \
+          -D WITH_IMAGEIO=OFF \
+          -D WITH_IMGCODEC_HDR=OFF \
+          -D WITH_IMGCODEC_PXM=OFF \
+          -D WITH_IMGCODEC_SUNRASTER=OFF \
+          -D WITH_INF_ENGINE=OFF \
+          -D WITH_INTELPERC=OFF \
+          -D WITH_IPP=OFF \
+          -D WITH_IPP_A=OFF \
+          -D WITH_ITT=OFF \
+          -D WITH_JASPER=OFF \
+          -D WITH_JPEG=ON \
+          -D WITH_LAPACK=ON \
+          -D WITH_LIBREALSENSE=OFF \
+          -D WITH_LIBV4L=OFF \
+          -D WITH_MATLAB=OFF \
+          -D WITH_MFX=OFF \
+          -D WITH_MSMF=OFF \
+          -D WITH_NVCUVID=OFF \
+          -D WITH_OPENCL=OFF \
+          -D WITH_OPENCLAMDBLAS=OFF \
+          -D WITH_OPENCLAMDFFT=OFF \
+          -D WITH_OPENCL_SVM=OFF \
+          -D WITH_OPENEXR=OFF \
+          -D WITH_OPENGL=OFF \
+          -D WITH_OPENMP=OFF \
+          -D WITH_OPENNI=OFF \
+          -D WITH_OPENNI2=OFF \
+          -D WITH_OPENVX=OFF \
+          -D WITH_PNG=ON \
+          -D WITH_PROTOBUF=OFF \
+          -D WITH_PTHREADS_PF=ON \
+          -D WITH_PVAPI=OFF \
+          -D WITH_QT=OFF \
+          -D WITH_QTKIT=OFF \
+          -D WITH_QUICKTIME=OFF \
+          -D WITH_TBB=OFF \
+          -D WITH_TIFF=ON \
+          -D WITH_UNICAP=OFF \
+          -D WITH_V4L=OFF \
+          -D WITH_VA=OFF \
+          -D WITH_VA_INTEL=OFF \
+          -D WITH_VFW=OFF \
+          -D WITH_VTK=OFF \
+          -D WITH_WEBP=OFF \
+          -D WITH_WIN32UI=OFF \
+          -D WITH_XIMEA=OFF \
+          -D WITH_XINE=OFF \
+          -D BUILD_ANDROID_EXAMPLES=OFF \
+          -D BUILD_ANDROID_PROJECTS=OFF \
+          -D BUILD_ANDROID_SERVICE=OFF \
+          -D BUILD_CUDA_STUBS=OFF \
+          -D BUILD_DOCS=OFF \
+          -D BUILD_EXAMPLES=OFF \
+          -D BUILD_FAT_JAVA_LIB=OFF \
+          -D BUILD_IPP_IW=OFF \
+          -D BUILD_ITT_IW=OFF \
+          -D BUILD_JAVA=OFF \
+          -D BUILD_JASPER=OFF \
+          -D BUILD_JPEG=OFF \
+          -D BUILD_OPENEXR=OFF \
+          -D BUILD_PACKAGE=OFF \
+          -D BUILD_PERF_TESTS=OFF \
+          -D BUILD_PNG=OFF \
+          -D BUILD_SHARED_LIBS=OFF \
+          -D BUILD_TBB=OFF \
+          -D BUILD_TESTS=OFF \
+          -D BUILD_TIFF=OFF \
+          -D BUILD_WEBP=OFF \
+          -D BUILD_WITH_DEBUG_INFO=OFF \
+          -D BUILD_WITH_DYNAMIC_IPP=OFF \
+          -D BUILD_WITH_STATIC_CRT=OFF \
+          -D BUILD_ZLIB=OFF \
+          -D BUILD_opencv_apps=OFF \
+          -D BUILD_opencv_aruco=OFF \
+          -D BUILD_opencv_calib3d=OFF \
+          -D BUILD_opencv_contrib=OFF \
+          -D BUILD_opencv_dnn=OFF \
+          -D BUILD_opencv_features2d=OFF \
+          -D BUILD_opencv_flann=OFF \
+          -D BUILD_opencv_gpu=OFF \
+          -D BUILD_opencv_gpuarithm=OFF \
+          -D BUILD_opencv_gpubgsegm=OFF \
+          -D BUILD_opencv_gpucodec=OFF \
+          -D BUILD_opencv_gpufeatures2d=OFF \
+          -D BUILD_opencv_gpufilters=OFF \
+          -D BUILD_opencv_gpuimgproc=OFF \
+          -D BUILD_opencv_gpulegacy=OFF \
+          -D BUILD_opencv_gpuoptflow=OFF \
+          -D BUILD_opencv_gpustereo=OFF \
+          -D BUILD_opencv_gpuwarping=OFF \
+          -D BUILD_opencv_highgui=OFF \
+          -D BUILD_opencv_java=OFF \
+          -D BUILD_opencv_js=OFF \
+          -D BUILD_opencv_ml=OFF \
+          -D BUILD_opencv_ml=OFF \
+          -D BUILD_opencv_nonfree=OFF \
+          -D BUILD_opencv_objdetect=OFF \
+          -D BUILD_opencv_photo=OFF \
+          -D BUILD_opencv_python=OFF \
+          -D BUILD_opencv_python2=OFF \
+          -D BUILD_opencv_python3=OFF \
+          -D BUILD_opencv_superres=OFF \
+          -D BUILD_opencv_video=OFF \
+          -D BUILD_opencv_videoio=OFF \
+          -D BUILD_opencv_videostab=OFF \
+          -D BUILD_opencv_viz=OFF \
+          -D BUILD_opencv_world=OFF \
+          $OPENCV_LAPACK_OPTIONS \
+          -D OPENCV_LIB_INSTALL_PATH=lib \
+          -D OPENCV_INCLUDE_INSTALL_PATH=include \
+          -D CMAKE_LIBRARY_PATH=$DEPS_PATH/lib \
+          -D CMAKE_INCLUDE_PATH=$DEPS_PATH/include \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH ..
+    if [[ $PLATFORM == 'linux' ]]; then
+        cp $DEPS_PATH/../patch/opencv_lapack.h ./
+    fi
+    make
+    make install
+    cd -
+    # @szha: compatibility header
+    cat $DEPS_PATH/include/opencv2/imgcodecs/imgcodecs_c.h >> $DEPS_PATH/include/opencv2/imgcodecs.hpp
+fi
diff --git a/tools/dependencies/openssl.sh b/tools/dependencies/openssl.sh
new file mode 100755
index 0000000..b7e4317
--- /dev/null
+++ b/tools/dependencies/openssl.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of openssl that can be used as dependency of mxnet.
+OPENSSL_VERSION=1.0.2l
+if [[ ! -f $DEPS_PATH/lib/libssl.a ]] || [[ ! -f $DEPS_PATH/lib/libcrypto.a ]]; then
+    # download and build openssl
+    >&2 echo "Building openssl..."
+    OPENSSL_VERSION=$(echo $OPENSSL_VERSION | sed 's/\./_/g')
+    curl -s -L https://github.com/openssl/openssl/archive/OpenSSL_$OPENSSL_VERSION.zip -o $DEPS_PATH/openssl.zip
+    unzip -q $DEPS_PATH/openssl.zip -d $DEPS_PATH
+    cd $DEPS_PATH/openssl-OpenSSL_$OPENSSL_VERSION
+    if [[ $PLATFORM == 'linux' ]]; then
+        TARGET=linux-x86_64
+    elif [[ $PLATFORM == 'darwin' ]]; then
+        TARGET=darwin64-x86_64-cc
+    fi
+    ./Configure no-shared no-zlib --prefix=$DEPS_PATH --openssldir=$DEPS_PATH/ssl $TARGET
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/protobuf.sh b/tools/dependencies/protobuf.sh
new file mode 100755
index 0000000..dfa3d71
--- /dev/null
+++ b/tools/dependencies/protobuf.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of protobuf along with protoc, that can be used as dependency of mxnet.
+PROTOBUF_VERSION=3.5.1
+if [[ $PLATFORM == 'darwin' ]]; then
+    DY_EXT="dylib"
+else
+    DY_EXT="so"
+fi
+
+LIBPROTOBUF="$DEPS_PATH/lib/libprotobuf.$DY_EXT"
+LIBPROTOC="$DEPS_PATH/lib/libprotoc.$DY_EXT"
+if [[ ! -e $LIBPROTOBUF ]] || [[ ! -e $LIBPROTOC ]]; then
+    # Download and build protobuf
+    >&2 echo "Building protobuf..."
+    curl -s -L https://github.com/google/protobuf/archive/v$PROTOBUF_VERSION.zip -o $DEPS_PATH/protobuf.zip
+    unzip -q $DEPS_PATH/protobuf.zip -d $DEPS_PATH
+    cd $DEPS_PATH/protobuf-$PROTOBUF_VERSION
+    ./autogen.sh
+    ./configure -prefix=$DEPS_PATH
+    make
+    make install
+    cd -
+fi
diff --git a/tools/dependencies/zmq.sh b/tools/dependencies/zmq.sh
new file mode 100755
index 0000000..55e1779
--- /dev/null
+++ b/tools/dependencies/zmq.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This script builds the static library of zeroMQ that can be used as dependency of mxnet.
+ZEROMQ_VERSION=4.2.2
+if [[ ! -f $DEPS_PATH/lib/libzmq.a ]]; then
+    # Download and build zmq
+    >&2 echo "Building zmq..."
+    curl -s -L https://github.com/zeromq/libzmq/archive/v$ZEROMQ_VERSION.zip -o $DEPS_PATH/zeromq.zip
+    unzip -q $DEPS_PATH/zeromq.zip -d $DEPS_PATH
+    mkdir -p $DEPS_PATH/libzmq-$ZEROMQ_VERSION/build
+    cd $DEPS_PATH/libzmq-$ZEROMQ_VERSION/build
+    cmake \
+          -D CMAKE_BUILD_TYPE=RELEASE \
+          -D CMAKE_INSTALL_PREFIX=$DEPS_PATH \
+          -D WITH_LIBSODIUM=OFF \
+          -D BUILD_SHARED_LIBS=OFF ..
+    make
+    make install
+    cp $DEPS_PATH/lib/x86_64-linux-gnu/libzmq.a $DEPS_PATH/lib/libzmq.a
+    cd -
+fi