File lfe.spec of Package lfe

%define bname lfe
Name: %bname
Version: 0.9.2
Release: 3
Summary: Lisp Flavoured Erlang
License: Apache-2.0
Group: Development/Tools/Other
Source: %bname-%version.tar.xz
Patch1: %bname-0.9.2-fix-build-warnings.patch
Patch2: %bname-0.9.2-remove-packages.patch
Provides: erlang-%bname = %version-%release

BuildRequires: rpm-macros-erlang rpm-build-erlang
BuildRequires: rebar erl_interface erlang-parsetools erlang-parsetools-devel

LFE, Lisp Flavoured Erlang, is a lisp syntax front-end to the Erlang compiler.
Code produced with it is compatible with "normal" Erlang code. An LFE evaluator
and shell is also included.

%setup -q
%patch1 -p1
%patch2 -p1
sed -i -r '1s|^.*/env[[:blank:]]+(.*)$|#!%_bindir/\1|' bin/%{bname}c examples/*script

erl -noshell -eval '
{ok, L} = file:consult("rebar.config"),
                lists:map(fun(E) -> io_lib:format("~p.~n", [E]) end,
                          [{erl_opts, [slim,inline|proplists:get_value(erl_opts, L)]}|proplists:delete(erl_opts, L)])),
export CFLAGS="%optflags"
for c in compile doc; do
	rebar -C %bname.rebar.config $c -v

install -d -m 0755 %buildroot%_otplibdir/%bname-%version/ebin
install -p -m 0644 ebin/* %buildroot%_otplibdir/%bname-%version/ebin/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/include
install -p -m 0644 include/* %buildroot%_otplibdir/%bname-%version/include/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/doc
install -p -m 0644 doc/*.{css,html,png,md} %buildroot%_otplibdir/%bname-%version/doc/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/priv
install -p -m 0755 priv/* %buildroot%_otplibdir/%bname-%version/priv/
install -d -m 0755 %buildroot%_otplibdir/%bname-%version/examples
install -p -m 0755 examples/*script %buildroot%_otplibdir/%bname-%version/examples/
install -p -m 0644 examples/*.lfe %buildroot%_otplibdir/%bname-%version/examples/
install -d -m 0755 %buildroot%_otpdir/bin %buildroot%_bindir
for i in %bname %{bname}c %{bname}script; do
	install -p -m 0755 bin/$i %buildroot%_otpdir/bin/
	ln -sf %_otpdir/bin/$i %buildroot%_bindir/
install -d -m 0755 %buildroot%_docdir/%name
ln -sf %_otplibdir/%bname-%version/doc %buildroot%_docdir/%name/html
install -p -m 0644 README* %buildroot%_docdir/%name/

%doc %_docdir/%name

* Sat May 30 2015 Led <> 0.9.2-3
- clean up spec

* Tue May 26 2015 Led <> 0.9.2-2
- add patches:
  + lfe-0.9.2-remove-packages.patch

* Tue May 26 2015 Led <> 0.9.2-1
- initial build