File eslang.spec of Package eslang

%define bname slang
Name: e%bname
Version: 1
Release: 8
Summary: Erlang S-Lang Bindings
License: GPL-2.0
Group: Development/Tools/Other
URL: https://github.com/5HT/%name
Source: %name.tar.xz
Provides: %name-devel = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: pkg-config
BuildRequires: pkgconfig(slang) >= 2.2
BuildRequires: rebar >= 2.6.1-7
BuildRequires: erts-devel

%description
This is eslang, an erlang interface to the amazing highly portable tty interface
that gave us such nice tty applications as mutt and slrn.
It's distributed as an erlang application (without a start mod) which makes it
possible to integrate into a larger build environment. We use this at bluetail to
have a terminal application onto our actual target machine. It can be used to to
anything that's possible to do with the slang lib itself.
It's know to compile and run with slang version 2.2.4.
The API is one-to-one withe the normal C-api to slanglib.


%prep
%setup -q -n %name
mv src/demo ./


%build
erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
file:write_file("%name.rebar.config",
                lists:map(fun(E) -> [io_lib:print(E), ".\n"] end,
                          lists:keystore(port_env, 1, L, {port_env, [{"linux", "LDFLAGS", "$LDFLAGS"}]})),
                [raw]),
init:stop().'
CFLAGS="%optflags -flto" LDFLAGS="%optflags -flto" LIBS="$(pkg-config slang --libs)" \
rebar %{?_smp_mflags} -C %name.rebar.config compile -v
rebar %{?_smp_mflags} -C %name.rebar.config doc


%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/include
install -p -m 0644 include/* %buildroot%_otplibdir/%name-%version/include/
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/%bname-%version/doc
install -p -m 0644 doc/*.{css,html,png} %buildroot%_otplibdir/%bname-%version/doc/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/%bname-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 README* doc/*.txt %buildroot%_docdir/%name/


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


%changelog
* Fri Aug 25 2017 Led <ledest@gmail.com> 1-8
- remove slim opt

* Sun May 31 2015 Led <ledest@gmail.com> 1-7
- don't compile demos
- add docs

* Sun Apr 12 2015 Led <ledest@gmail.com> 1-6
- clean ups

* Sun Apr 05 2015 Led <ledest@gmail.com> 1-5
- cosmetic fixes

* Tue Mar 03 2015 Led <ledest@gmail.com> 1-4
- add provides

* Mon Mar 02 2015 Led <ledest@gmail.com> 1-3
- added '--no-as-needed' link options to fix wired rebar's link policy

* Mon Mar 02 2015 Led <ledest@gmail.com> 1-2
- add '-flto' option for link eslang_drv

* Fri Feb 27 2015 Led <ledest@gmail.com> 1-1
- initial build
openSUSE Build Service is sponsored by