mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
389 lines
10 KiB
Bash
389 lines
10 KiB
Bash
#!/bin/sh -e
|
|
################################################################################
|
|
#
|
|
# This script compiles OSG and OSGEarth dependencies (GDAL, GEOS, ...)
|
|
#
|
|
# Known to work with MSYS 1.0.11
|
|
# A zip file is provided here http://librepilot.github.io/tools/MSYS-1.0.11.zip
|
|
# This zip is based on the official http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe
|
|
# It was generated by installing MSYS-1.0.11.exe and adding to it:
|
|
# - http://gnuwin32.sourceforge.net/packages/wget.htm
|
|
# - http://gnuwin32.sourceforge.net/packages/libintl.htm
|
|
# - http://gnuwin32.sourceforge.net/packages/libiconv.htm
|
|
# And finally zipping the resulting directory (minus Readme.txt)
|
|
#
|
|
# A good source for building with mingw :
|
|
# http://www.gaia-gis.it/gaia-sins/mingw_how_to.html
|
|
#
|
|
# Sample command line to execute this script from a MS shell :
|
|
# .\tools\msys\bin\sh --login -i -c /d/Projects/LibrePilot/make/3rdparty/osgearth/osg_win.sh
|
|
#
|
|
# Executing this script from git bash does not seem to work.
|
|
#
|
|
################################################################################
|
|
|
|
# turn -x on if DEBUG is set to a non-empty string
|
|
[ -n "$DEBUG" ] && set -x
|
|
|
|
################################################################################
|
|
# MinGW
|
|
################################################################################
|
|
|
|
#MINGW_DIR=D:/Projects/LibrePilotTools/qt-5.4.1/Tools/mingw491_32
|
|
if [ -z "$MINGW_DIR" ]; then
|
|
echo MINGW_DIR not defined. Exiting...
|
|
exit 1
|
|
fi
|
|
|
|
umount /mingw || true
|
|
mount $MINGW_DIR /mingw
|
|
|
|
################################################################################
|
|
# Environment
|
|
################################################################################
|
|
|
|
BASE_DIR=$(dirname $0)
|
|
|
|
WORK_DIR=$BASE_DIR
|
|
ROOT_DIR=$BASE_DIR/../../..
|
|
|
|
DOWNLOAD_DIR=$ROOT_DIR/downloads/osg
|
|
SOURCE_DIR=$ROOT_DIR/3rdparty/osg_dependencies
|
|
BUILD_DIR=$ROOT_DIR/build/3rdparty/osg_dependencies
|
|
|
|
HOST=mingw32
|
|
|
|
DOWNLOAD_FILES=1
|
|
|
|
echo Root dir : $ROOT_DIR
|
|
echo Work dir : $WORK_DIR
|
|
echo Build dir : $BUILD_DIR
|
|
echo MinGW dir : $MINGW_DIR
|
|
|
|
################################################################################
|
|
# download sources
|
|
################################################################################
|
|
|
|
if [ "$DOWNLOAD_FILES" -eq 1 ]; then
|
|
|
|
SRC_FILES="
|
|
http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
|
|
http://zlib.net/zlib-1.2.8.tar.gz
|
|
http://www.ijg.org/files/jpegsrc.v9a.tar.gz
|
|
http://sourceforge.net/projects/libpng/files/libpng16/older-releases/1.6.16/libpng-1.6.16.tar.gz
|
|
ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.3.tar.gz
|
|
http://sourceforge.net/projects/freetype/files/freetype2/2.5.3/freetype-2.5.3.tar.gz
|
|
http://curl.haxx.se/download/curl-7.38.0.tar.gz
|
|
http://download.osgeo.org/proj/proj-4.8.0.tar.gz
|
|
http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz
|
|
http://download.osgeo.org/geos/geos-3.3.8.tar.bz2
|
|
http://download.osgeo.org/gdal/1.10.1/gdal-1.10.1.tar.gz
|
|
"
|
|
|
|
mkdir -p $DOWNLOAD_DIR/
|
|
for f in $SRC_FILES
|
|
do
|
|
filename=$(basename "$f")
|
|
if [ ! -f $DOWNLOAD_DIR/$filename ]; then
|
|
echo "****************************************"
|
|
echo "Downloading $filename"
|
|
echo "****************************************"
|
|
wget -P $DOWNLOAD_DIR/ $f
|
|
fi
|
|
done
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# build all
|
|
################################################################################
|
|
|
|
# list of libraries to build
|
|
# other candidates include bzip2, libxml2, gif, geotiff, ssl, gl...
|
|
BUILD_PKGCONFIG=1
|
|
BUILD_ZLIB=1
|
|
BUILD_LIBJPEG=1
|
|
BUILD_LIBPNG=1
|
|
BUILD_LIBTIFF=1
|
|
BUILD_FREETYPE=1
|
|
BUILD_OPENSSL=2
|
|
BUILD_CURL=1
|
|
BUILD_PROJ4=1
|
|
BUILD_GEOS=1
|
|
BUILD_GDAL=1
|
|
|
|
# TODO
|
|
# libcurl needs to be built with and ssl support
|
|
# gdal does not seem to link with shared proj4
|
|
|
|
# Clean src and build dirs
|
|
rm -rf $SOURCE_DIR/*
|
|
rm -rf $BUILD_DIR/*
|
|
|
|
mkdir -p $SOURCE_DIR/
|
|
mkdir -p $BUILD_DIR/
|
|
mkdir -p $BUILD_DIR/bin/
|
|
mkdir -p $BUILD_DIR/include/
|
|
mkdir -p $BUILD_DIR/lib/
|
|
|
|
# make sure all libraries see each others
|
|
export PATH=$BUILD_DIR/bin:$PATH
|
|
export CPATH=$BUILD_DIR/include
|
|
export LIBRARY_PATH=$BUILD_DIR/lib
|
|
export PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig
|
|
|
|
# compiler flags
|
|
export CFLAGS=-O2
|
|
export CXXFLAGS=-O2
|
|
|
|
################################################################################
|
|
# pkg-config
|
|
# required by libcurl, gdal, osg, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_PKGCONFIG" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building pkg-config..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/pkg-config-0.28.tar.gz -C .
|
|
cd pkg-config-0.28
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST \
|
|
--with-internal-glib
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# ZLIB
|
|
# required by libcurl, gdal, osg, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_ZLIB" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building zlib..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/zlib-1.2.8.tar.gz -C .
|
|
cd zlib-1.2.8
|
|
|
|
make -f win32/Makefile.gcc clean
|
|
make -f win32/Makefile.gcc
|
|
|
|
cp -f zlib1.dll $BUILD_DIR/bin/
|
|
cp -f zconf.h $BUILD_DIR/include/
|
|
cp -f zlib.h $BUILD_DIR/include/
|
|
cp -f libz.a $BUILD_DIR/lib/
|
|
cp -f libz.dll.a $BUILD_DIR/lib/
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# LIBJPEG
|
|
# required by gdal, osg, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_LIBJPEG" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building libjpeg..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/jpegsrc.v9a.tar.gz -C .
|
|
cd jpeg-9a
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST
|
|
make
|
|
make install-strip
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# LIBPNG
|
|
# required by gdal, osg, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_LIBPNG" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building libpng..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/libpng-1.6.16.tar.gz -C .
|
|
cd libpng-1.6.16
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST
|
|
make
|
|
make install-strip
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# LIBTIFF
|
|
# reqires zlib
|
|
# required by gdal, osg, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_LIBTIFF" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building libtiff..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/tiff-4.0.3.tar.gz -C .
|
|
cd tiff-4.0.3
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST
|
|
make
|
|
make install-strip
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# FreeType
|
|
################################################################################
|
|
|
|
if [ "$BUILD_FREETYPE" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building FreeType..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/freetype-2.5.3.tar.gz -C .
|
|
cd freetype-2.5.3
|
|
|
|
./configure --prefix=$BUILD_DIR
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# OpenSSL
|
|
################################################################################
|
|
|
|
if [ "$BUILD_OPENSSL" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building OpenSSL..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/curl-7.38.0.tar.gz -C .
|
|
cd curl-7.38.0
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# cURL
|
|
# required by gdal, osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_CURL" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building cURL..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/curl-7.38.0.tar.gz -C .
|
|
cd curl-7.38.0
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST \
|
|
--enable-shared=yes --with-zlib=$BUILD_DIR
|
|
make
|
|
make install-strip
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# PROJ.4
|
|
# required by osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_PROJ4" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building PROJ.4..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar -xzf $DOWNLOAD_DIR/proj-4.8.0.tar.gz -C .
|
|
tar -xzf $DOWNLOAD_DIR/proj-datumgrid-1.5.tar.gz -C proj-4.8.0/nad/
|
|
cd proj-4.8.0
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST \
|
|
--enable-static=no --enable-shared=yes
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# GEOS
|
|
# required by gdal
|
|
################################################################################
|
|
|
|
if [ "$BUILD_GEOS" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building GEOS..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xjf $DOWNLOAD_DIR/geos-3.3.8.tar.bz2 -C .
|
|
cd geos-3.3.8
|
|
|
|
# TODO why --disable-inline?
|
|
./configure --prefix=$BUILD_DIR --build=$HOST \
|
|
--enable-static=no --enable-shared=yes --disable-inline
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|
|
################################################################################
|
|
# GDAL
|
|
# requires zlib, libcurl, libpng, libjpeg, libtiff, geos
|
|
# required by osgearth
|
|
################################################################################
|
|
|
|
if [ "$BUILD_GDAL" -eq 1 ]; then
|
|
|
|
echo "****************************************"
|
|
echo "Building GDAL..."
|
|
echo "****************************************"
|
|
|
|
cd $SOURCE_DIR
|
|
tar xzf $DOWNLOAD_DIR/gdal-1.10.1.tar.gz -C .
|
|
cd gdal-1.10.1
|
|
|
|
# fix GNUmakefile as described here http://trac.osgeo.org/gdal/wiki/BuildingWithMinGW
|
|
patch < $WORK_DIR/gdal_GNUmakefile_fix.patch
|
|
|
|
./configure --prefix=$BUILD_DIR --build=$HOST \
|
|
--without-python --without-libtool \
|
|
--with-xerces=no \
|
|
--with-libz=$BUILD_DIR --with-curl=$BUILD_DIR \
|
|
--with-png=$BUILD_DIR --with-jpeg=$BUILD_DIR --with-libtiff=$BUILD_DIR \
|
|
--with-geos=$BUILD_DIR/bin/geos-config
|
|
make
|
|
make install
|
|
|
|
fi
|
|
|