- -x11lib %{_libdir} \
- -x11include %{_includedir} \
- -mandir %{_mandir}/man1 \
- -cc %{_mingw32_cc} \
- -as %{_mingw32_as}
-
-# ./configure creates the following files:
-# config/Makefile - containing mainly paths and names of build tools
-# config/m.h - containing the machine description
-# config/s.h - containing the environment / API description
-
-# Overwrite the generated m.h & s.h with the ones from Windows NT.
-cp config/m-nt.h config/m.h
-cp config/s-nt.h config/s.h
-
-make world bootstrap opt opt.opt
+ -mandir %{_mandir}/man1
+make world
+
+# Now move the working ocamlrun, ocamlc into the boot/ directory,
+# overwriting the binary versions which ship with the compiler with
+# ones that contain the above filename-win32-dirsep patch.
+make coreboot
+
+# Now replace the compiler configuration (config/{s.h,m.h,Makefile})
+# with ones as they would be on a 32 bit Windows system.
+pushd config
+
+# config/m.h can just be copied from config/m-nt.h which ships.
+rm -f m.h
+cp m-nt.h m.h
+
+# config/s.h can just be copied from config/s-nt.h which ships.
+rm -f s.h
+cp s-nt.h s.h
+
+# config/Makefile is a custom one which we supply.
+rm -f Makefile
+sed \
+ -e 's,@prefix@,%{_prefix},g' \
+ -e 's,@bindir@,%{_bindir},g' \
+ -e 's,@libdir@,%{_libdir},g' \
+ < %{SOURCE1000} > Makefile
+
+popd
+
+# We're going to build in otherlibs/win32unix and otherlibs/win32graph
+# directories, but since they would normally only be built under
+# Windows, they only have the Makefile.nt files. Just symlink
+# Makefile -> Makefile.nt for these cases.
+for d in otherlibs/win32unix otherlibs/win32graph; do
+ ln -s Makefile.nt $d/Makefile
+done
+
+# Now clean the temporary files from the previous build. This
+# will also cause asmcomp/arch.ml (etc) to be linked to the 32 bit
+# i386 versions, essentially causing ocamlopt to use the Win/i386 code
+# generator.
+make partialclean
+
+# Just rebuild some small bits that we need for the following
+# 'make opt' to work. Note that 'make all' fails here.
+make -C byterun libcamlrun.a
+make ocaml ocamlc
+make -C stdlib
+make -C tools ocamlmklib
+
+# Build ocamlopt
+make opt