#!/bin/bash
# Copyright (C) 2016 by ETH Zürich
# Software engineering by Intevation GmbH
#
# This file is Free Software under the GNU GPL (v>=2)
# and comes with ABSOLUTELY NO WARRANTY!
# See LICENSE.txt for details.

echo "; This file is autogenerated." > @CMAKE_CURRENT_BINARY_DIR@/filelist_in.nsh
echo "; This file is autogenerated." > @CMAKE_CURRENT_BINARY_DIR@/filelist_un.nsh

echo File \"@CMAKE_BINARY_DIR@/src/@PROJECT_NAME@.exe\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_in.nsh
echo Delete \"$INSTDIR\\@PROJECT_NAME@.exe\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_un.nsh
echo File \"@CMAKE_SOURCE_DIR@/src/replacements.ini\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_in.nsh
echo Delete \"$INSTDIR\\replacements.ini\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_un.nsh
echo File \"@CMAKE_SOURCE_DIR@/LICENSE.txt\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_in.nsh
echo Delete \"$INSTDIR\\LICENSE.txt\" >> @CMAKE_CURRENT_BINARY_DIR@/filelist_un.nsh

EST_SIZE=$(du -s @CMAKE_BINARY_DIR@/src/@PROJECT_NAME@.exe| cut -f 1)

makensis \
    -Dplugin_dir="@CMAKE_BINARY_DIR@" \
    -Dversion_number=@PROJECT_VERSION@ \
    -Dnumeric_version=@HG_REVISION_TAG@.0.0 \
    -Dsetupname="@CMAKE_BINARY_DIR@/@PRETTY_NAME@-@PROJECT_VERSION@.exe" \
    -Dproductname="@PRETTY_NAME@" \
    -Dpath_sep="/" \
    -Dinfo_url="https://wald.intevation.org/projects/clickerconvert/" \
    -Dsize=$EST_SIZE \
    -Dproductname_short="@PROJECT_NAME@" @CMAKE_SOURCE_DIR@/packaging/@PROJECT_NAME@.nsi
