#!/bin/sh

# Copyright (C) 2000-2019 The Xastir Group
# <http://gdal.org/>

# Compile gdal-1.3.2b2 under Linux Standard Base 3.0.  Install into
# /opt/lsb-tmp/ directory structure.

# NOTE:
# "Free Standards Group, FSG, Linux Standard Base, LSB, Free
# Standards Certified, LSB Certified and the Free Standards
# Certified logo are trademarks, service marks and certification
# marks, as appropriate, of Free Standards Group in the United
# States and in other countries."
#
# We are in no way representing that Xastir has been certified by
# the FSG.  To do so costs real money.  We do intend some Xastir
# binaries to install and run properly on LSB-3.0 compliant x86
# Linux systems though...
#


export PATH=${PATH}:/opt/lsb/bin
export LSBCC_WARN=1

# A colon-separated list of "extra" shared libraries to link with
# the application.  Each shared lib must be LSB-compliant and must
# be distributed along with the application.
#export LSBCC_SHAREDLIBS=

# Change "export *" to "const std::exception &e"
sed -i -e 's/exception\*/const std::exception \&e/g' frmts/ilwis/ilwisdataset.cpp

CC=lsbcc CXX=lsbc++ ./configure \
    --prefix=/opt/lsb-gdal \
    --exec_prefix=/opt/lsb-gdal \
    --oldincludedir=/opt/lsb/include \
    --disable-shared \
    --without-ld-shared \
    --enable-static \
    --with-static-proj4 \
    --with-threads \
    --without-pcraster \
    --without-pg \
    --without-python \
    --without-ngpyton \
    --without-netcdf \
    --without-png \
    --without-jpeg \
    --without-gif \
    --without-jasper \
    --without-perl \
    --without-libz

#    --without-libtiff \
#    --without-geotiff \
#    --without-libtool \
 
make clean

find . -type f -name Makefile -print | while read i
  do
    sed -i 's@/usr/include@/opt/lsb/include@g' $i
    sed -i 's@/usr/local/include@/opt/lsb/include@g' $i
    sed -i 's@/usr/X11R6/include@/opt/lsb/include@g' $i
    sed -i 's@/usr/lib@/opt/lsb/lib@g' $i
    sed -i 's@/usr/local/lib@/opt/lsb/lib@g' $i
    sed -i 's@/usr/X11R6/lib@/opt/lsb/lib@g' $i
    sed -i 's@/usr/X11/lib@/opt/lsb/lib@g' $i
  done

sed -i 's@/usr/lib@/opt/lsb/lib@g' libgdal.la
sed -i 's@/usr/local/lib@/opt/lsb/lib@g' libgdal.la

(make 2>&1) | tee make.log

#make -n install
#(sudo make install 2>&1) | tee install.log


