##
##  imlib.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_imlib1_major 1.9
%define       V_imlib1_minor 15
%define       V_imlib2_major 1.12
%define       V_imlib2_minor 5

#   package information
Name:         imlib
Summary:      The Gtk Image Library
URL:          http://www.enlightenment.org/Libraries/Imlib2/
Vendor:       Carsten Haitzler
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        XWindow
License:      GPL
Version:      %{V_imlib2_major}.%{V_imlib2_minor}
Release:      20250410

#   list of sources
Source0:      ftp://ftp.gnome.org/pub/GNOME/sources/imlib/%{V_imlib1_major}/imlib-%{V_imlib1_major}.%{V_imlib1_minor}.tar.gz
Source1:      http://download.sourceforge.net/enlightenment/imlib2-%{V_imlib2_major}.%{V_imlib2_minor}.tar.gz
Patch0:       imlib.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  glib, tiff, jpeg, png, giflib, freetype
PreReq:       glib, tiff, jpeg, png, giflib, freetype

%description
    Imlib is an image processing library for use with Gtk. It can
    load/save image files from/to disk in many formats, render image
    data onto other images, render images to an X-Windows drawable,
    produce pixmaps and pixmap masks of images, apply filters to
    images, rotate images, accept RGBA data for images, scale images,
    alpha blend images on other images or drawables, apply color
    correction and modification tables and factors to images, render
    images onto images with color correction and modification tables,
    render truetype anti-aliased text at any angle, render anti-aliased
    lines, render rectangles render linear multi-colored gradients,
    cache data intelligently for maximum performance, allocate colors
    automatically, allow full control over caching and color allocation,
    provide plug-in filter interface, and provide on-the-fly runtime
    plug-in image loading and saving interface.

    This package contains both the newer Imlib2 %{V_imlib2_major}.%{V_imlib2_minor}
    and the older Imlib %{V_imlib1_major}.%{V_imlib1_minor}.

%track
    prog imlib:imlib1 = {
        version   = %{V_imlib1_major}.%{V_imlib1_minor}
        url       = ftp://ftp.gnome.org/pub/GNOME/sources/imlib/
        regex     = (\d+\.\d+)\b
        url       = ftp://ftp.gnome.org/pub/GNOME/sources/imlib/__NEWVER__/
        regex     = imlib-(__VER__)\.tar\.gz
    }
    prog imlib:imlib2 = {
        version   = %{V_imlib2_major}.%{V_imlib2_minor}
        url       = http://sourceforge.net/project/showfiles.php?group_id=2
        regex     = imlib2-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -D -T -a 1
    %patch -p0
    %{l_shtool} subst \
        -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
        imlib-%{V_imlib1_major}.%{V_imlib1_minor}/configure

%build
    ( cd imlib2-%{V_imlib2_major}.%{V_imlib2_minor}
      CC="%{l_cc}" \
      CFLAGS="%{l_cflags -O}" \
      CPPFLAGS="%{l_cppflags tiff .}" \
      LDFLAGS="%{l_ldflags}" \
      LIBS="-ljpeg -lz -lm" \
      ./configure \
          --prefix=%{l_prefix} \
          --without-x \
          --without-gtk \
          --without-zlib \
          --without-bzip2 \
          --without-id3 \
          --disable-shared
      %{l_make} %{l_mflags -O}
    ) || exit $?

%install
    ( cd imlib2-%{V_imlib2_major}.%{V_imlib2_minor}
      %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    ) || exit $?
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std}

%files -f files

%clean

