+#
+# Conditional build:
+%bcond_without ocaml_opt # skip building native optimized binaries (bytecode is always built)
+
+# not yet available on x32 (ocaml 4.02.1), update when upstream will support it
+%ifnarch %{ix86} %{x8664} %{arm} aarch64 ppc sparc sparcv9
+%undefine with_ocaml_opt
+%endif
+
+%if %{without ocaml_opt}
+%define _enable_debug_packages 0
+%endif
+
%define ocaml_ver 1:3.09.2
Summary: OpenGL binding for OCaml
Summary(pl.UTF-8): Wiązania OpenGL dla OCamla
Name: ocaml-lablgl
-Version: 1.02
-Release: 6
+Version: 1.06
+Release: 2
License: BSD
Group: Libraries
-Source0: http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/dist/lablgl-%{version}.tar.gz
-# Source0-md5: b50e4e7d856c26bc4449151e4307b37b
-Patch0: %{name}-tk85.patch
+#Source0Download: https://github.com/garrigue/lablgl/releases
+Source0: https://github.com/garrigue/lablgl/archive/v%{version}/lablgl-%{version}.tar.gz
+# Source0-md5: 8ee7a37b016095c4f7cd066f0ebd4436
URL: http://wwwfun.kurims.kyoto-u.ac.jp/soft/olabl/lablgl.html
BuildRequires: OpenGL-GLX-devel
BuildRequires: OpenGL-glut-devel >= 3.7
%prep
%setup -q -n lablgl-%{version}
-%patch0 -p1
+
+find LablGlut/examples -name '*.ml' -print0 | xargs --null \
+ %{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+lablglut(\s|$),#!%{_bindir}/lablglut\1,' \
%build
sed -e 's|^\(X\|TK\)INCLUDES|#&|;
s|^GLLIBS.*|GLLIBS = -lGL -lGLU -lXmu|;
s|^COPTS.*|COPTS = %{rpmcflags} -c -fPIC|;' \
Makefile.config.ex > Makefile.config
-%{__make} -j1 all opt
+%{__make} -j1 all %{?with_ocaml_opt:opt}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/ocaml/{stublibs,site-lib/{lablgl,togl}}} \
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir}/ocaml/stublibs} \
$RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}/{LablGlut,Togl}
%{__make} install \
LIBDIR=$RPM_BUILD_ROOT%{_libdir}/ocaml \
BINDIR=$RPM_BUILD_ROOT%{_bindir}
-mv -f $RPM_BUILD_ROOT%{_libdir}/ocaml/lablGL/*.mli .
+%{__mv} $RPM_BUILD_ROOT%{_libdir}/ocaml/lablGL/*.mli .
cp -r LablGlut/examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}/LablGlut
cp -r Togl/examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}/Togl
-cat > $RPM_BUILD_ROOT%{_libdir}/ocaml/site-lib/lablgl/META <<EOF
-# Specifications for the "lablgl" library:
-requires = ""
-version = "%{version}"
-directory = "+lablGL"
-archive(byte) = "lablgl.cma"
-archive(native) = "lablgl.cmxa"
-linkopts = ""
-EOF
-
-cat > $RPM_BUILD_ROOT%{_libdir}/ocaml/site-lib/togl/META <<EOF
-# Specifications for the "togl" library:
-requires = "lablgl"
-version = "%{version}"
-directory = "+lablGL"
-archive(byte) = "togl.cma"
-archive(native) = "togl.cmxa"
-linkopts = ""
-EOF
+cp -p META $RPM_BUILD_ROOT%{_libdir}/ocaml/lablGL
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
%doc COPYRIGHT CHANGES README
+%dir %{_libdir}/ocaml/lablGL
+%{_libdir}/ocaml/lablGL/META
%attr(755,root,root) %{_libdir}/ocaml/stublibs/dlllablgl.so
%files devel
%defattr(644,root,root,755)
%doc *.mli
-%dir %{_libdir}/ocaml/lablGL
+%{_libdir}/ocaml/lablGL/build.ml
%{_libdir}/ocaml/lablGL/gl*
%{_libdir}/ocaml/lablGL/lablgl.*
%{_libdir}/ocaml/lablGL/liblablgl.a
%{_libdir}/ocaml/lablGL/raw.*
-%{_libdir}/ocaml/site-lib/lablgl
%{_examplesdir}/%{name}-%{version}
%files glut
%defattr(644,root,root,755)
%{_libdir}/ocaml/lablGL/togl.*
%{_libdir}/ocaml/lablGL/libtogl.a
-%{_libdir}/ocaml/site-lib/togl
%files toplevel
%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/*
+%attr(755,root,root) %{_bindir}/lablgl
+%attr(755,root,root) %{_bindir}/lablglut