A new user interface for you! Read more...

File esqlite.spec of Package esqlite

%define bname esqlite
Name: %bname
Version: 1
Release: 2
Summary: Erlang NIF for sqlite
License: Apache-2.0
Group: Development/Tools/Other
URL: https://github.com/mmzeeman/%bname
Source: %bname.tar.xz
BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar >= 2.5.1-13
BuildRequires: pkg-config pkgconfig(sqlite3)
BuildRequires: erl_interface erts-devel

%description
%summary.


%prep
%setup -q -n %bname
sed -i \
	-e '/^sqlite_version_test()/,/^[[:blank:]]*ok\./s/<<"[^"]*">>/<<"'"$(pkg-config --modversion sqlite3)"'">>/' \
	-e '/^sqlite_source_id_test()/,/^[[:blank:]]*ok\./d' \
	test/esqlite_test.erl


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
PS = proplists:get_value(port_specs, L, []),
file:write_file("%bname.rebar.config",
                lists:map(fun(X) -> io_lib:format("~p.\n", [X]) end,
                          [{erl_opts,
                            [slim,inline,no_debug_info|lists:delete(debug_info, proplists:get_value(erl_opts, L, []))]},
                           {port_specs,
                            [{"priv/esqlite3_nif.so",
                              lists:delete("c_src/sqlite3.c", proplists:get_value("priv/esqlite3_nif.so", PS, []))}
                             |proplists:delete("priv/esqlite3_nif.so", PS)]}
                            |proplists:delete(port_specs, proplists:delete(erl_opts, L))])),
halt().'
CC=%__cc CXX=g++ CFLAGS="%optflags $(pkg-config --cflags sqlite3) -flto" LDFLAGS="%optflags -flto" LIBS="$(pkg-config --libs sqlite3)" \
rebar -C %bname.rebar.config compile -v
rebar -C %bname.rebar.config doc -v


%install
install -d -m 0755 %buildroot%_otplibdir/%name-%version/ebin
install -p -m 0644 ebin/* %buildroot%_otplibdir/%name-%version/ebin/
install -d -m 0755 %buildroot%_otplibdir/%name-%version/priv
install -p -m 0755 priv/*.so %buildroot%_otplibdir/%name-%version/priv/
install -d -m 0755 %buildroot%_otplibdir/%name-%version/doc
install -p -m 0644 doc/*.{css,html,png} %buildroot%_otplibdir/%name-%version/doc/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/%name-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 AUTHORS* CONTRIBUTERS* README* %buildroot%_docdir/%name/


%check
rebar -C %bname.rebar.config eunit


%files
%defattr(-,root,root)
%doc %_docdir/%name
%_otplibdir/*


%changelog
* Fri Oct 02 2015 Led <ledest@gmail.com> 1-2
- add inline to erl_opts

* Fri Oct 02 2015 Led <ledest@gmail.com> 1-1
- initial build (git f7b151f)