#!/bin/sh
cd ${0%/*} || exit 1    # Run from this directory

# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments

if ! onWin; then

wmakeLnInclude interfacialModels
wmake $targetType twoPhaseSystem
wmake $targetType interfacialModels
wmake $targetType phaseCompressibleTurbulenceModels
wmake $targetType

else

    wmakeLnInclude interfacialModels

    set +x

    echo "Library stub stack is currently being built at twoPhaseEulerFoam..."

    # Going to ommit the first build loop, as it will give a few errors, but
    # it's the second loop that matters.
    (

      for libitem in $(grep -h "LIB =" */Make/files | sed 's=.*/=='); do
        if [ ! -e "$FOAM_LIBBIN/${libitem}.a" ]; then
          cp $FOAM_LIBBIN/libstubLibrary.a $FOAM_LIBBIN/${libitem}.a
        fi
        if [ -e "$FOAM_LIBBIN/${libitem}.dll" ]; then
          rm $FOAM_LIBBIN/${libitem}.dll
        fi
      done

      export WM_CONTINUE_ON_ERROR=1
      set +e

      wmake libso twoPhaseSystem
      wmake libso interfacialModels
      wmake libso phaseCompressibleTurbulenceModels

      exit 0

    ) > /dev/null 2>&1

    echo "Library stub stack is done being built at twoPhaseEulerFoam."

    # Now going to do the second and final pass.
    set -x

    wmake libso twoPhaseSystem
    wmake libso interfacialModels
    wmake libso phaseCompressibleTurbulenceModels

    wmake

fi

#------------------------------------------------------------------------------
