-cp -p {parsing/{location,longident,parsetree},typing/typecore}.{cm,ml}i \
- $RPM_BUILD_ROOT%{_libdir}/%{name}
-
-mv -f $RPM_BUILD_ROOT%{_bindir}/ocamlc $RPM_BUILD_ROOT%{_bindir}/ocamlc.byte
-ln -sf %{_bindir}/ocamlc.opt $RPM_BUILD_ROOT%{_bindir}/ocamlc
-mv -f $RPM_BUILD_ROOT%{_bindir}/ocamlopt $RPM_BUILD_ROOT%{_bindir}/ocamlopt.byte
-ln -sf %{_bindir}/ocamlopt.opt $RPM_BUILD_ROOT%{_bindir}/ocamlopt
-rm -f $RPM_BUILD_ROOT%{_libdir}/%{_name}/*.ml
+# symlink .opt versions of compilers (if present)
+# warning: don't do that with camlp4 (can't load extensions then)
+for f in ocamlc ocamlopt ocamldoc ocamllex; do
+ if test -f $RPM_BUILD_ROOT%{_bindir}/$f.opt; then
+ mv -f $RPM_BUILD_ROOT%{_bindir}/$f \
+ $RPM_BUILD_ROOT%{_bindir}/$f.byte
+ ln -sf %{_bindir}/$f.opt $RPM_BUILD_ROOT%{_bindir}/$f
+ fi
+done
+
+# move includes to the proper place
+install -d $RPM_BUILD_ROOT%{_includedir}
+mv -f $RPM_BUILD_ROOT%{_libdir}/%{name}/caml $RPM_BUILD_ROOT%{_includedir}/caml
+# but leave compatibility symlink
+ln -s ../../include/caml $RPM_BUILD_ROOT%{_libdir}/%{name}/caml
+
+# compiled sources of compiler, needed by some programs
+for f in {asm,byte}comp parsing typing utils ; do
+ install -d $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f
+ cp $f/*.{cmi,cmo,cmx,o} $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f
+done
+
+# this isn't installed by default, but is useful
+install tools/objinfo $RPM_BUILD_ROOT%{_bindir}/ocamlobjinfo
+
+install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+cp -r examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+
+install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-labltk-%{version}
+cp -r otherlibs/labltk/examples* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-labltk-%{version}