##
##  perl-curses.spec -- OpenPKG RPM Specification
##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
##
##  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.
##

#   versions of individual parts
%define       V_curses          1.06
%define       V_curses_ui       0.71
%define       V_curses_ui_dtv   0.10
%define       V_curses_widgets  1.997
%define       V_curses_forms    1.997
%define       V_cdk_perl        20020728

#   package information
Name:         perl-curses
Summary:      Perl Modules for use with Curses
URL:          http://www.cpan.org/
Vendor:       Perl Community
Packager:     The OpenPKG Project
Distribution: OpenPKG [BASE]
Group:        Language
License:      GPL/Artistic
Version:      20021125
Release:      20021125

#   list of sources
Source0:      http://www.cpan.org/modules/by-module/Curses/Curses-%{V_curses}.tar.gz
Source1:      http://www.cpan.org/modules/by-module/Curses/Curses-UI-%{V_curses_ui}.tar.gz
Source2:      http://www.cpan.org/modules/by-module/Curses/Curses-UI-DelimitedTextViewer-%{V_curses_ui_dtv}.tar.gz
Source3:      http://www.cpan.org/modules/by-module/Curses/CursesWidgets-%{V_curses_widgets}.tar.gz
Source4:      http://www.cpan.org/modules/by-module/Curses/CursesForms-%{V_curses_forms}.tar.gz
Source5:      ftp://invisible-island.net/cdk/cdk-perl-%{V_cdk_perl}.tgz
Patch0:       perl-curses.patch

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20020206, perl >= 5.8.0, ncurses, cdk, perl-term
PreReq:       OpenPKG, openpkg >= 20020206, perl >= 5.8.0, ncurses, cdk, perl-term
AutoReq:      no
AutoReqProv:  no

%description
    Various modules for using the Curses library from within the Perl
    language plus additional widgets:
    - Curses (%{V_curses})
    - Curses::UI (%{V_curses_ui})
    - Curses::UI::DelimitedTextViewer (%{V_curses_ui_dtv})
    - Curses::Widgets (%{V_curses_widgets})
    - Curses::Forms (%{V_curses_forms})
    - Cdk (%{V_cdk_perl})

%prep
    %setup0 -q -c
    %setup1 -q -T -D -a 1
    %setup2 -q -T -D -a 2
    %setup3 -q -T -D -a 3
    %setup4 -q -T -D -a 4
    %setup5 -q -T -D -a 5
    (cd Curses-UI-%{V_curses_ui} && %{l_patch} -p0 <%{SOURCE perl-curses.patch})

%build

%install
    #   perform common prolog operations
    %{l_prefix}/bin/perl-openpkg prolog

    #   build Curses
    ( cd Curses-%{V_curses}
      hint="unknown"
      case "%{l_target}" in
          *-freebsd* ) hint="freebsd.ncurses" ;;
          *-linux*   ) hint="linux.ncurses"   ;;
          *-solaris* ) hint="solaris"         ;;
      esac
      if [ -f hints/c-$hint.h ]; then
          cp hints/c-$hint.h c-config.h
      fi
      %{l_shtool} subst \
          -e 's:my $inc;:my $inc = "-I%{l_prefix}/include -I%{l_prefix}/include/ncurses";:' \
          -e 's:my $libs;:my $libs = "-L%{l_prefix}/lib -lpanel -lmenu -lform -lncurses";:' \
          Makefile.PL
      %{l_prefix}/bin/perl-openpkg install PANELS MENUS FORMS
    )

    #   build Curses::UI
    %{l_prefix}/bin/perl-openpkg install -d Curses-UI-%{V_curses_ui}

    #   build Curses::UI
    %{l_prefix}/bin/perl-openpkg install -d Curses-UI-DelimitedTextViewer-%{V_curses_ui_dtv}

    #   build Curses::Widgets
    %{l_prefix}/bin/perl-openpkg install -d CursesWidgets-%{V_curses_widgets}

    #   build Curses::Forms
    %{l_prefix}/bin/perl-openpkg install -d CursesForms-%{V_curses_forms}

    #   build Cdk
    ( cd cdk-perl-%{V_cdk_perl}
      %{l_shtool} subst \
          -e 's;-L/usr/local/lib;-L%{l_prefix}/lib;' \
          -e 's;-I/usr/include/ncurses;-I%{l_prefix}/include/ncurses;' \
          -e 's;-I/usr/local/include/cdk;-I%{l_prefix}/include/cdk;' \
          Makefile.PL
      %{l_prefix}/bin/perl-openpkg install
    )

    #   perform common epilog operations
    %{l_prefix}/bin/perl-openpkg epilog

%files -f files

%clean
    rm -rf $RPM_BUILD_ROOT

