[packages/lua-lpeg] add luajit-lpeg subpackage

atler atler at pld-linux.org
Sun May 19 14:16:45 CEST 2024


commit 12d316d5f7653edc18371e5cb9482186bb5f2435
Author: Jan Palus <atler at pld-linux.org>
Date:   Sun May 19 14:09:33 2024 +0200

    add luajit-lpeg subpackage

 lua-lpeg.spec | 55 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/lua-lpeg.spec b/lua-lpeg.spec
index 66f40fe..7574ca4 100644
--- a/lua-lpeg.spec
+++ b/lua-lpeg.spec
@@ -1,8 +1,12 @@
-%define	__lua	/usr/bin/lua5.1
-#define	luaver %(%{__lua} -e "print(string.sub(_VERSION, 5))")
-%define	luaver 5.1
-%define	lualibdir %{_libdir}/lua/%{luaver}
-%define	luapkgdir %{_datadir}/lua/%{luaver}
+%define	__lua		/usr/bin/lua5.1
+%define	luaver		5.1
+%define	lualibdir	%{_libdir}/lua/%{luaver}
+%define	luapkgdir	%{_datadir}/lua/%{luaver}
+
+%define	__luajit	/usr/bin/luajit
+%define	luajitabi	2.1
+%define	luajitlibdir	%{_libdir}/luajit/%{luajitabi}
+%define	luajitpkgdir	%{_datadir}/luajit/%{luajitabi}
 
 Summary:	Parsing Expression Grammars for Lua
 Name:		lua-lpeg
@@ -15,6 +19,8 @@ Source0:	http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-%{version}.tar.gz
 URL:		http://www.inf.puc-rio.br/~roberto/lpeg/
 BuildRequires:	lua51 >= %{luaver}
 BuildRequires:	lua51-devel >= %{luaver}
+BuildRequires:	luajit >= %{luajitabi}
+BuildRequires:	luajit-devel >= %{luajitabi}
 BuildRequires:	pkgconfig
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -22,9 +28,16 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 LPeg is a new pattern-matching library for Lua, based on Parsing
 Expression Grammars (PEGs).
 
+%package -n luajit-lpeg
+Summary:	Parsing Expression Grammars for Lua
+Requires:	luajit-libs
+
+%description -n luajit-lpeg
+LPeg is a new pattern-matching library for Lua, based on Parsing
+Expression Grammars (PEGs).
+
 %prep
 %setup -q -n lpeg-%{version}
-%{__sed} -i -e "s|/usr/bin/env lua5.1|%{__lua}|" test.lua
 # strict module not part of our Lua 5.1.4
 %{__sed} -i -e 's|require"strict"|-- require"strict"|' test.lua
 %{__chmod} -x test.lua
@@ -40,14 +53,34 @@ Expression Grammars (PEGs).
 %{__lua} test.lua
 %endif
 
+install -D lpeg.so build-%{luaver}/lpeg.so
+
+%{__make} clean
+
+%{__make} lpeg.so \
+	CC="%{__cc}" \
+	COPT="%{rpmcflags}" \
+	LUADIR=$(pkg-config --variable includedir luajit) \
+	DLLFLAGS="-shared -fPIC $(pkg-config --libs luajit)"
+
+%if %{with tests}
+%{__luajit} test.lua
+%endif
+
+install -D lpeg.so build-luajit/lpeg.so
+
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{lualibdir},%{luapkgdir}}
+install -d $RPM_BUILD_ROOT{%{lualibdir},%{luapkgdir},%{luajitlibdir},%{luajitpkgdir}}
 
-install -p lpeg.so $RPM_BUILD_ROOT%{lualibdir}/lpeg.so.%{version}
+install -p build-%{luaver}/lpeg.so $RPM_BUILD_ROOT%{lualibdir}/lpeg.so.%{version}
 ln -s lpeg.so.%{version} $RPM_BUILD_ROOT%{lualibdir}/lpeg.so
 install -p re.lua $RPM_BUILD_ROOT%{luapkgdir}
 
+install -p build-luajit/lpeg.so $RPM_BUILD_ROOT%{luajitlibdir}/lpeg.so.%{version}
+ln -s lpeg.so.%{version} $RPM_BUILD_ROOT%{luajitlibdir}/lpeg.so
+install -p re.lua $RPM_BUILD_ROOT%{luajitpkgdir}
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -56,3 +89,9 @@ rm -rf $RPM_BUILD_ROOT
 %doc HISTORY lpeg.html re.html lpeg-128.gif test.lua
 %attr(755,root,root) %{lualibdir}/lpeg.so*
 %{luapkgdir}/re.lua
+
+%files -n luajit-lpeg
+%defattr(644,root,root,755)
+%doc HISTORY lpeg.html re.html lpeg-128.gif test.lua
+%attr(755,root,root) %{luajitlibdir}/lpeg.so*
+%{luajitpkgdir}/re.lua
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/lua-lpeg.git/commitdiff/3806fb255681362403008ebb2dd3c3d74a05bc67



More information about the pld-cvs-commit mailing list