#!/bin/bash
# Script generated by dpconfigure on Dec  4 2020
#
#   Configure script for Linux, Mac OS X and Unix
#
# copyright (C) 2002-2019 Marc Wathelet. All rights reserved.
#
#  This script is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#

# Return absolute path
absolutePath()
{
  PATH=$1
  if [ "${PATH:0:1}" = "/" ]; then
    echo $PATH
  else
    ABS_PATH=$PWD
    while [ "${PATH:0:3}" = "../" ]; do
      ABS_PATH=${ABS_PATH%/[^/]*}
      PATH=${PATH:3}
    done
    echo $ABS_PATH/$PATH
  fi
}

# $1 is the path in the mingw form: /c/usr/... or "/c/usr/..."
function winPath()
{
  if [ "$PLATFORM" = "MINGW" ] &&
     [ "${1:0:1}" = "/" ] && [ "${1:2:1}" = "/" ]; then
    echo $1 | sed -r "s/^\"(.*)\"$/\1/" | sed -r "s/^\/([a-zA-Z])/\1:/" | sed "s/\//\\\\/g"
  else
    echo $1
  fi
}

#function cWinPath()
#{
#  winPath $1 | sed "s/\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/g"
#}

# Arguments: destination directory, file
# New file must be generated in TEMP_DIR
function replaceFile()
{
  if [ -e $1/$2 ] && diff $1/$2 $TEMP_DIR/$2 > /dev/null; then
    rm $TEMP_DIR/$2
  else
    mv $TEMP_DIR/$2 $1
  fi
}

