License: QPL and (LGPLv2+ with exceptions)
Group: Development/Libraries
+
URL: http://caml.inria.fr/
Source0: http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-%{version}.tar.bz2
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+# This is installed as config/Makefile when we cross-compile.
+Source1000: Makefile-fedora-mingw.in
+
+# XXX We should apply any Fedora native patches here.
+
+# For patch description, see the top of each patch file.
+# Start numbering at 1000 since these are MinGW-specific patches.
+Patch1000: mingw32-ocaml-3.11.0+beta1-combined-Makefile.patch
+Patch1001: mingw32-ocaml-3.11.0+beta1-disable-cmxs.patch
+Patch1002: mingw32-ocaml-3.11.0+beta1-filename-win32-dirsep.patch
+Patch1003: mingw32-ocaml-3.11.0+beta1-i386-profiling.patch
+Patch1004: mingw32-ocaml-3.11.0+beta1-no-stdlib-dir.patch
+Patch1005: mingw32-ocaml-3.11.0+beta1-win32-fixes.patch
+Patch1006: mingw32-ocaml-3.11.0+beta1-win32unix-path.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+# Is it noarch? (XXX)
BuildArch: noarch
BuildRequires: mingw32-filesystem >= 30
BuildRequires: mingw32-gcc
BuildRequires: mingw32-binutils
+BuildRequires: mingw32-flexdll
%description
%prep
%setup -q -n ocaml-%{version}
+%patch1000 -p1
+%patch1001 -p1
+%patch1002 -p1
+%patch1003 -p1
+%patch1004 -p1
+%patch1005 -p1
+%patch1006 -p0
-%build
-# Remember that we're _not_ cross-compiling OCaml itself, we're trying
-# to build a Fedora native OCaml compiler (ocamlopt) which just has
-# the back-end part modified to generate Windows binaries. So we
-# build as normal on a Unix system, but we make sure that ocamlopt
-# will use the Windows codegen and the MinGW assembler and linker.
-CFLAGS="$RPM_OPT_FLAGS" \
+%build
+# Build native ocamlrun and ocamlc which contain the filename-win32-dirsep
+# patch.
./configure \
+ -no-tk \
-bindir %{_bindir} \
-libdir %{_libdir}/ocaml \
- -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
%install
rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
-# Remove static libraries but DON'T remove *.dll.a files.
-rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libfoo.a
+# Only want to install ocamlopt and libraries.
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+mkdir -p $RPM_BUILD_ROOT%{_libdir}/i686-pc-mingw32-ocaml
+mkdir -p $RPM_BUILD_ROOT%{_libdir}/i686-pc-mingw32-ocaml/threads
+
+make installopt \
+ BINDIR=$RPM_BUILD_ROOT%{_bindir} \
+ LIBDIR=$RPM_BUILD_ROOT%{_libdir}/i686-pc-mingw32-ocaml
+
+# ocamlopt is a cross-compiler, so rename the binary.
+# XXX This should probably use %{_mingw32_target} macro.
+mv $RPM_BUILD_ROOT%{_bindir}/ocamlopt \
+ $RPM_BUILD_ROOT%{_bindir}/i686-pc-mingw32-ocamlopt
%clean
%files
%defattr(-,root,root)
-%{_mingw32_bindir}/foo.dll
-%{_mingw32_libdir}/foo.dll.a
-# etc.
+%{_bindir}/i686-pc-mingw32-ocamlopt
+%{_libdir}/i686-pc-mingw32-ocaml/
%changelog
-* Fri Nov 14 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-1
+* Sat Nov 15 2008 Richard W.M. Jones <rjones@redhat.com> - 3.11.0+beta1-1
- Initial RPM release.