1 OCaml sources uses separate Makefile and Makefile.nt in each directory,
2 which is a pain when cross-compiling. Instead of that, it's better to
3 combine all objects into one Makefile, and make sure the source is
4 defended by #ifdef/#ifndef WIN32 ... #endif, around the whole files as
7 diff -urN ocaml-3.11.0+beta1.orig/asmrun/Makefile ocaml-3.11.0+beta1.mingw/asmrun/Makefile
8 --- ocaml-3.11.0+beta1.orig/asmrun/Makefile 2007-11-15 13:21:15.000000000 +0000
9 +++ ocaml-3.11.0+beta1.mingw/asmrun/Makefile 2008-11-15 14:43:50.000000000 +0000
11 misc.o freelist.o major_gc.o minor_gc.o memory.o alloc.o compare.o ints.o \
12 floats.o str.o array.o io.o extern.o intern.o hash.o sys.o parsing.o \
13 gc_ctrl.o terminfo.o md5.o obj.o lexing.o printexc.o callback.o weak.o \
14 - compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o
15 + compact.o finalise.o custom.o unix.o win32.o backtrace.o natdynlink.o
20 ln -s ../byterun/globroots.c globroots.c
21 unix.c: ../byterun/unix.c
22 ln -s ../byterun/unix.c unix.c
23 +win32.c: ../byterun/win32.c
24 + ln -s ../byterun/win32.c win32.c
25 dynlink.c: ../byterun/dynlink.c
26 ln -s ../byterun/dynlink.c dynlink.c
27 signals.c: ../byterun/signals.c
29 LINKEDFILES=misc.c freelist.c major_gc.c minor_gc.c memory.c alloc.c array.c \
30 compare.c ints.c floats.c str.c io.c extern.c intern.c hash.c sys.c \
31 parsing.c gc_ctrl.c terminfo.c md5.c obj.c lexing.c printexc.c callback.c \
32 - weak.c compact.c finalise.c meta.c custom.c main.c globroots.c unix.c \
33 + weak.c compact.c finalise.c meta.c custom.c main.c globroots.c unix.c win32.c \
37 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/byterun/Makefile.common ocaml-3.11.0+beta1.mingw/byterun/Makefile.common
38 --- ocaml-3.11.0+beta1.orig/byterun/Makefile.common 2008-09-10 06:51:11.000000000 +0100
39 +++ ocaml-3.11.0+beta1.mingw/byterun/Makefile.common 2008-11-15 15:47:05.000000000 +0000
41 compare.o ints.o floats.o str.o array.o io.o extern.o intern.o \
42 hash.o sys.o meta.o parsing.o gc_ctrl.o terminfo.o md5.o obj.o \
43 lexing.o callback.o debugger.o weak.o compact.o finalise.o custom.o \
48 alloc.c array.c compare.c extern.c floats.c gc_ctrl.c hash.c \
49 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/byterun/unix.c ocaml-3.11.0+beta1.mingw/byterun/unix.c
50 --- ocaml-3.11.0+beta1.orig/byterun/unix.c 2008-04-22 13:40:14.000000000 +0100
51 +++ ocaml-3.11.0+beta1.mingw/byterun/unix.c 2008-11-15 14:44:12.000000000 +0000
54 /* Unix-specific stuff */
59 /* Helps finding RTLD_DEFAULT in glibc */
67 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/byterun/win32.c ocaml-3.11.0+beta1.mingw/byterun/win32.c
68 --- ocaml-3.11.0+beta1.orig/byterun/win32.c 2008-04-22 13:24:10.000000000 +0100
69 +++ ocaml-3.11.0+beta1.mingw/byterun/win32.c 2008-11-15 15:50:32.000000000 +0000
72 /* $Id: win32.c,v 1.36 2008/04/22 12:24:10 frisch Exp $ */
76 /* Win32-specific stuff */
80 seed ^= GetCurrentProcessId();
85 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/otherlibs/systhreads/Makefile ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/Makefile
86 --- ocaml-3.11.0+beta1.orig/otherlibs/systhreads/Makefile 2008-07-15 16:31:32.000000000 +0100
87 +++ ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/Makefile 2008-11-15 15:51:58.000000000 +0000
89 MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
90 COMPFLAGS=-warn-error A -g
92 -BYTECODE_C_OBJS=posix_b.o
93 -NATIVECODE_C_OBJS=posix_n.o
94 +BYTECODE_C_OBJS=posix_b.o win32_b.o
95 +NATIVECODE_C_OBJS=posix_n.o win32_n.o
97 THREAD_OBJS= thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
103 +win32_b.$(O): win32.c
104 + $(BYTECC) -I ../../byterun $(BYTECCCOMPOPTS) $(CFLAGS) -c win32.c
105 + mv win32.$(O) win32_b.$(O)
107 # Dynamic linking with -lpthread is risky on many platforms, so
108 # do not create a shared object for libthreadsnat.
109 libthreadsnat.a: $(NATIVECODE_C_OBJS)
111 $(NATIVECC) -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) -c posix.c
114 +win32_n.$(O): win32.c
115 + $(NATIVECC) -DNATIVE_CODE -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) -c win32.c
116 + mv win32.$(O) win32_n.$(O)
118 threads.cma: $(THREAD_OBJS)
119 $(MKLIB) -ocamlc '$(CAMLC)' -o threads $(THREAD_OBJS) \
120 - -cclib -lunix $(PTHREAD_LINK)
121 + -cclib -lunix $(PTHREAD_LINK) -lcamlrun
123 # See remark above: force static linking of libthreadsnat.a
124 threads.cmxa: $(THREAD_OBJS:.cmo=.cmx)
125 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/otherlibs/systhreads/posix.c ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/posix.c
126 --- ocaml-3.11.0+beta1.orig/otherlibs/systhreads/posix.c 2008-09-27 11:46:55.000000000 +0100
127 +++ ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/posix.c 2008-11-15 15:35:28.000000000 +0000
130 /* $Id: posix.c,v 1.58 2008/09/27 10:46:55 xleroy Exp $ */
134 /* Thread interface for POSIX 1003.1c threads */
138 raise_sys_error(str);
142 diff --exclude _build -urN ocaml-3.11.0+beta1.orig/otherlibs/systhreads/win32.c ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/win32.c
143 --- ocaml-3.11.0+beta1.orig/otherlibs/systhreads/win32.c 2007-10-31 09:12:29.000000000 +0000
144 +++ ocaml-3.11.0+beta1.mingw/otherlibs/systhreads/win32.c 2008-11-15 15:35:47.000000000 +0000
147 /* $Id: win32.c,v 1.45 2007/10/31 09:12:29 xleroy Exp $ */
151 /* Thread interface for Win32 threads */
155 sprintf(errmsg, "%s: error code %lx", msg, GetLastError());
156 raise_sys_error(copy_string(errmsg));