cleanexit()
{
  rm -rf $TEMP_DIR
  if [ $# = 1 ]; then
    if [ $1 -ne 0 ]; then
      rm -f $BUILD_DIR/ArrayCore.pro
      rm -f $BUILD_DIR/Makefile*
      echo "Error while configuring ArrayCore. Check above messages."
      echo "If you want to contact support, send a copy of the whole output."
    fi
    exit $1
  else
    echo
    echo "Aborting..." 1>&2
    exit 2
  fi
}

function beginModificationSafe() {
  rm -rf $TEMP_DIR/*
  if [ -e $1 ]; then
    mkdir $TEMP_DIR/old
    mv $* $TEMP_DIR/old
  fi
}

function endModificationSafe() {
  BASE_DIR=$1
  shift
  if [ -d $TEMP_DIR/old ]; then
    mkdir $TEMP_DIR/new
    mv $* $TEMP_DIR/new
    if diff -r $TEMP_DIR/old $TEMP_DIR/new > /dev/null; then
      mv $TEMP_DIR/old/* $BASE_DIR
    else
      mv $TEMP_DIR/new/* $BASE_DIR
    fi
    rm -r $TEMP_DIR/old $TEMP_DIR/new
  fi
}

trap cleanexit INT QUIT
TEMP_DIR=$(mktemp -d /tmp/ArrayCore_configure_XXXXXXXXX)

###############################################################
# Guess platform
###############################################################
#Platform options
case "$(uname)" in
  Linux) PLATFORM=LINUX ;;
  SunOS) PLATFORM=SUNOS ;;
  Darwin) PLATFORM=MAC ;;
  MINGW*) PLATFORM=MINGW ;;
  *)
    echo "Unknown platform $(uname)" > /dev/stderr
    cleanexit 2
  ;;
esac

###############################################################
# Default options
###############################################################
# make sure that we are in the correct directory
cd $(dirname $0)

PREFIX="/usr/local/Geopsy.org"
BINDIR="$PREFIX/bin"
LIBDIR="$PREFIX/lib"
INCDIR="$PREFIX/include"
SHAREDIR="$PREFIX/share"
LIBTYPE=shared
EXTINCDIR=""
EXTLIBDIR=""
RPATHDIR="$LIBDIR"
DEFINES=""
LICENSE_ACCEPTED="no"
COMMANDLINE=""
SILENT_MARK=""
SKIP_QT_CHECK="no"
SKIP_QT_TRANSLATIONS="no"
SKIP_QMAKE="no"
PROFILING="no"
PCH="yes"
QT_BIN_PATH=""
NO_SCRIPT="no"
NO_SVG="no"
CFLAGS=""
DEBUG="no"
# BASE_SOURCE_DIR is the directory containing eventually several projects
# Note that explicit -sourcedir option is mandatory if BASE_SOURCE_DIR and SOURCE_DIR are different.
BASE_SOURCE_DIR=$(pwd)
# SOURCE_DIR is the directory of this project.
SOURCE_DIR=$BASE_SOURCE_DIR
# Same remarks for BASE_BUILD_DIR and BUILD_DIR
BASE_BUILD_DIR=$BASE_SOURCE_DIR
BUILD_DIR=$SOURCE_DIR
DEST_DIR=$SOURCE_DIR
###############################################################
# Collect user options
###############################################################
while [ "$1" ]; do
  case "$1" in
    "-prefix" | "--prefix")
      shift
      PREFIX="$(absolutePath $1)"
      BINDIR="$PREFIX/bin"
      LIBDIR="$PREFIX/lib"
      RPATHDIR="\"$LIBDIR\""
      INCDIR="$PREFIX/include"
      SHAREDIR="$PREFIX/share/Geopsy.org"
      COMMANDLINE="$COMMANDLINE -prefix \"$1\""
    ;;
    "-bindir" | "--bindir")
      shift
      BINDIR="$(absolutePath $1)"
      COMMANDLINE="$COMMANDLINE -bindir \"$1\""
    ;;
    "-libdir" | "--libdir")
      shift
      LIBDIR="$(absolutePath $1)"
      RPATHDIR="$RPATHDIR \"$LIBDIR\""
      COMMANDLINE="$COMMANDLINE -libdir \"$1\""
    ;;
    "-incdir" | "--incdir")
      shift
      INCDIR="$(absolutePath $1)"
      COMMANDLINE="$COMMANDLINE -incdir \"$1\""
    ;;
    "-sharedir" | "--sharedir")
      shift
      SHAREDIR="$(absolutePath $1)"
      COMMANDLINE="$COMMANDLINE -sharedir \"$1\""
    ;;
    "-sourcedir" | "--sourcedir")
      shift
      BASE_SOURCE_DIR="$(absolutePath $1)"
      COMMANDLINE="$COMMANDLINE -sourcedir \"$1\""
    ;;
    "-builddir" | "--builddir")
      shift
      BASE_BUILD_DIR="$(absolutePath $1)"
      if [ "$BUILD_DIR" = "$SOURCE_DIR" ]; then
        BUILD_DIR=$BASE_BUILD_DIR
      fi
      COMMANDLINE="$COMMANDLINE -builddir \"$1\""
    ;;
    "-buildsubdir" | "--buildsubdir")
      shift
      REGEXP_BUILD_SUBDIR=".*/$1$"
      if ! [[ "$BUILD_DIR" =~ $REGEXP_BUILD_SUBDIR ]]; then
        BUILD_DIR="$BASE_BUILD_DIR/$1"
      fi
      COMMANDLINE="$COMMANDLINE -buildsubdir \"$1\""
    ;;
    "-dest-prefix" | "--dest-prefix")
      shift
      DEST_DIR="$(absolutePath $1)"
      COMMANDLINE="$COMMANDLINE -dest-prefix \"$1\""
    ;;
    "-shared" | "--shared")
      LIBTYPE="shared"
      COMMANDLINE="$COMMANDLINE -shared"
    ;;
    "-static" | "--static")
      LIBTYPE="static"
      COMMANDLINE="$COMMANDLINE -static"
    ;;
    "-accept-license" | "--accept-license")
      LICENSE_ACCEPTED="yes"
      COMMANDLINE="$COMMANDLINE -accept-license"
    ;;
    -I*)
      if [ "$1" != "-I" ]; then
        ARG=${1:2}
      else
        shift
        ARG="$1"
      fi
      EXTINCDIR="$EXTINCDIR \"$(winPath $ARG)\""
      COMMANDLINE="$COMMANDLINE -I \"$ARG\""
    ;;
    -L*)
      if [ "$1" != "-L" ]; then
        ARG=${1:2}
      else
        shift
        ARG="$1"
      fi
      EXTLIBDIR="$EXTLIBDIR \"$(winPath $ARG)\""
      COMMANDLINE="$COMMANDLINE -L \"$ARG\""
    ;;
    "-rpath" | "--rpath")
      if [ "${2:0:1}" = "-" ]; then
        RPATHDIR=""
        COMMANDLINE="$COMMANDLINE -rpath"
      else
        shift
        RPATHDIR="$RPATHDIR \"$(absolutePath $1)\""
        COMMANDLINE="$COMMANDLINE -rpath \"$1\""
      fi
    ;;
    "-D")
      shift
      DEFINES="$DEFINES $1"
      COMMANDLINE="$COMMANDLINE -D \"$1\""
    ;;
    "-skip-qt-check" | "--skip-qt-check")
      SKIP_QT_CHECK="yes"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-skip-qt-translations" | "--skip-qt-translations")
      SKIP_QT_TRANSLATIONS="yes"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
     "-skip-qmake" | "--skip-qmake")
      SKIP_QMAKE="yes"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
   "-profile" | "--profile")
      PROFILING="yes"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-silent" | "--silent")
      SILENT_MARK="@"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-no-pch" | "--no-pch")
      PCH="no"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-debug" | "--debug")
      DEBUG="yes"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-win32" | "--win32" | "-win64" | "--win64")
      PLATFORM="MINGW"
      COMMANDLINE="$COMMANDLINE $1"
    ;;
    "-qt-bin-path" | "--qt-bin-path")
      shift
      QT_BIN_PATH="$1/"
      COMMANDLINE="$COMMANDLINE -qt-bin-path \"$1\""
    ;;
    "-no-svg" | "--no-svg")
      NO_SVG=yes
      DEFINES="$DEFINES NO_SVG"
      COMMANDLINE="$COMMANDLINE -no-svg"
    ;;
    "-cflags" | "--cflags")
      shift
      CFLAGS="$CFLAGS $1"
      COMMANDLINE="$COMMANDLINE -cflags \"$1\""
    ;;
    "-sse3" | "--sse3")
      CFLAGS="$CFLAGS -msse3"
      COMMANDLINE="$COMMANDLINE -msse3"
    ;;
    "-march" | "--march")
      shift
      CFLAGS="$CFLAGS -march=$1"
      COMMANDLINE="$COMMANDLINE -march \"$1\""
    ;;
    "-h" | "-help" | "--help")
      echo
      echo "Usage: configure [options]"
      echo
      echo "Options:"
      echo
      echo " -qt-bin-path <DIR>     Use Qt in DIR instead of qt in PATH"         
      echo " -accept-license        Skip interactive license acceptance"
      echo " -silent                Minimal output during \"make install\""
      echo " -no-pch                Do not use precompiled headers (slower compilation)"
      echo " -debug                 Include debugging symbols (less optimized)"
      echo
      echo "Paths:"
      echo
      echo " -prefix <DIR>          Base directory for installation. It must be before any -*dir"
      echo "                          (default /usr/local/Geopsy.org)"
      echo " -bindir <DIR>          Executables will be installed to DIR"
      echo "                          (default $BINDIR)"
      echo " -libdir <DIR>          Libraries will be installed to DIR"
      echo "                          (default $LIBDIR)"
      echo " -incdir <DIR>          Headers will be installed to DIR"
      echo "                          (default $INCDIR)"
      echo " -sharedir <DIR>        Shared files and translations will be installed"
      echo "                        to DIR (default $SHAREDIR)"
      echo " -sourcedir <DIR>       Source are in DIR (default $SOURCE_DIR)"
      echo " -builddir <DIR>        Building in DIR (default $BASE_BUILD_DIR)"
      echo " -buildsubdir <DIR>     Add subdir DIR to build directory"
      echo
      echo "Configuration:"
      echo
      echo " -shared                Create and use shared libraries"
      echo " -static                Create and use static libraries"
      echo
      echo " -D <MACRO>             Defines MACRO"
      echo
      echo " -dest-prefix <DIR>     Destination prefix for all binaries"
      echo "                          (default $DEST_DIR)"
      echo " -rpath <DIR>           Add DIR to library rutime search path"
      echo "                          (default $RPATHDIR, reset to null without DIR)"
      echo " -skip-qt-check         Do not check current Qt version"
      echo " -skip-qt-TRANSLATIONS  Do not use Qt translations"
      echo " -profile               Turn profiling on, add gcc option '-pg'"
      echo "                          (for development under Linux only)"
      echo " -win32                 Turn on cross compilation with i686-mingw32"
      echo "                          (under Linux only)"
      echo " -win64                 Turn on cross compilation with x86_64-mingw32"
      echo "                          (under Linux only)"
      echo " -no-svg                Do not compile support for Qt svg"
      echo " -cflags <FLAG>         Add FLAG to the list of compilation flags"
      echo " -sse3                  Compile with SSE3 support"
      echo " -march <ARCH>          Specify the name of the target architecture"
      echo "                        Use ARCH=native for auto detection of the CPU's architecture"
      echo "                        Useful link: https://wiki.gentoo.org/wiki/Safe_CFLAGS"
      echo "                        Your architecture is:"
      grep -m1 -A3 "vendor_id" /proc/cpuinfo | awk '{printf("                       ");print}'
      echo
      echo "Third party libraries:"
      echo
      echo " -I dir                 Add dir to the list of directories to be"
      echo "                        searched for headers"
      echo " -L dir                 Add dir to the list of directories to be"
      echo "                        searched for libraries"
      echo
      cleanexit 0
    ;;
    *)
      echo "Bad option $1, see './configure -h' for help" > /dev/stderr
      cleanexit 2
    ;;
  esac
  shift
