##
##  nsis.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         nsis
Summary:      Nullsoft Scriptable Install System
URL:          http://nsis.sourceforge.net/
Vendor:       NullSoft
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        System
License:      GPL
Version:      2.46
Release:      20091207

#   list of sources
Source0:      http://download.sourceforge.net/nsis/nsis-%{version}-src.tar.bz2
Source1:      http://download.sourceforge.net/nsis/nsis-%{version}.zip
Patch0:       nsis.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, infozip, scons, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101

%description
    Nullsoft Scriptable Install System (NSIS) is a professional,
    script-driven Open-Source system to create Windows installers. It is
    designed to be as small and flexible as possible and is therefore
    very suitable for Internet distribution. This OpenPKG package
    contains the compiler and the native Win32 binary artifacts.

%track
    prog nsis = {
        version   = %{version}
        url       = http://sourceforge.net/projects/nsis/files/
        regex     = nsis-(\d+\.\d+)-src\.tar\.bz2
    }

%prep
    %setup -q -n nsis-%{version}-src
    unzip -q -x %{SOURCE1}
    %patch -p0

%build
    #   configure and build makensis(1)
    export OPENPKG_CCFLAGS="%{l_cxxflags -O} %{l_cppflags}"
    export OPENPKG_LINKFLAGS="%{l_ldflags} -liconv"
    scons \
        PREFIX=%{l_prefix}/share/nsis \
        PREFIX_CONF=%{l_prefix}/etc/nsis \
        PREFIX_DATA=%{l_prefix}/share/nsis \
        NSIS_CONFIG_CONST_DATA_PATH=yes \
        SKIPSTUBS=all \
        SKIPPLUGINS=all \
        SKIPUTILS=all \
        SKIPMISC=all \
        STRIP=no \
        makensis

%install
    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/etc/nsis \
        $RPM_BUILD_ROOT%{l_prefix}/share/nsis

    #   install default configuration file
    %{l_shtool} install -c -m 644 \
        nsisconf.nsh $RPM_BUILD_ROOT%{l_prefix}/etc/nsis/

    #   install the artifacts of the Win32 binary distribution
    mv  "nsis-%{version}/Contrib/Modern UI" \
        "nsis-%{version}/Contrib/Modern-UI"
    mv  "nsis-%{version}/Contrib/Modern UI 2" \
        "nsis-%{version}/Contrib/Modern-UI-2"
    mv  "nsis-%{version}/Contrib/Language files" \
        "nsis-%{version}/Contrib/Language-files"
    rm -rf nsis-%{version}/Examples
    rm -rf nsis-%{version}/Docs
    rm -f nsis-%{version}/nsisconf.nsh
    rm -f nsis-%{version}/makensis.exe
    rm -f nsis-%{version}/makensisw.exe
    rm -f nsis-%{version}/COPYING
    find nsis-%{version} -name "*.orig" -print | xargs rm -f
    cp -rp nsis-%{version}/* \
        $RPM_BUILD_ROOT%{l_prefix}/share/nsis/

    #   install the native-compiled compiler makensis(1)
    %{l_shtool} install -c -s -m 755 \
        build/release/makensis/makensis \
        $RPM_BUILD_ROOT%{l_prefix}/bin/

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/nsis/*'

%files -f files

%clean

