New patches from Fedora.
[fedora-mingw.git] / ocaml / mingw32-ocaml-3.11.0+beta1-combined-Makefile.patch
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
5 necessary.
6
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
10 @@ -26,7 +26,7 @@
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
16  
17  ASMOBJS=$(ARCH).o
18  
19 @@ -138,6 +138,8 @@
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
28 @@ -146,7 +148,7 @@
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 \
34    dynlink.c signals.c
35  
36  clean::
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
40 @@ -24,7 +24,7 @@
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 \
44 -  dynlink.o
45 +  dynlink.o win32.o
46  
47  PRIMS=\
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
52 @@ -15,6 +15,8 @@
53  
54  /* Unix-specific stuff */
55  
56 +#ifndef WIN32
57 +
58  #define _GNU_SOURCE
59             /* Helps finding RTLD_DEFAULT in glibc */
60  
61 @@ -320,3 +322,5 @@
62  }
63  
64  #endif
65 +
66 +#endif /* !WIN32 */
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
70 @@ -13,6 +13,8 @@
71  
72  /* $Id: win32.c,v 1.36 2008/04/22 12:24:10 frisch Exp $ */
73  
74 +#ifdef WIN32
75 +
76  /* Win32-specific stuff */
77  
78  #include <windows.h>
79 @@ -543,3 +564,5 @@
80    seed ^= GetCurrentProcessId();
81    return seed;
82  }
83 +
84 +#endif /* WIN32 */
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
88 @@ -20,8 +20,8 @@
89  MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
90  COMPFLAGS=-warn-error A -g
91  
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
96  
97  THREAD_OBJS= thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
98  
99 @@ -39,6 +39,10 @@
100            -c posix.c
101         mv posix.o posix_b.o
102  
103 +win32_b.$(O): win32.c
104 +       $(BYTECC) -I ../../byterun $(BYTECCCOMPOPTS) $(CFLAGS) -c win32.c
105 +       mv win32.$(O) win32_b.$(O)
106 +
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)
110 @@ -48,9 +52,13 @@
111         $(NATIVECC) -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) -c posix.c
112         mv posix.o posix_n.o
113  
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)
117 +
118  threads.cma: $(THREAD_OBJS)
119         $(MKLIB) -ocamlc '$(CAMLC)' -o threads $(THREAD_OBJS) \
120 -          -cclib -lunix $(PTHREAD_LINK)
121 +          -cclib -lunix $(PTHREAD_LINK) -lcamlrun
122  
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
128 @@ -13,6 +13,8 @@
129  
130  /* $Id: posix.c,v 1.58 2008/09/27 10:46:55 xleroy Exp $ */
131  
132 +#ifndef WIN32
133 +
134  /* Thread interface for POSIX 1003.1c threads */
135  
136  #include <errno.h>
137 @@ -924,3 +926,4 @@
138    raise_sys_error(str);
139  }
140  
141 +#endif /* !WIN32 */
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
145 @@ -13,6 +13,8 @@
146  
147  /* $Id: win32.c,v 1.45 2007/10/31 09:12:29 xleroy Exp $ */
148  
149 +#ifdef WIN32
150 +
151  /* Thread interface for Win32 threads */
152  
153  #include <windows.h>
154 @@ -662,3 +664,6 @@
155    sprintf(errmsg, "%s: error code %lx", msg, GetLastError());
156    raise_sys_error(copy_string(errmsg));
157  }
158 +
159 +#endif /* WIN32 */
160 +