##
##  rolo.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 version
%define       V_rolo        011
%define       V_libvc       003
%define       V_muttvcquery 002

#   package information
Name:         rolo
Summary:      Contact Manager
URL:          http://rolo.sourceforge.net/
Vendor:       Andrew Hsu
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Terminal
License:      GPL
Version:      %{V_rolo}
Release:      20080101

#   list of sources
Source0:      http://download.sourceforge.net/rolo/rolo-%{V_rolo}.tar.gz
Source1:      http://download.sourceforge.net/rolo/libvc-%{V_libvc}.tar.gz
Source2:      http://download.sourceforge.net/rolo/mutt_vc_query-%{V_muttvcquery}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, flex, bison
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  ncurses
PreReq:       ncurses

%description
    Rolo keeps track of contacts and displays them with a text-based
    menu. Rolo strives to be a well-constructed tool for complimenting
    text-based email programs-such as mutt(1). It utilizes the vCard 3.0
    format for storing its contacts and it interfaces with the end-user
    through a full-screen front-end.

%track
    prog rolo = {
        version   = %{V_rolo}
        url       = http://sourceforge.net/projects/rolo/files/
        regex     = rolo-(__VER__)\.tar\.gz
    }
    prog rolo:libvc = {
        version   = %{V_libvc}
        url       = http://sourceforge.net/projects/rolo/files/
        regex     = libvc-(__VER__)\.tar\.gz
    }
    prog rolo:mutt_vc_query = {
        version   = %{V_muttvcquery}
        url       = http://sourceforge.net/projects/rolo/files/
        regex     = mutt_vc_query-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -D -T -a 1
    %setup -q -D -T -a 2

%build
    #   build vCard library
    ( cd libvc-%{V_libvc}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      ./configure \
          --prefix=%{l_prefix} \
          --disable-shared
      %{l_make} %{l_mflags -O}
    ) || exit $?

    #   build Rolo application
    ( cd rolo-%{V_rolo}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags} -I`pwd`/../libvc-%{V_libvc}/src" \
      LDFLAGS="%{l_ldflags} -L`pwd`/../libvc-%{V_libvc}/src/.libs" \
      ./configure \
          --prefix=%{l_prefix}
      %{l_make} %{l_mflags -O}
    ) || exit $?

    #   build mutt_vc_query utility
    ( cd mutt_vc_query-%{V_muttvcquery}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags} -I`pwd`/../libvc-%{V_libvc}/src" \
      LDFLAGS="%{l_ldflags} -L`pwd`/../libvc-%{V_libvc}/src/.libs" \
      ./configure \
          --prefix=%{l_prefix}
      %{l_make} %{l_mflags -O}
    ) || exit $?

%install

    #   build vCard library
    ( cd libvc-%{V_libvc}
      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    ) || exit $?

    #   install Rolo application
    ( cd rolo-%{V_rolo}
      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    ) || exit $?

    #   install mutt_vc_query utility
    ( cd mutt_vc_query-%{V_muttvcquery}
      %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    ) || exit $?

    #   strip down installation files
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