done
# Fix DEST_DIR in case of separate BUILD_DIR
if [ "$BUILD_DIR" != "$SOURCE_DIR" ] && [ "$DEST_DIR" = "$SOURCE_DIR" ]; then
  DEST_DIR=$BASE_BUILD_DIR
fi
EXTLIBDIR="\"$(winPath $DEST_DIR/lib)\" $EXTLIBDIR"

###############################################################
# Show license if .pro file does not exist
###############################################################
echo "* License..."
if [ ! -e $BUILD_DIR/configure.cache ] && [ "$LICENSE_ACCEPTED" = "no" ]; then
  echo
  echo "ArrayCore package is licensed to you under the terms"
  echo "of the GNU General Public License (GPL) version 2."
  LICENSE_ACCEPT=""
  while [ "$LICENSE_ACCEPT" != "no" ] && [ "$LICENSE_ACCEPT" != "yes" ]; do
    echo
    echo "Type 'view' to view the GNU General Public License."
    echo "Type 'yes' to accept this license offer."
    echo "Type 'no' to decline this license offer."
    echo
    echo -n "Do you accept this license? "
    read LICENSE_ACCEPT
    if [ "$LICENSE_ACCEPT" = "view" ]; then
      echo "#######################################################"
      echo "Type SPACE BAR or RETURN to move down"
      echo "#######################################################"
      sleep 2
      more LICENSE.GPL
      echo "#######################################################"
    fi
  done
  if [ "$LICENSE_ACCEPT" = "no" ]; then
    echo "You are not allowed to use this package." > /dev/stderr
    cleanexit 2
  fi
fi

###############################################################
# Store configure options
###############################################################
# If configure called from ./configure.cache, do not overwrite
if [ "$SAVE_CONFIGURE_OPTIONS_IN_CACHE" != "no" ]; then
  (
  cat << END
export SAVE_CONFIGURE_OPTIONS_IN_CACHE="no"
cd $SOURCE_DIR
echo "$SHELL $0 ${COMMANDLINE//\"/\\\"}"
$SHELL $0 $COMMANDLINE
END
  ) > $BUILD_DIR/configure.cache
  chmod a+x $BUILD_DIR/configure.cache
fi

###############################################################
# Check that Qt is correctly installed
###############################################################
if [ "$SKIP_QT_CHECK" = "yes" ]; then
  QT_VERSION=$(${QT_BIN_PATH}qmake -v | awk '{if (NR==2) print $4}')
  QT_VERSION_NUM=$(echo $QT_VERSION | awk 'BEGIN{FS="."}{print $1*1000000+$2*1000+$3}')
