##
##  ploticus.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_opkg 2.33
%define       V_dist 233

#   package information
Name:         ploticus
Summary:      Data Display Engine
URL:          http://ploticus.sourceforge.net/
Vendor:       Steve Grubb
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Diagram
License:      GPL
Version:      %{V_opkg}
Release:      20120623

#   list of sources
Source0:      http://download.sourceforge.net/ploticus/pl%{V_dist}src.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  gd, png, zlib, freetype, fontconfig
PreReq:       gd, png, zlib, freetype, fontconfig

%description
    Ploticus is a non-interactive tool for producing plots, charts, and
    graphics from data. Ploticus is good for automated or just-in-time
    graph generation, handles date and time data nicely, and has basic
    statistical capabilities. It allows significant user control over
    colors, styles, options and details.

%track
    prog ploticus = {
        version   = %{V_dist}
        url       = http://ploticus.sourceforge.net/doc/download.html
        regex     = pl(__VER__)src\.tar\.gz
    }

%prep
    %setup -q -n pl%{V_dist}src

%build
    ( cd src
      %{l_shtool} subst \
          -e 's;^\(CC =\).*;\1 %{l_cc} %{l_cflags -O};' \
          -e "s;^\\(XLIBS =\\).*;\\1;" \
          -e "s;^\\(INCLUDEDIRS =\\).*;\\1 %{l_cppflags};" \
          -e 's;^# \(NOXFLAG = -DNOX11.*\)$;\1;' \
          -e 's;^# \(XOBJ =\).*;\1;' \
          -e 's;^\(ploticus:.*\)$;# \1;' \
          -e 's;^# \(ploticus: plgd18.*\)$;\1;' \
          -e 's;^# \(GD18LIBS =\)\( -lgd -lpng -lz -ljpeg -lfreetype.*\)$;\1 %{l_ldflags} \2 -lfontconfig -lfreetype -liconv -lexpat;' \
          -e 's;^# \(GD18H =\).*;\1 %{l_cppflags};' \
          -e 's;^# \(GDFREETYPE = -DGDFREETYPE.*\)$;\1;' \
          -e 's;^# \(PREFABS_DIR =\).*$;\1 %{l_prefix}/share/ploticus;' \
          -e 's;^# \(ZLIB = -lz.*\)$;\1;' \
          -e 's;^# \(ZFLAG = -DWZ.*\)$;\1;' \
          Makefile
      %{l_make} %{l_mflags}
    ) || exit $?

%install
    %{l_shtool} mkdir -p -f -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/share/ploticus
    %{l_shtool} install -c -s -m 755 \
        src/pl $RPM_BUILD_ROOT%{l_prefix}/bin/ploticus
    %{l_shtool} install -c -m 644 \
        prefabs/* $RPM_BUILD_ROOT%{l_prefix}/share/ploticus/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

