-# Rename the binaries so they don't clash with base OCaml package.
-mv $RPM_BUILD_ROOT%{_bindir}/ocamlrun \
- $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlrun
-echo '#!%{_bindir}/%{_mingw32_target}-ocamlrun' \
- > $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
-tail -n +2 $RPM_BUILD_ROOT%{_bindir}/ocamlopt \
- >> $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
-chmod 0755 $RPM_BUILD_ROOT%{_bindir}/%{_mingw32_target}-ocamlopt
-rm $RPM_BUILD_ROOT%{_bindir}/ocamlopt
+# For bytecode binaries, change the bang-path to point to the locally
+# installed ocamlrun.
+pushd $RPM_BUILD_ROOT%{_bindir}
+for f in ocamlc ocamlcp ocamldep ocamlmklib ocamlopt ocamlprof; do
+ mv $f $f.old
+ echo '#!%{_bindir}/%{_mingw32_target}-ocamlrun' > $f
+ tail -n +2 $f.old >> $f
+ chmod +x $f
+ rm $f.old
+done
+popd
+
+# Rename all the binaries to target-binary.
+pushd $RPM_BUILD_ROOT%{_bindir}
+for f in ocamlc ocamlcp ocamldep ocamlmklib ocamlmktop ocamlopt ocamlprof ocamlrun; do
+ mv $f %{_mingw32_target}-$f
+done
+popd