From bed35a1d331746ac29514e968bcebfc720e1a438 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 12 Sep 2015 20:20:40 +0200 Subject: [PATCH] LP-30 osg : added proper win dependencies build script --- ...sgearth_dependencies_win.sh => osg_win.sh} | 108 +++++++++++++++--- 1 file changed, 93 insertions(+), 15 deletions(-) rename make/3rdparty/osgearth/{osgearth_dependencies_win.sh => osg_win.sh} (71%) diff --git a/make/3rdparty/osgearth/osgearth_dependencies_win.sh b/make/3rdparty/osgearth/osg_win.sh similarity index 71% rename from make/3rdparty/osgearth/osgearth_dependencies_win.sh rename to make/3rdparty/osgearth/osg_win.sh index b5f76643a..ed428b692 100644 --- a/make/3rdparty/osgearth/osgearth_dependencies_win.sh +++ b/make/3rdparty/osgearth/osg_win.sh @@ -1,29 +1,103 @@ -################################################################################ -#!/bin/bash +#!/bin/sh -e ################################################################################ # -# This script compiles GDAL and other dependencies needed by OSG and OSGEarth +# 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 ################################################################################ -WORKING_DIR=$PWD +BASE_DIR=$(dirname $0) -# TODO this should not be hardwired -ROOT_DIR=/d/Projects/LibrePilot +WORK_DIR=$BASE_DIR +ROOT_DIR=$BASE_DIR/../../.. -DOWNLOAD_DIR=$ROOT_DIR/downloads/osgearth -SOURCE_DIR=$ROOT_DIR/3rdparty/osgearth_dependencies -BUILD_DIR=$ROOT_DIR/build/3rdparty/osgearth_dependencies +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 @@ -39,10 +113,15 @@ BUILD_GEOS=1 BUILD_GDAL=1 # TODO -# libcurl needs to be built with ssl support +# 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/ @@ -53,7 +132,7 @@ export CPATH=$BUILD_DIR/include export LIBRARY_PATH=$BUILD_DIR/lib export PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig -# reduce binary sizes by removing the -g option (not picked up by all libraries) +# compiler flags export CFLAGS=-O2 export CXXFLAGS=-O2 @@ -138,8 +217,8 @@ echo "Building libpng..." echo "****************************************" cd $SOURCE_DIR -tar xzf $DOWNLOAD_DIR/libpng-1.6.14.tar.gz -C . -cd libpng-1.6.14 +tar xzf $DOWNLOAD_DIR/libpng-1.6.16.tar.gz -C . +cd libpng-1.6.16 ./configure --prefix=$BUILD_DIR --build=$HOST make @@ -294,7 +373,7 @@ 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 < $WORKING_DIR/gdal_GNUmakefile_fix.patch +patch < $WORK_DIR/gdal_GNUmakefile_fix.patch ./configure --prefix=$BUILD_DIR --build=$HOST \ --without-python --without-libtool \ @@ -307,4 +386,3 @@ make install fi -################################################################################