##
##  highlight.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   4.10
%define       V_dist   4.10
%define       V_subdir 4.10

#   package information
Name:         highlight
Summary:      Syntax Highlighting Utility
URL:          http://www.andre-simon.de/
Vendor:       Andre Simon
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Typesetting
License:      GPL
Version:      %{V_opkg}
Release:      20231023

#   list of sources
Source0:      http://www.andre-simon.de/zip/highlight-%{V_dist}.tar.bz2
Source1:      rse.theme
Patch0:       highlight.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, gcc, gcc::with_cxx = yes, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  boost, lua
PreReq:       boost, lua

%description
    Highlight is a utility for applying syntax highlighting to a myriad
    of programming language texts. It supports HTML, XHTML, RTF, TeX,
    LaTeX, XSL-FO and ANSI as output formats.

%track
    prog highlight = {
        version   = %{V_dist}
        url       = http://www.andre-simon.de/zip/download.html
        regex     = highlight-(__VER__)\.tar\.bz2
    }

%prep
    %setup -q -n highlight-%{V_subdir}
    %patch -p0

%build
    %{l_make} %{l_mflags} \
        CXX="%{l_cxx} -std=c++14" \
        CFLAGS="%{l_cxxflags} %{l_cppflags lua .}" \
        LDFLAGS="%{l_ldflags lua .}" \
        data_dir=%{l_prefix}/share/highlight/ \
        conf_dir=%{l_prefix}/etc/highlight/

%install
    %{l_make} %{l_mflags} install \
        INSTALL_DATA="%{l_shtool} install -m 644 -c" \
        INSTALL_PROGRAM="%{l_shtool} install -m 755 -c" \
        data_dir=$RPM_BUILD_ROOT%{l_prefix}/share/highlight/ \
        bin_dir=$RPM_BUILD_ROOT%{l_prefix}/bin/ \
        man_dir=$RPM_BUILD_ROOT%{l_prefix}/man/ \
        doc_dir=$RPM_BUILD_ROOT%{l_prefix}/share/highlight/doc/ \
        examples_dir=$RPM_BUILD_ROOT%{l_prefix}/share/highlight/examples/ \
        conf_dir=$RPM_BUILD_ROOT%{l_prefix}/etc/highlight/
    %{l_gzip} -d $RPM_BUILD_ROOT%{l_prefix}/man/man1/highlight.1.gz
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/highlight/examples
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/highlight/doc
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_shtool} install -c -m 644 \
        %{SOURCE rse.theme} $RPM_BUILD_ROOT%{l_prefix}/share/highlight/highlight/themes/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%config %{l_prefix}/etc/highlight/*'

%files -f files

%clean

