##
##  mldonkey.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:         mldonkey
Summary:      Multi-Platform Multi-Networks Peer-to-Peer (P2P) Client/Server
URL:          http://mldonkey.sourceforge.net/
Vendor:       The MLdonkey Team
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        P2P
License:      MLdonkey/GPL
Version:      3.0.4
Release:      20100816

#   list of sources
Source0:      http://download.sourceforge.net/mldonkey/mldonkey-%{version}.tar.bz2
Source1:      mldonkey.sh
Source2:      mldonkeyrc

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  ocaml, gd, png, jpeg
PreReq:       ocaml, gd, png, jpeg

%description
    MLdonkey is a multi-platform multi-networks Peer-to-Peer (P2P)
    client. Originally, it was the first open-source client to access
    the eDonkey network. Currently, it supports several large networks,
    such as eDonkey, Overnet, Bittorrent, Gnutella, Gnutella2,
    Fasttrack, Soulseek, Direct-Connect, and OpenNap. Networks can be
    enabled/disabled, searches are performed in parallel on all enabled
    networks.

%track
    prog mldonkey = {
        version   = %{version}
        url       = http://sourceforge.net/projects/mldonkey/files/
        regex     = mldonkey-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q

%build
    #   configure program
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    CPPFLAGS="%{l_cppflags}" \
    LDFLAGS="%{l_ldflags}" \
    OCAMLC="%{l_prefix}/bin/ocamlc" \
    GTK_CONFIG="no" \
    WGET="no" \
    ./configure \
        --prefix=%{l_prefix} \
        --enable-batch \
        --enable-multinet \
        --enable-ocamlver=3 \
        --disable-gui

    #   build main program and addons
    %{l_make} %{l_mflags}
    %{l_make} %{l_mflags} utils

%install
    #   install main program and addons
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin
    %{l_shtool} install -c -s -m 755 \
        mlnet mld_hash get_range make_torrent subconv \
        $RPM_BUILD_ROOT%{l_prefix}/bin/

    #   install user wrapper script and configuration
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/mldonkey
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE mldonkey.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/mldonkey
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE mldonkeyrc} $RPM_BUILD_ROOT%{l_prefix}/etc/mldonkey/

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

%files -f files

%clean

