%define luaver %(pkg-config --variable=V lua || echo missing)
%define lualibdir %{_libdir}/lua/%{luaver}

Summary:        Regular expression handling library for Lua
Summary(ja):    正規表現を扱うための Lua ライブラリ
Name:           lua-rex
Version:        2.9.1
Release:        1%{?_dist_release}
Group:          programming
Vendor:         Project Vine
Distribution:   Vine Linux

License:        MIT
URL:            http://rrthomas.github.io/lrexlib/
%global         altver %(echo %{version} | sed -e 's/\\./-/g')
Source0:        https://github.com/rrthomas/lrexlib/archive/rel-%{altver}.tar.gz
Source1:        Makefile
Source2:        common.mak
Source3:        defaults.mak
Source4:        rex_onig.mak
Source5:        rex_pcre.mak
Source6:        rex_posix.mak
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires:  oniguruma-devel
BuildRequires:  pcre-devel
BuildRequires:  lua
BuildRequires:  lua-devel
BuildRequires:  pkgconfig
BuildRequires:  unzip
Requires:       lua(abi) = %{luaver}
Provides:       lrexlib = %{version}

%description
Lrexlib are bindings of three regular expression library APIs (POSIX, PCRE
and Oniguruma) to Lua.


%prep
%setup -q -n lrexlib-rel-%{altver}

cp -f %{SOURCE1} ./
cp -f %{SOURCE2} src/
cp -f %{SOURCE3} src/
cp -f %{SOURCE4} src/oniguruma/
cp -f %{SOURCE5} src/pcre/
cp -f %{SOURCE6} src/posix/

%build
make %{?_smp_mflags} LUA=lua LD=cc MYCFLAGS='%{optflags} -DVERSION=\"%{version}\" -fPIC %(pcre-config --cflags)' build


%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{lualibdir}
cp -P */*/rex_{onig,pcre,posix}.so* $RPM_BUILD_ROOT%{lualibdir}


%check
make %{?_smp_mflags} LUA=lua test


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{lualibdir}/*
%license LICENSE
%doc ChangeLog NEWS README doc


%changelog
* Fri Aug 21 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.9.1-1
- new upstream release.

* Sat Sep 14 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.9.0-1
- new upstream release.
- built with oniguruma-6.9.3.

* Wed Oct 24 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-6
- rebuild with pcre-8.31

* Sun Apr 17 2011 Shu KONNO <owa@bg.wakwak.com> - 2.4.0-5
- rebuilt with rpm-4.8.1-3

* Fri Feb 12 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.4.0-4
- rebuilt with gcc-4.4.3-3 on ppc

* Fri Feb  5 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.4.0-3
- rebuilt with rpm-4.8.0-3 (on ppc)

* Wed Feb 03 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.0-2
- added BR: unzip

* Wed Feb 03 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-1
- initial build for Vine Linux

* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Tue Dec 23 2008 Lubomir Rintel <lkundrak@v3.sk> - 2.4.0-3
- Compile shared library as PIC

* Wed Dec 17 2008 Lubomir Rintel <lkundrak@v3.sk> - 2.4.0-2
- Add doc directory to documentation
- Allow parallel make runs

* Tue Dec 16 2008 Lubomir Rintel <lkundrak@v3.sk> - 2.4.0-1
- Initial packaging
