%global commit f75e2d7c465e641e8c736ca2601ce7859df41c43
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name:           egl-registry
# awk '/Version/ {print $NF; exit}' sdk/docs/man/reference.xml
Version:        1.5
Release:        1.20190318git%{shortcommit}%{?dist}
Summary:        EGL API and Extension Registry

License:        MIT
URL:            https://github.com/KhronosGroup/EGL-Registry/
Source0:        https://github.com/KhronosGroup/EGL-Registry/archive/%{commit}/EGL-Registry-%{shortcommit}.tar.gz

BuildArch:      noarch
BuildRequires:  /usr/bin/xsltproc
BuildRequires:  docbook-style-xsl

%description
The EGL-Registry repository contains the EGL API and Extension Registry, 
including specifications, reference pages and reference cards, and the 
enumerant registry.


%package -n egl-docs
Summary:        EGL API Documentation

%description -n egl-docs
This package ships the manual fof the EGL API and the extensions.


%prep
%setup -q -n EGL-Registry-%{commit}


%build
mkdir man
cd man
for i in ../sdk/docs/man/docbook4/egl*.xml; do
        awk '
                /<refsect3 id="Copyright">/ {s=1}
                /<\/refmeta>/ {print "<refmiscinfo class=\"manual\">%{summary}</refmiscinfo>"}
                {if(!s)print}
                /<\/refsect3>/ {s=0}
        ' $i >tmp
        mv tmp $i

        xsltproc --nonet --stringparam man.th.extra1.suppress 1 \
                http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $i

done


%install
mkdir -p %{buildroot}%{_mandir}/man3G
install man/* %{buildroot}%{_mandir}/man3G


%files -n egl-docs
%{_mandir}/man3G
%license sdk/docs/man/copyright.xml
%doc extensions
%doc README.md


%changelog
* Fri Mar 22 2019 Lubomir Rintel <lkundrak@v3.sk> - 1.5-1.20190318gitf75e2d7
- Initial packaging