##
##  icon-theme.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_hicolor_icon_theme     0.13
%define       V_icon_naming_utils      0.8.90
%define       V_gnome_icon_theme_major 2.19
%define       V_gnome_icon_theme_minor 91
%define       V_tango_icon_theme       0.8.90
%define       V_xfce_icon_theme        4.4.2
%define       V_toolbaricons           20101107

#   package information
Name:         icon-theme
Summary:      Icon Theme
URL:          http://icon-theme.freedesktop.org/
Vendor:       FreeDesktop Project
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        XWindow
License:      GPL
Version:      0
Release:      20131218

#   list of sources
Source0:      http://icon-theme.freedesktop.org/releases/hicolor-icon-theme-%{V_hicolor_icon_theme}.tar.gz
Source1:      http://tango.freedesktop.org/releases/icon-naming-utils-%{V_icon_naming_utils}.tar.gz
Source2:      http://tango.freedesktop.org/releases/tango-icon-theme-%{V_tango_icon_theme}.tar.gz
Source3:      http://ftp.gnome.org/pub/gnome/sources/gnome-icon-theme/%{V_gnome_icon_theme_major}/gnome-icon-theme-%{V_gnome_icon_theme_major}.%{V_gnome_icon_theme_minor}.tar.gz
Source4:      http://www.xfce.org/archive/xfce-%{V_xfce_icon_theme}/src/xfce4-icon-theme-%{V_xfce_icon_theme}.tar.bz2
Source5:      http://download.sourceforge.net/toolbaricons/ToolbarIcons-png256-%{V_toolbaricons}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, perl, perl-xml, pkgconfig, imagemagick
PreReq:       OpenPKG, openpkg >= 20160101

%description
    This is a bundle of icons themes following the FreeDesktop Icon
    Theme standard. Currently it provides the Hicolor Fallback icon
    theme ("hicolor"), the Tango icon theme ("Tango"), the GNOME icon
    theme ("gnome") and the XFCE icon theme ("Rodent").

%track
    prog icon-theme:hicolor-icon-theme = {
        version   = %{V_hicolor_icon_theme}
        url       = http://icon-theme.freedesktop.org/releases/
        regex     = hicolor-icon-theme-(__VER__)\.tar\.gz
    }
    prog icon-theme:icon-naming-utils = {
        version   = %{V_icon_naming_utils}
        url       = http://tango.freedesktop.org/releases/
        regex     = icon-naming-utils-(__VER__)\.tar\.gz
    }
    prog icon-theme:tango-icon-theme = {
        version   = %{V_tango_icon_theme}
        url       = http://tango.freedesktop.org/releases/
        regex     = tango-icon-theme-(__VER__).tar.gz
    }
    prog icon-theme:gnome-icon-theme = {
        version   = %{V_gnome_icon_theme_major}.%{V_gnome_icon_theme_minor}
        url       = http://ftp.gnome.org/pub/gnome/sources/gnome-icon-theme/%{V_gnome_icon_theme_major}/
        regex     = gnome-icon-theme-(__VER__).tar.gz
    }
    prog icon-theme:xfce-icon-theme = {
        version   = %{V_xfce_icon_theme}
        url       = http://www.xfce.org/archive/
        regex     = xfce-(\d+\.\d+(?:\.\d+)*)
        url       = http://www.xfce.org/archive/xfce-__NEWVER__/src/
        regex     = xfce4-icon-theme-(__VER__).tar.bz2
    }
    prog icon-theme:toolbaricons = {
        version   = %{V_toolbaricons}
        url       = http://sourceforge.net/projects/toolbaricons/files/
        regex     = ToolbarIcons-png256-(__VER__).tar.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5

%build

%install
    #   create common directories
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig

    #   install filesystem layout
    ( cd hicolor-icon-theme-%{V_hicolor_icon_theme}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      ./configure \
          --prefix=%{l_prefix} \
          --datadir=%{l_prefix}/share/icon-theme
      %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    ) || exit $?

    #   install icon naming utilities
    ( cd icon-naming-utils-%{V_icon_naming_utils}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      ./configure \
          --prefix=%{l_prefix} \
          --libexecdir=%{l_prefix}/libexec/icon-theme \
          --datadir=%{l_prefix}/share/icon-theme
      %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
      mv  $RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/pkgconfig/* \
          $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
      rmdir $RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/pkgconfig 2>&1 || true
    ) || exit $?

    #   install Tango icon theme
    ( cd tango-icon-theme-%{V_tango_icon_theme}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      PKG_CONFIG_PATH="$RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig:%{l_prefix}/lib/pkgconfig" \
      ./configure \
          --prefix=%{l_prefix} \
          --datadir=%{l_prefix}/share/icon-theme
      export INU_DATA_DIR="$RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/icon-naming-utils"
      %{l_make} %{l_mflags} install \
          AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
          ICONMAP="$RPM_BUILD_ROOT%{l_prefix}/libexec/icon-theme/icon-name-mapping"
    ) || exit $?

    #   install GNOME icon theme
    ( cd gnome-icon-theme-%{V_gnome_icon_theme_major}.%{V_gnome_icon_theme_minor}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      PKG_CONFIG_PATH="$RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig:%{l_prefix}/lib/pkgconfig" \
      ./configure \
          --prefix=%{l_prefix} \
          --datadir=%{l_prefix}/share/icon-theme
      export INU_DATA_DIR="$RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/icon-naming-utils"
      %{l_make} %{l_mflags} install \
          AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
          ICONMAP="$RPM_BUILD_ROOT%{l_prefix}/libexec/icon-theme/icon-name-mapping"
      mv  $RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/pkgconfig/* \
          $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
      rmdir $RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/pkgconfig 2>&1 || true
    ) || exit $?

    #   install XFCE icon theme
    ( cd xfce4-icon-theme-%{V_xfce_icon_theme}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags}" \
      LDFLAGS="%{l_ldflags}" \
      PKG_CONFIG_PATH="$RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig:%{l_prefix}/lib/pkgconfig" \
      ./configure \
          --prefix=%{l_prefix} \
          --datadir=%{l_prefix}/share/icon-theme
      export INU_DATA_DIR="$RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/icon-naming-utils"
      %{l_make} %{l_mflags} install \
          AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
          ICONMAP="$RPM_BUILD_ROOT%{l_prefix}/libexec/icon-theme/icon-name-mapping"
    ) || exit $?

    #   install ToolbarIcons theme
    ( cd png/256/Modern3D
      %{l_shtool} mkdir -f -p -m 755 \
          $RPM_BUILD_ROOT%{l_prefix}/share/icon-theme/toolbaricons
      cp -rp * \
          $RPM_BUILD_ROOT%{l_prefix}share/icon-theme/toolbaricons/
    ) || exit $?

    #   strip down installation
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/locale 2>&1 || true

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

%files -f files

%clean

