File lua-luasql.spec of Package lua-luasql

# spec file for package lua-luasql
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2014 Malcolm J Lewis <>
# 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

%global flavor @BUILD_FLAVOR@%{nil}
%define flavor_dec $(c=%{flavor}; echo ${c:0:-1}.${c: -1})
%define flavor_ver %{lua:ver, ok = string.gsub(rpm.expand("%{flavor}"), "lua(%d)(%d)", "%1.%2"); print(ver)}
%define mod_name luasql
%define lua_archdir	%{_libdir}/lua/%{flavor_ver}
%define lua_incdir	%{_includedir}/lua%{flavor_ver}
%define lua_noarchdir	%{_datadir}/lua/%{flavor_ver}

%if "%{flavor}" == ""
Name:           lua-%{mod_name}
ExclusiveArch:  do_not_build
Name:           %{flavor}-%{mod_name}
Version:        2.4.0
Release:        0
Summary:        Simple interface from Lua to a DBMS
License:        MIT
Group:          Development/Libraries/Other
#Source0 via
# PATCH-FIX-OPENSUSE luasql-fix-configuration.patch -- Clean up building and add rpm optflags.
Patch0:         luasql-fix-configuration.patch
BuildRequires:  %{flavor}-devel
BuildRequires:  libiodbc-devel
BuildRequires:  libmysqlclient-devel
BuildRequires:  pkg-config
BuildRequires:  postgresql-devel
BuildRequires:  sqlite3-devel
Requires:       %{flavor}
Requires:       libmariadb3

A simple interface from Lua to a DBMS. It enables a Lua program to:
 - Connect to ODBC, ADO, Oracle, MySQL, SQLite and PostgreSQL databases;
 - Execute arbitrary SQL statements;
 - Retrieve results in a row-by-row cursor fashion.

%setup -q -n %{mod_name}-%{version}
%patch0 -p1

export OPTFLAGS="%{optflags}"
export LUA_INC="%{lua_incdir}"

# also oci8 firebird
make %{?_smp_mflags} \
    DRIVER_INCS="-I%{_includedir}" DRIVER_LIBS_sqlite3="-lsqlite3" sqlite3
make %{?_smp_mflags} \
    DRIVER_INCS="-I%{_includedir}/pgsql" DRIVER_LIBS_postgres="-lpq" postgres
make %{?_smp_mflags} \
    DRIVER_INCS="-I%{_includedir}/mysql" DRIVER_LIBS_mysql="-lmysqlclient -lz" mysql
make %{?_smp_mflags} \
    DRIVER_INCS="-I%{_includedir}" DRIVER_LIBS_odbc="-liodbc" odbc

%make_install LUA_LIBDIR='$(DESTDIR)%{lua_archdir}' sqlite3
%make_install LUA_LIBDIR='$(DESTDIR)%{lua_archdir}' postgres
%make_install LUA_LIBDIR='$(DESTDIR)%{lua_archdir}' mysql
%make_install LUA_LIBDIR='$(DESTDIR)%{lua_archdir}' odbc

%doc doc/us/*
%dir %{lua_archdir}/luasql
# TODO? Split to subpackages?
# /usr/lib64/lua/%%{lua_version}/luasql
# /usr/lib64/lua/%%{lua_version}/luasql/
# /usr/lib64/lua/%%{lua_version}/luasql/
# /usr/lib64/lua/%%{lua_version}/luasql/

openSUSE Build Service is sponsored by