File lua-lpeg.spec of Package lua-lpeg

#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define flavor @BUILD_FLAVOR@
%define _name lgi
%define mod_name lpeg
Version:        1.0.2
Release:        0
Summary:        Parsing Expression Grammars For Lua
License:        MIT
Group:          Development/Libraries/Other
URL:            http://www.inf.puc-rio.br/~roberto/lpeg
Source:         http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-%{version}.tar.gz
BuildRequires:  %{flavor}-devel
BuildRequires:  lua-macros
Requires:       %{flavor}
%if "%{flavor}" == ""
Name:           lua-%{mod_name}
ExclusiveArch:  do_not_build
%else
Name:           %{flavor}-%{mod_name}
Provides:       %{flavor}-LPeg = %{version}
Obsoletes:      %{flavor}-LPeg < %{version}
%endif

%description
LPeg is a new pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs).

%package doc
Summary:        Lua Documentation for %{mod_name}
Group:          Development/Languages/Other
Requires:       %{name} = %{version}
BuildArch:      noarch

%description doc
Documentation and examples included with the library, sometimes
generated by luadoc or ldoc.

%prep
%setup -q -n lpeg-%{version}

# Set our cflags
sed -i \
    -e 's:../lua/:%{lua_incdir}:' \
    -e 's: -O2: %{optflags}:g' \
    makefile

%build
%make_build -j1

%install

mkdir -p %{buildroot}%{_docdir}/%{name}
mkdir -p %{buildroot}%{lua_archdir}
mkdir -p %{buildroot}%{lua_noarchdir}

install lpeg.so %{buildroot}%{lua_archdir}
install -Dm 644 re.lua %{buildroot}%{lua_noarchdir}

%check
LUA_PATH='%{_datadir}/lua/%{lua_version}/?.lua'
LUA_PATH="%{buildroot}%{lua_noarchdir}/?/init.lua;${LUA_PATH}"
export LUA_PATH="%{buildroot}%{lua_noarchdir}/?.lua;${LUA_PATH}"
%{_bindir}/lua%{lua_version} test.lua

%files
%{lua_archdir}
%{lua_noarchdir}

%files doc
%doc re.html lpeg.html HISTORY

%changelog
openSUSE Build Service is sponsored by