else
  echo "* Check Qt..."

  if ! ${QT_BIN_PATH}qmake -v > /dev/null 2>&1; then
    (
    echo "*** ERROR *** : qmake command is not available."
    echo "                Either Qt is not correctly installed"
    echo "                or PATH does not point to Qt binaries."
    echo "                Check '-qt-bin-path' option."
    ) > /dev/stderr
    cleanexit 2
  fi
 
  QT_VERSION=$(${QT_BIN_PATH}qmake -v | awk '{if (NR==2) print $4}')
  QT_VERSION_NUM=$(echo $QT_VERSION | awk 'BEGIN{FS="."}{print $1*1000000+$2*1000+$3}')

  if [ $QT_VERSION_NUM -lt 5014000 ]; then
    (
    echo "*** ERROR *** : Your Qt version is $QT_VERSION."
    echo "                At least version 5.14.2 is recommended."
    echo "                If you want to skip this version check,"
    echo "                add option -skip-qt-check."
    ) > /dev/stderr
    cleanexit 2
  fi

  if [ "$SKIP_QT_TRANSLATIONS" = "no" ] && ! ${QT_BIN_PATH}lrelease -version > /dev/null 2>&1; then
    (
    echo "*** ERROR *** : lrelease command is not available."
    echo "                Either Qt is not correctly installed"
    echo "                or PATH does not point to Qt binaries."
    echo "                Check '-qt-bin-path' option."
    echo "                You can also use '-skip-qt-translations'."
    ) > /dev/stderr
    cleanexit 2
  fi

###############################################################
# Check that g++ is available
###############################################################

  echo "* Check compiler..."

  if ! g++ --version > /dev/null 2>&1; then
    (
    echo "*** ERROR *** : g++ is not available."
    ) > /dev/stderr
    cleanexit 2
  fi

###############################################################
# Check if Qt is compiled statically
###############################################################

  QT_SHARED="yes"
  rm -rf $TEMP_DIR/Qt_static
  mkdir $TEMP_DIR/Qt_static
  ORIG_DIR=$(pwd)
  cd $TEMP_DIR/Qt_static
  if [ "$PLATFORM" = "MINGW" ]; then
    (
    cat << END
#include <qglobal.h>
int main(int argc, int argv)
{
#ifdef QT_DLL
  return 2;
#else
  return 0;
#endif
}
END
    ) > main.cpp
  else
    (
    cat << END
#include <qglobal.h>
int main(int argc, int argv)
{
#ifdef QT_SHARED
  return 2;
#else
  return 0;
#endif
}
END
    ) > main.cpp
  fi
  if ${QT_BIN_PATH}qmake -project -o test.pro > /dev/null 2>&1 &&     ${QT_BIN_PATH}qmake "CONFIG-=app_bundle" "CONFIG-=debug" "CONFIG+=release" > /dev/null 2>&1 &&     make > /dev/null 2>&1 &&     test; then
    QT_SHARED="no"
    echo "Qt build statically"
  fi
  cd $ORIG_DIR
  rm -rf $TEMP_DIR/Qt_static
fi

###############################################################
# Dependency lib names
###############################################################
echo "* Dependency lib names [platform dependent]..."
case "$PLATFORM" in
  "LINUX")
    LIBS="-lQGpCoreTools -lQGpCoreMath -lGeopsyCore -lQGpCoreWave -lDinverCore -lDinverDCCore -lQGpCompatibility -llapack -lblas -lQGpCoreStat "
  ;;
  "SUNOS")
    LIBS="-lQGpCoreTools -lQGpCoreMath -lGeopsyCore -lQGpCoreWave -lDinverCore -lDinverDCCore -lQGpCompatibility -llapack -lblas -lQGpCoreStat "
  ;;
  "MINGW")
    LIBS="-lQGpCoreTools2 -lQGpCoreMath1 -lGeopsyCore4 -lQGpCoreWave2 -lDinverCore1 -lDinverDCCore2 -lQGpCompatibility1 -llapack -lblas -lQGpCoreStat1 "
  ;;
  "MAC")
    LIBS="-framework QGpCoreTools -framework QGpCoreMath -framework GeopsyCore -framework QGpCoreWave -framework DinverCore -framework DinverDCCore -framework QGpCompatibility -llapack -lblas -framework QGpCoreStat "
  ;;
esac

