OCaml sources uses separate Makefile and Makefile.nt in each directory,
which is a pain when cross-compiling.  Instead of that, it's better to
combine all objects into one Makefile, and make sure the source is
defended by #ifdef/#ifndef WIN32 ... #endif, around the whole files as
necessary.

Index: build-tree/ocaml-3.12.1/asmrun/Makefile
===================================================================
--- build-tree.orig/ocaml-3.12.1/asmrun/Makefile	2010-04-20 17:47:15.000000000 +0200
+++ build-tree/ocaml-3.12.1/asmrun/Makefile	2011-10-09 04:22:46.385153424 +0200
@@ -26,7 +26,7 @@
   misc.o freelist.o major_gc.o minor_gc.o memory.o alloc.o compare.o ints.o \
   floats.o str.o array.o io.o extern.o intern.o hash.o sys.o parsing.o \
   gc_ctrl.o terminfo.o md5.o obj.o lexing.o printexc.o callback.o weak.o \
-  compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o debugger.o
+  compact.o finalise.o custom.o unix.o win32.o backtrace.o natdynlink.o debugger.o
 
 ASMOBJS=$(ARCH).o
 
@@ -138,6 +138,8 @@
 	ln -s ../byterun/globroots.c globroots.c
 unix.c: ../byterun/unix.c
 	ln -s ../byterun/unix.c unix.c
+win32.c: ../byterun/win32.c
+	ln -s ../byterun/win32.c win32.c
 dynlink.c: ../byterun/dynlink.c
 	ln -s ../byterun/dynlink.c dynlink.c
 signals.c: ../byterun/signals.c
@@ -148,7 +150,7 @@
 LINKEDFILES=misc.c freelist.c major_gc.c minor_gc.c memory.c alloc.c array.c \
   compare.c ints.c floats.c str.c io.c extern.c intern.c hash.c sys.c \
   parsing.c gc_ctrl.c terminfo.c md5.c obj.c lexing.c printexc.c callback.c \
-  weak.c compact.c finalise.c meta.c custom.c main.c globroots.c unix.c \
+  weak.c compact.c finalise.c meta.c custom.c main.c globroots.c unix.c win32.c \
   dynlink.c signals.c debugger.c
 
 clean::
Index: build-tree/ocaml-3.12.1/byterun/Makefile.common
===================================================================
--- build-tree.orig/ocaml-3.12.1/byterun/Makefile.common	2010-05-21 13:28:21.000000000 +0200
+++ build-tree/ocaml-3.12.1/byterun/Makefile.common	2011-10-09 04:22:46.389151425 +0200
@@ -24,7 +24,7 @@
   compare.o ints.o floats.o str.o array.o io.o extern.o intern.o \
   hash.o sys.o meta.o parsing.o gc_ctrl.o terminfo.o md5.o obj.o \
   lexing.o callback.o debugger.o weak.o compact.o finalise.o custom.o \
-  dynlink.o
+  dynlink.o win32.o
 
 PRIMS=\
   alloc.c array.c compare.c extern.c floats.c gc_ctrl.c hash.c \
Index: build-tree/ocaml-3.12.1/byterun/unix.c
===================================================================
--- build-tree.orig/ocaml-3.12.1/byterun/unix.c	2010-07-02 10:44:04.000000000 +0200
+++ build-tree/ocaml-3.12.1/byterun/unix.c	2011-10-09 04:22:46.389151425 +0200
@@ -15,6 +15,8 @@
 
 /* Unix-specific stuff */
 
+#ifndef WIN32
+
 #define _GNU_SOURCE
            /* Helps finding RTLD_DEFAULT in glibc */
 
@@ -323,3 +325,5 @@
 }
 
 #endif
+
+#endif /* !WIN32 */
Index: build-tree/ocaml-3.12.1/byterun/win32.c
===================================================================
--- build-tree.orig/ocaml-3.12.1/byterun/win32.c	2010-01-22 13:48:24.000000000 +0100
+++ build-tree/ocaml-3.12.1/byterun/win32.c	2011-10-09 04:24:17.191729161 +0200
@@ -13,6 +13,8 @@
 
 /* $Id: win32.c 9547 2010-01-22 12:48:24Z doligez $ */
 
+#ifdef WIN32
+
 /* Win32-specific stuff */
 
 #include <windows.h>
@@ -543,3 +545,5 @@
   seed ^= GetCurrentProcessId();
   return seed;
 }
+
+#endif /* WIN32 */
Index: build-tree/ocaml-3.12.1/otherlibs/systhreads/Makefile
===================================================================
--- build-tree.orig/ocaml-3.12.1/otherlibs/systhreads/Makefile	2011-10-09 04:22:45.109791401 +0200
+++ build-tree/ocaml-3.12.1/otherlibs/systhreads/Makefile	2011-10-09 04:22:46.389151425 +0200
@@ -20,8 +20,8 @@
 MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
 COMPFLAGS=-warn-error A -g
 
-BYTECODE_C_OBJS=st_stubs_b.o
-NATIVECODE_C_OBJS=st_stubs_n.o
+BYTECODE_C_OBJS=st_stubs_b.o win32_b.o
+NATIVECODE_C_OBJS=st_stubs_n.o win32_n.o
 
 THREAD_OBJS= thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
 
@@ -37,6 +37,10 @@
 	   -c st_stubs.c
 	mv st_stubs.o st_stubs_b.o
 
+win32_b.$(O): st_stubs.c st_win32.h
+	$(BYTECC) -I ../../byterun $(BYTECCCOMPOPTS) $(CFLAGS) -c st_stubs.c
+	mv st_stubs.$(O) win32_b.$(O)
+
 # Dynamic linking with -lpthread is risky on many platforms, so
 # do not create a shared object for libthreadsnat.
 libthreadsnat.a: $(NATIVECODE_C_OBJS)
@@ -46,9 +50,13 @@
 	$(NATIVECC) -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) -c st_stubs.c
 	mv st_stubs.o st_stubs_n.o
 
+win32_n.$(O): st_stubs.c st_win32.h
+	$(NATIVECC) -DNATIVE_CODE -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) -c st_stubs.c
+	mv st_stubs.$(O) win32_n.$(O)
+
 threads.cma: $(THREAD_OBJS)
 	$(MKLIB) -ocamlc '$(CAMLC)' -o threads $(THREAD_OBJS) \
-	  -cclib -lunix $(PTHREAD_LINK)
+	  -cclib -lunix $(PTHREAD_LINK) -lcamlrun
 
 # See remark above: force static linking of libthreadsnat.a
 threads.cmxa: $(THREAD_OBJS:.cmo=.cmx)