###############################################################
# Dependency lib includes
###############################################################
echo "* Dependency lib include paths..."
cd $BASE_SOURCE_DIR
for LLIB in -lQGpCoreTools -lQGpCoreMath -lGeopsyCore -lQGpCoreWave -lDinverCore -lDinverDCCore -lQGpCompatibility -llapack -lblas -lQGpCoreStat; do
  LIB_BASENAME=$(echo $LLIB | sed "s/^-l//g")
  LIB_PATH_FOUND="no"
  for LIB_PATH in $(find . -name "${LIB_BASENAME}" | sed "s/^\.\///"); do
    if [ -e ${LIB_PATH}/src/${LIB_BASENAME}.h ] && [ -e ${LIB_PATH}/configure ]; then
      if [ "$LIB_PATH_FOUND" = "yes" ]; then
        echo "    Found more than one include path for lib '${LIB_BASENAME}'"
        cleanexit 2
      fi
      cd $LIB_PATH
      echo "    $LIB_PATH"
      EXTINCDIR="$EXTINCDIR $(winPath $PWD/src)"
      if [ "$BUILD_DIR" != "$SOURCE_DIR" ]; then
        EXTINCDIR="$EXTINCDIR $(winPath $BASE_BUILD_DIR/$LIB_PATH/src)"
      fi
      if ls src/*.ui > /dev/null 2>&1; then
        if [ "$BUILD_DIR" = "$SOURCE_DIR" ]; then
          EXTINCDIR="$EXTINCDIR $(winPath $PWD/ui)"
        else
          EXTINCDIR="$EXTINCDIR $(winPath $BASE_BUILD_DIR/$LIB_PATH/ui)"
        fi
      fi
      LIB_PATH_FOUND="yes"
      cd $BASE_SOURCE_DIR
    fi
  done
done
cd $SOURCE_DIR


###############################################################
# Generate .pro file
###############################################################
echo "* Qt project..."
test -d ${BUILD_DIR} || mkdir -p ${BUILD_DIR}
(
echo "CONFIG -= debug_and_release"
if [ "$DEBUG" = "yes" ]; then
  echo "CONFIG += debug separate_debug_info"
else
  echo "CONFIG += release"
fi
echo "CONFIG +=no_lflags_merge"
echo "TARGET = ArrayCore"
echo "TEMPLATE = lib"
echo "VERSION = 4.0.4"
  echo "QT-=gui"
  echo "INCLUDEPATH+=$(winPath $SOURCE_DIR/src) src"
  echo "DEPENDPATH+=$(winPath $SOURCE_DIR/src) src"
if [ "$PCH" = "yes" ]; then
  echo "CONFIG += precompile_header"
  echo "PRECOMPILED_HEADER = $(winPath $SOURCE_DIR/src/stable.h)"
fi
if [ "$QT_SHARED" = "no" ]; then
  echo "QTPLUGIN += qjpeg qgif qmng"
fi
if [ "$PLATFORM" = "MAC" ] && [ -e $SOURCE_DIR/images/ArrayCore.icns ]; then
  echo "ICON= $SOURCE_DIR/images/ArrayCore.icns"
elif [ "$PLATFORM" = "MINGW" ] && [ -e $SOURCE_DIR/images/ArrayCore.rc ]; then
  echo "RC_FILE= $(winPath $SOURCE_DIR/images/ArrayCore.rc)"
fi 
if [ "$PLATFORM" = "MAC" ]; then
  echo "QMAKE_SONAME_PREFIX = @rpath"
  echo "QMAKE_MACOSX_DEPLOYMENT_TARGET=10.7"
  if [ "$LIBTYPE" = "shared"  ]; then
    echo "CONFIG += lib_bundle"
    echo "FRAMEWORK_HEADERS.version = Versions"
cat << END
FRAMEWORK_HEADERS.files += \\
           $(winPath $SOURCE_DIR/src/AbstractArrayResults.h) \\
           $(winPath $SOURCE_DIR/src/AbstractArrayTool.h) \\
           $(winPath $SOURCE_DIR/src/AbstractFKFunction.h) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKParameters.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteering.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteeringOneComponent.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTool.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKToolSet.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKWorker.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKDirectRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleighEllipticity.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/ArrayCoreDLLExport.h) \\
           $(winPath $SOURCE_DIR/src/ArrayCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/ArrayParameters.h) \\
           $(winPath $SOURCE_DIR/src/ArraySelection.h) \\
           $(winPath $SOURCE_DIR/src/ArrayStationSignals.h) \\
           $(winPath $SOURCE_DIR/src/ArrayStations.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTask.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTimeWindows.h) \\
           $(winPath $SOURCE_DIR/src/ArrayWorker.h) \\
           $(winPath $SOURCE_DIR/src/AsyncArrayProcess.h) \\
           $(winPath $SOURCE_DIR/src/AsyncFKLoop.h) \\
           $(winPath $SOURCE_DIR/src/AsyncFKTool.h) \\
           $(winPath $SOURCE_DIR/src/AsyncParameters.h) \\
           $(winPath $SOURCE_DIR/src/AsyncStationPair.h) \\
           $(winPath $SOURCE_DIR/src/BlockAveragingParameters.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKTransverse.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/CrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/FKCache.h) \\
           $(winPath $SOURCE_DIR/src/FKCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/FKGradientSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKGridSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKParameters.h) \\
           $(winPath $SOURCE_DIR/src/FKPeaks.h) \\
           $(winPath $SOURCE_DIR/src/FKPolarGradientSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKPower.h) \\
           $(winPath $SOURCE_DIR/src/FKResults.h) \\
           $(winPath $SOURCE_DIR/src/FKSteering.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringOneComponent.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentConvRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentTransverse.h) \\
           $(winPath $SOURCE_DIR/src/FKTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/FKTool.h) \\
           $(winPath $SOURCE_DIR/src/FKWorker.h) \\
           $(winPath $SOURCE_DIR/src/FrequencyBand.h) \\
           $(winPath $SOURCE_DIR/src/GaussianFrequencyBand.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectLove.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRefined.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighEllipticity.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKTransverse.h) \\
           $(winPath $SOURCE_DIR/src/HRFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/KmaxSolver.h) \\
           $(winPath $SOURCE_DIR/src/KminSolver.h) \\
           $(winPath $SOURCE_DIR/src/MuttiArrayFKLoop.h) \\
           $(winPath $SOURCE_DIR/src/OmniFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/OmniFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/PoggiFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/PoggiFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/RingPairs.h) \\
           $(winPath $SOURCE_DIR/src/SPACCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/SPACLoop.h) \\
           $(winPath $SOURCE_DIR/src/SPACParameters.h) \\
           $(winPath $SOURCE_DIR/src/SPACResults.h) \\
           $(winPath $SOURCE_DIR/src/SPACRing.h) \\
           $(winPath $SOURCE_DIR/src/SPACStatistics.h) \\
           $(winPath $SOURCE_DIR/src/SPACTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/SPACTool.h) \\
           $(winPath $SOURCE_DIR/src/SPACWorker.h) \\
           $(winPath $SOURCE_DIR/src/StationPair.h) \\
           $(winPath $SOURCE_DIR/src/StationPairs.h) \\
           $(winPath $SOURCE_DIR/src/WaveNumberConverter.h) \\
           $(winPath $SOURCE_DIR/src/Wavenumber.h) \\
           $(winPath $SOURCE_DIR/src/ArrayCore.h)
END
    echo "FRAMEWORK_HEADERS.path = Headers"
    echo "QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS"
  fi
fi
if [ "$PLATFORM" = "MINGW" ]; then
  if [ "$LIBTYPE" = "shared" ]; then
    echo "CONFIG+= dll"
  fi
fi
if [ -n "$CFLAGS" ]; then
  echo "QMAKE_CXXFLAGS_DEBUG += $CFLAGS"
  echo "QMAKE_CXXFLAGS_RELEASE += $CFLAGS"
fi
if [ "$LIBTYPE" = "static" ]; then
  echo "CONFIG += staticlib"
  echo "QMAKE_CXXFLAGS_DEBUG += -fPIC"
  echo "QMAKE_CXXFLAGS_RELEASE += -fPIC"
  echo "QMAKE_CFLAGS_DEBUG += -fPIC"
  echo "QMAKE_CFLAGS_RELEASE += -fPIC"
fi
if [ "$PROFILING" = "yes" ]; then
  echo "CONFIG(debug) {"
  echo "  QMAKE_CXXFLAGS_DEBUG += -pg"
  echo "  QMAKE_CFLAGS_DEBUG += -pg"
  echo "  QMAKE_LFLAGS_DEBUG += -pg"
  echo "} else {"
  echo "  QMAKE_CXXFLAGS_RELEASE += -pg"
  echo "  QMAKE_CFLAGS_RELEASE += -pg"
  echo "  QMAKE_LFLAGS_RELEASE += -pg"
  echo "}"
fi
echo "QMAKE_LFLAGS_DEBUG += -g"
if [ "$EXTINCDIR" ]; then
  echo "INCLUDEPATH += $EXTINCDIR"
  echo "DEPENDPATH += $EXTINCDIR"
fi
if [ "$EXTLIBDIR" ]; then
  for p in $(echo $EXTLIBDIR); do
    echo "LIBS += -L$p"
    if [ "$PLATFORM" = "MAC" ]; then
      echo "LIBS += -F$p"
    fi
  done
  for p in $(echo $RPATHDIR); do
    if [ "$PLATFORM" = "LINUX" ] || [ "$PLATFORM" = "MAC" ]; then
      echo "LIBS += -Wl,-rpath,$p"
    elif [ "$PLATFORM" = "SUNOS" ]; then
      echo "LIBS += -Wl,-R,$p"
    fi
  done
fi
if [ "$LIBS" ]; then
   echo "LIBS += $LIBS"
fi
if [ "$PLATFORM" = "MAC" ]; then
  echo "LIBS += -Wl,-undefined,dynamic_lookup"
  echo "QMAKE_SONAME_PREFIX = @rpath"
fi
if [ "$PLATFORM" = "MINGW" ]; then
  echo "QMAKE_LFLAGS_RELEASE = -Wl,-S"
fi
if [ "$DEFINES" ] || [ "" ]; then
  echo "DEFINES += $DEFINES "
fi
if [ "$LIBTYPE" = "shared" ]; then
  echo "DEFINES += MAKE_ARRAYCORE_DLL"
elif [ "$LIBTYPE" = "static" ]; then
  echo "DEFINES += ARRAYCORE_STATIC"
fi
echo "DESTDIR = $(winPath ${DEST_DIR}/lib)"
if [ "$PLATFORM" != "MAC" ]; then
  echo "LIBS+=-lgfortran"
fi
cat << END
SOURCES+= \\
           $(winPath $SOURCE_DIR/src/AbstractArrayResults.cpp) \\
           $(winPath $SOURCE_DIR/src/AbstractArrayTool.cpp) \\
           $(winPath $SOURCE_DIR/src/AbstractFKFunction.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteering.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteeringOneComponent.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTaskManager.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTool.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKToolSet.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveFKWorker.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKDirectRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleighEllipticity.cpp) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayCore.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayCrossSpectrum.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/ArraySelection.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayStationSignals.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayStations.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayTask.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayTaskManager.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayTimeWindows.cpp) \\
           $(winPath $SOURCE_DIR/src/ArrayWorker.cpp) \\
           $(winPath $SOURCE_DIR/src/AsyncArrayProcess.cpp) \\
           $(winPath $SOURCE_DIR/src/AsyncFKLoop.cpp) \\
           $(winPath $SOURCE_DIR/src/AsyncFKTool.cpp) \\
           $(winPath $SOURCE_DIR/src/AsyncParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/AsyncStationPair.cpp) \\
           $(winPath $SOURCE_DIR/src/BlockAveragingParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/ConvFKRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/ConvFKRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/ConvFKTransverse.cpp) \\
           $(winPath $SOURCE_DIR/src/ConvFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/CrossSpectrum.cpp) \\
           $(winPath $SOURCE_DIR/src/FKCache.cpp) \\
           $(winPath $SOURCE_DIR/src/FKCrossSpectrum.cpp) \\
           $(winPath $SOURCE_DIR/src/FKGradientSearch.cpp) \\
           $(winPath $SOURCE_DIR/src/FKGridSearch.cpp) \\
           $(winPath $SOURCE_DIR/src/FKParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/FKPeaks.cpp) \\
           $(winPath $SOURCE_DIR/src/FKPolarGradientSearch.cpp) \\
           $(winPath $SOURCE_DIR/src/FKPower.cpp) \\
           $(winPath $SOURCE_DIR/src/FKResults.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteering.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringOneComponent.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighFixedEll.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentConvRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighFixedEll.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentTransverse.cpp) \\
           $(winPath $SOURCE_DIR/src/FKTaskManager.cpp) \\
           $(winPath $SOURCE_DIR/src/FKTool.cpp) \\
           $(winPath $SOURCE_DIR/src/FKWorker.cpp) \\
           $(winPath $SOURCE_DIR/src/FrequencyBand.cpp) \\
           $(winPath $SOURCE_DIR/src/GaussianFrequencyBand.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectLove.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighFixedEll.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRefined.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighEllipticity.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighFixedEll.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKTransverse.cpp) \\
           $(winPath $SOURCE_DIR/src/HRFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/KmaxSolver.cpp) \\
           $(winPath $SOURCE_DIR/src/KminSolver.cpp) \\
           $(winPath $SOURCE_DIR/src/MuttiArrayFKLoop.cpp) \\
           $(winPath $SOURCE_DIR/src/OmniFKRayleigh.cpp) \\
           $(winPath $SOURCE_DIR/src/OmniFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/PoggiFKRadial.cpp) \\
           $(winPath $SOURCE_DIR/src/PoggiFKVertical.cpp) \\
           $(winPath $SOURCE_DIR/src/RingPairs.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACCrossSpectrum.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACLoop.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACParameters.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACResults.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACRing.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACStatistics.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACTaskManager.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACTool.cpp) \\
           $(winPath $SOURCE_DIR/src/SPACWorker.cpp) \\
           $(winPath $SOURCE_DIR/src/StationPair.cpp) \\
           $(winPath $SOURCE_DIR/src/StationPairs.cpp) \\
           $(winPath $SOURCE_DIR/src/WaveNumberConverter.cpp) \\
           $(winPath $SOURCE_DIR/src/Wavenumber.cpp)
!mac {
SOURCES+=
}
HEADERS+= \\
           $(winPath $SOURCE_DIR/src/AbstractArrayResults.h) \\
           $(winPath $SOURCE_DIR/src/AbstractArrayTool.h) \\
           $(winPath $SOURCE_DIR/src/AbstractFKFunction.h) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveConvFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKParameters.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteering.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKSteeringOneComponent.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKTool.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKToolSet.h) \\
           $(winPath $SOURCE_DIR/src/ActiveFKWorker.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKDirectRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKRayleighEllipticity.h) \\
           $(winPath $SOURCE_DIR/src/ActiveHRFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/ArrayCoreDLLExport.h) \\
           $(winPath $SOURCE_DIR/src/ArrayCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/ArrayParameters.h) \\
           $(winPath $SOURCE_DIR/src/ArraySelection.h) \\
           $(winPath $SOURCE_DIR/src/ArrayStationSignals.h) \\
           $(winPath $SOURCE_DIR/src/ArrayStations.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTask.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/ArrayTimeWindows.h) \\
           $(winPath $SOURCE_DIR/src/ArrayWorker.h) \\
           $(winPath $SOURCE_DIR/src/AsyncArrayProcess.h) \\
           $(winPath $SOURCE_DIR/src/AsyncFKLoop.h) \\
           $(winPath $SOURCE_DIR/src/AsyncFKTool.h) \\
           $(winPath $SOURCE_DIR/src/AsyncParameters.h) \\
           $(winPath $SOURCE_DIR/src/AsyncStationPair.h) \\
           $(winPath $SOURCE_DIR/src/BlockAveragingParameters.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKTransverse.h) \\
           $(winPath $SOURCE_DIR/src/ConvFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/CrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/FKCache.h) \\
           $(winPath $SOURCE_DIR/src/FKCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/FKGradientSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKGridSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKParameters.h) \\
           $(winPath $SOURCE_DIR/src/FKPeaks.h) \\
           $(winPath $SOURCE_DIR/src/FKPolarGradientSearch.h) \\
           $(winPath $SOURCE_DIR/src/FKPower.h) \\
           $(winPath $SOURCE_DIR/src/FKResults.h) \\
           $(winPath $SOURCE_DIR/src/FKSteering.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringOneComponent.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringThreeComponentRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentConvRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/FKSteeringTwoComponentTransverse.h) \\
           $(winPath $SOURCE_DIR/src/FKTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/FKTool.h) \\
           $(winPath $SOURCE_DIR/src/FKWorker.h) \\
           $(winPath $SOURCE_DIR/src/FrequencyBand.h) \\
           $(winPath $SOURCE_DIR/src/GaussianFrequencyBand.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectLove.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighRefined.h) \\
           $(winPath $SOURCE_DIR/src/HRFKDirectRayleighVertical.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighEllipticity.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighFixedEll.h) \\
           $(winPath $SOURCE_DIR/src/HRFKRayleighRadial.h) \\
           $(winPath $SOURCE_DIR/src/HRFKTransverse.h) \\
           $(winPath $SOURCE_DIR/src/HRFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/KmaxSolver.h) \\
           $(winPath $SOURCE_DIR/src/KminSolver.h) \\
           $(winPath $SOURCE_DIR/src/MuttiArrayFKLoop.h) \\
           $(winPath $SOURCE_DIR/src/OmniFKRayleigh.h) \\
           $(winPath $SOURCE_DIR/src/OmniFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/PoggiFKRadial.h) \\
           $(winPath $SOURCE_DIR/src/PoggiFKVertical.h) \\
           $(winPath $SOURCE_DIR/src/RingPairs.h) \\
           $(winPath $SOURCE_DIR/src/SPACCrossSpectrum.h) \\
           $(winPath $SOURCE_DIR/src/SPACLoop.h) \\
           $(winPath $SOURCE_DIR/src/SPACParameters.h) \\
           $(winPath $SOURCE_DIR/src/SPACResults.h) \\
           $(winPath $SOURCE_DIR/src/SPACRing.h) \\
           $(winPath $SOURCE_DIR/src/SPACStatistics.h) \\
           $(winPath $SOURCE_DIR/src/SPACTaskManager.h) \\
           $(winPath $SOURCE_DIR/src/SPACTool.h) \\
           $(winPath $SOURCE_DIR/src/SPACWorker.h) \\
           $(winPath $SOURCE_DIR/src/StationPair.h) \\
           $(winPath $SOURCE_DIR/src/StationPairs.h) \\
           $(winPath $SOURCE_DIR/src/WaveNumberConverter.h) \\
           $(winPath $SOURCE_DIR/src/Wavenumber.h)
FORMS+=
TRANSLATIONS+= \\
           $(winPath $SOURCE_DIR/lang/ArrayCore.fr.ts) \\
           $(winPath $SOURCE_DIR/lang/ArrayCore.de.ts) \\
           $(winPath $SOURCE_DIR/lang/ArrayCore.es.ts) \\
           $(winPath $SOURCE_DIR/lang/ArrayCore.it.ts)
END
echo "win32: dlltarget.path = $(winPath $BINDIR)"
echo "target.path = $(winPath $LIBDIR)"
echo "includes.files = \$\$HEADERS \$\$FORMS_HEADERS"
echo "includes.path = $INCDIR/ArrayCore"
echo "oneinclude.files = src/ArrayCore.h"
echo "oneinclude.path = $(winPath $INCDIR)"
echo "win32 {"
echo "  INSTALLS += dlltarget target includes oneinclude"
echo "} else {"
echo "  INSTALLS += target includes oneinclude"
echo "}"
if [ "$SKIP_QT_TRANSLATIONS" = "no" ]; then
  cat << END
lang.path = $(winPath $SHAREDIR/lang)
lang.files = lang/ArrayCore.fr.qm \\
             lang/ArrayCore.de.qm \\
             lang/ArrayCore.es.qm \\
             lang/ArrayCore.it.qm
INSTALLS += lang
END
fi
) > $TEMP_DIR/ArrayCore.pro
replaceFile $BUILD_DIR ArrayCore.pro

###############################################################
# Generate src/ArrayCoreInstallPath.h file
###############################################################
echo "* src/ArrayCoreInstallPath.h..."
test -d $BUILD_DIR/src || mkdir -p $BUILD_DIR/src
(
cat << END
#ifndef ARRAYCORE_INSTALL_PATHS
#define ARRAYCORE_INSTALL_PATHS
#define ARRAYCORE_BINDIR "$BINDIR"
#define ARRAYCORE_LIBDIR "$LIBDIR"
#define ARRAYCORE_INCDIR "$INCDIR"
#define ARRAYCORE_SHAREDIR "$SHAREDIR"
#endif // ARRAYCORE_INSTALL_PATHS
END
) > $TEMP_DIR/ArrayCoreInstallPath.h
replaceFile $BUILD_DIR/src ArrayCoreInstallPath.h

###############################################################
# Generate src/ArrayCoreStatic.h file
###############################################################
echo "* src/ArrayCoreStatic.h..."
(
if [ "$LIBTYPE" = "static" ]; then
  cat << END
#ifndef ARRAYCORE_STATIC
#define ARRAYCORE_STATIC
#endif
END
fi
) > $TEMP_DIR/ArrayCoreStatic.h
replaceFile $BUILD_DIR/src ArrayCoreStatic.h
###############################################################
# Generate .qrc file
###############################################################
###############################################################
# Generate binary lang files
###############################################################
cd ${BUILD_DIR}
if [ "$SKIP_QT_TRANSLATIONS" = "no" ]; then
  echo "* Qt translations..."
  test -d lang || mkdir -p lang
  beginModificationSafe lang/*.qm
  for f in $(ls $SOURCE_DIR/lang/*.ts); do
    QM_FILE=lang/$(basename $f ts)qm
    rm -f $QM_FILE
    ${QT_BIN_PATH}lrelease -silent $f -qm $QM_FILE
  done
  endModificationSafe lang lang/*.qm
fi
###############################################################
# Generate Makefile
###############################################################
if [ "$SKIP_QMAKE" = "no" ]; then
  echo "* Makefile..."
  if [ "$PLATFORM" = "MINGW" ]; then
    QMAKE_OPTIONS="-spec win32-g++"
  else
    QMAKE_OPTIONS=""
  fi
  beginModificationSafe Makefile*
  ${QT_BIN_PATH}qmake $QMAKE_OPTIONS ArrayCore.pro
  endModificationSafe . Makefile*
  cd ${SOURCE_DIR}
  ###############################################################
  # Final user message
  ###############################################################
  echo
  if [ "$PLATFORM" = "MINGW" ]; then
    CONFIGURE_COMMAND="sh configure"
  else
    CONFIGURE_COMMAND="./configure"
  fi
  echo "  ArrayCore is now configured for building."
  echo
  echo "  To proceed, run (if you have 8 cores)"
  echo
  if [ "${BUILD_DIR}" != "${SOURCE_DIR}" ]; then
    echo "    $ make -j 8 -C ${BUILD_DIR}"
  else
    echo "    $ make -j 8"
  fi
  echo
  echo "  Once everything is built, you must run either"
  echo
  echo "    $ su -c \"make install\", if root privileges are needed;"
  echo "  or"
  echo "    $ make install, if user permissions are sufficient."
  echo
  echo "  The current configuration options are stored in 'configure.cache'."
  echo "  To change the configuration, run '$CONFIGURE_COMMAND [options]'."
  echo
else
  echo "  To finish configuration, run qmake"
  echo
fi
cleanexit 0
