summaryrefslogtreecommitdiffstats
path: root/src/ocaml-native-1-fixes.patch
blob: 795bf5d83ecb15e46b6c1781d3b03421897884cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
This file is part of MXE.
See index.html for further information.

Contains ad hoc patches for cross building.

From 71a88993df13ccaaab5957ad2a0aef3adf1d49ff Mon Sep 17 00:00:00 2001
From: MXE
Date: Wed, 3 Oct 2012 09:25:11 +0200
Subject: [PATCH 1/5] findlib.ml


diff --git a/ocamlbuild/findlib.ml b/ocamlbuild/findlib.ml
index b5ef878..77454ed 100644
--- a/ocamlbuild/findlib.ml
+++ b/ocamlbuild/findlib.ml
@@ -44,7 +44,7 @@ let report_error e =
   prerr_endline (string_of_error e);
   exit 2
 
-let ocamlfind = "ocamlfind"
+let ocamlfind = "@target@-ocamlfind"
 
 type package = {
   name: string;
-- 
1.7.2.5


From a1a25210b44d5c7064d5c7a7002676a114b5f539 Mon Sep 17 00:00:00 2001
From: MXE
Date: Wed, 3 Oct 2012 09:26:40 +0200
Subject: [PATCH 2/5] main.ml : warnings on use of option -use-ocamlfind


diff --git a/ocamlbuild/main.ml b/ocamlbuild/main.ml
index 3b9bd89..7045867 100644
--- a/ocamlbuild/main.ml
+++ b/ocamlbuild/main.ml
@@ -152,6 +152,14 @@ let proceed () =
   Ocaml_specific.init ();
   Hooks.call_hook Hooks.After_rules;
 
+  if not !Options.use_ocamlfind then begin
+	if !Param_tags.ocamlfind_tags_used <> StringSet.empty then 
+	  Log.eprintf "Warning: Tag(s) '%s' can only work with option -use-ocamlfind"
+		(String.concat "," (StringSet.elements !Param_tags.ocamlfind_tags_used));
+	if !Options.ocaml_pkgs <> [] then
+	  Log.eprintf "Warning: Options -pkg and -pkgs only work with -use-ocamlfind"
+  end;
+
   Param_tags.init ();
 
   Sys.chdir newpwd;
-- 
1.7.2.5


From aa7642e19ec9a81bcdda382d4682ab20df0013ba Mon Sep 17 00:00:00 2001
From: MXE
Date: Wed, 3 Oct 2012 09:29:23 +0200
Subject: [PATCH 3/5] param_tags : use of special tags considering whether state of option -use-ocamlfind


diff --git a/ocamlbuild/param_tags.ml b/ocamlbuild/param_tags.ml
index 02001de..1aae306 100644
--- a/ocamlbuild/param_tags.ml
+++ b/ocamlbuild/param_tags.ml
@@ -12,15 +12,24 @@
 
 (* Original author: Romain Bardou *)
 
-module StringSet = Set.Make(String)
+(* 1 : 'acknowledge' while reading user input;
+   2 : 'declare '    to declare what tags are parameterised tags
+   3 : 'init'        to check acknowledged vs declared tags,
+   and perform declared actions *)
+
+module StringSet = My_std.StringSet
 module SSOSet = Set.Make(struct
   type t = string * string option
   let compare = Pervasives.compare
 end)
 
-(* tag name -> tag action (string -> unit) *)
+(* tag (string) -> action (string -> unit) *)
+(* all parameterised tags must be declared here *)
 let declared_tags = Hashtbl.create 17
 
+(* set of tags that were read (see 'acknowledge'): 
+   ("package",Some "lablgtk2") if "package(lablgtk2)" was read ;
+   ("foo",None) if "foo" was read *)
 let acknowledged_tags = ref SSOSet.empty
 
 let only_once f =
@@ -32,25 +41,32 @@ let only_once f =
       f param
     end
 
-let declare name action =
-  Hashtbl.add declared_tags name (only_once action)
+let declare tag action =
+  Hashtbl.add declared_tags tag (only_once action)
 
-let acknowledge tag =
-  let tag = Lexers.tag_gen (Lexing.from_string tag) in
-  acknowledged_tags := SSOSet.add tag !acknowledged_tags
+let ocamlfind_tags_used = ref StringSet.empty
 
-let really_acknowledge (name, param) =
-  match param with
-    | None ->
-        if Hashtbl.mem declared_tags name then
-          Log.eprintf "Warning: tag %S expects a parameter" name
-    | Some param ->
-        let actions = List.rev (Hashtbl.find_all declared_tags name) in
-        if actions = [] then
-          Log.eprintf "Warning: tag %S does not expect a parameter, but is used with parameter %S" name param;
-        List.iter (fun f -> f param) actions
+let acknowledge tag_string =
+  let sso = Lexers.tag_gen (Lexing.from_string tag_string) in
+  let tag = fst sso in
+  (match tag with
+  | "package" | "predicate" | "syntax" -> 
+	ocamlfind_tags_used := StringSet.add tag !ocamlfind_tags_used
+  | _ -> ()
+  );
+  acknowledged_tags := SSOSet.add sso !acknowledged_tags
 
 let init () =
-  SSOSet.iter really_acknowledge !acknowledged_tags
+  SSOSet.iter (fun (tag,param) ->
+	match param with
+    | None ->
+      if Hashtbl.mem declared_tags tag then
+        Log.eprintf "Warning: tag %S expects a parameter" tag
+    | Some param ->
+      let actions = List.rev (Hashtbl.find_all declared_tags tag) in
+      if actions = [] then
+        Log.eprintf "Warning: tag %S does not expect a parameter, but is used with parameter %S" tag param;
+      List.iter (fun f -> f param) actions
+  ) !acknowledged_tags
 
 let make = Printf.sprintf "%s(%s)"
-- 
1.7.2.5


From e1f2adad03b52d5b71dea7fd6e2169d361366d60 Mon Sep 17 00:00:00 2001
From: MXE
Date: Wed, 3 Oct 2012 09:30:21 +0200
Subject: [PATCH 4/5] param_tags : use of special tags considering whether state of option -use-ocamlfind (mli)


diff --git a/ocamlbuild/param_tags.mli b/ocamlbuild/param_tags.mli
index a0047af..0839534 100644
--- a/ocamlbuild/param_tags.mli
+++ b/ocamlbuild/param_tags.mli
@@ -12,29 +12,38 @@
 
 (* Original author: Romain Bardou *)
 
+(** just a check for use of tag "package" that implies ocamlfind use *)
+val ocamlfind_tags_used : My_std.StringSet.t ref
+
 val declare: string -> (string -> unit) -> unit
   (** Declare a parameterized tag.
 
-[declare "name" action]: [action "param"] will be executed (once) by [init]
-if a tag of the form [name(param)] is [acknowledge]d.
-
-A given tag may be declared several times with different actions. All actions
-will be executed, in the order they were declared. *)
+[declare tag action] declares [tag] as a parameterized tag.
+A given tag may be declared several times with different actions.
+[init] will execute all actions in the order they were declared. 
+Example : [declare "package" action] *)
 
 val acknowledge: string -> unit
   (** Acknowledge a tag.
 
-If the tag is of the form [X(Y)], and have been declared using [declare],
-then the actions given using [declare] will be executed with [Y] as parameter
-when [init] is executed. The action will only be called once per
-acknowledged parameter. *)
+[acknowledge "package(lablgtk2)"] will store the tag "package" with
+parameter [Some "lablgtk2"].
+[acknowledge "annot"] will store the tag "annot" with 
+parameter [None] *)
 
 val init: unit -> unit
   (** Initialize parameterized tags.
 
-Call this function once all tags have been [declare]d and [acknowledge]d.
+[init] checks in turn each acknowledged tag along with its parameter :
+- if the tag is declared (e.g "package"), and parameter=Some "lablgtk2",
+calls declared actions (only once) on "lablgtk2".
+- if the tag is not declared (e.g "annot"), and parameter=None, nothing is done
+- if the tag is not declared, but there is a parameter, raise a warning
+- if the tag is declared, but there is no parameter, raise a warning
 If you [declare] or [acknowledge] a tag after having called [init], this will
-have no effect. [init] should only be called once. *)
+have no effect. 
+[init] must be called once all tags have been marked with [declare] and
+[acknowledge]. It should only be called once. *)
 
 val make: Tags.elt -> string -> Tags.elt
   (** Make a parameterized tag instance.
-- 
1.7.2.5


From 82118f5d8e0cb7a0193479d0e7459d265692551a Mon Sep 17 00:00:00 2001
From: MXE
Date: Wed, 3 Oct 2012 09:31:13 +0200
Subject: [PATCH 5/5] options : support for prefixed ocaml-tools with ocamlfind


diff --git a/ocamlbuild/options.ml b/ocamlbuild/options.ml
index 1be4b63..48f6648 100644
--- a/ocamlbuild/options.ml
+++ b/ocamlbuild/options.ml
@@ -39,16 +39,17 @@ let use_menhir = ref false
 let catch_errors = ref true
 let use_ocamlfind = ref false
 
-let mk_virtual_solvers =
+let mk_virtual_solvers target =
   let dir = Ocamlbuild_where.bindir in
   List.iter begin fun cmd ->
-    let opt = cmd ^ ".opt" in
+	let target_cmd = target^cmd in
+    let opt = target_cmd ^ ".opt" in
     let a_opt = A opt in
-    let a_cmd = A cmd in
+    let a_cmd = A target_cmd in
     let search_in_path = memo Command.search_in_path in
     let solver () =
       if sys_file_exists !dir then
-        let long = filename_concat !dir cmd in
+        let long = filename_concat !dir target_cmd in
         let long_opt = long ^ ".opt" in
         if file_or_exe_exists long_opt then A long_opt
         else if file_or_exe_exists long then A long
@@ -61,9 +62,9 @@ let mk_virtual_solvers =
   end
 
 let () =
-  mk_virtual_solvers
-    ["ocamlc"; "ocamlopt"; "ocamldep"; "ocamldoc";
-    "ocamlyacc"; "menhir"; "ocamllex"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"]
+  mk_virtual_solvers "@target@-" 
+	["ocamlc"; "ocamlopt"; "ocamldep"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"];
+  mk_virtual_solvers "" ["ocamldoc"; "ocamlyacc"; "menhir"; "ocamllex"; "ocamlfind"]
 let ocamlc = ref (V"OCAMLC")
 let ocamlopt = ref (V"OCAMLOPT")
 let ocamldep = ref (V"OCAMLDEP")
@@ -73,7 +74,7 @@ let ocamllex = ref (V"OCAMLLEX")
 let ocamlmklib = ref (V"OCAMLMKLIB")
 let ocamlmktop = ref (V"OCAMLMKTOP")
 let ocamlrun = ref N
-let ocamlfind x = S[V"OCAMLFIND"; x]
+let ocamlfind = (V"OCAMLFIND")
 let program_to_execute = ref false
 let must_clean = ref false
 let show_documentation = ref false
@@ -261,11 +262,19 @@ let init () =
     (* TODO: warning message when using an option such as -ocamlc *)
     (* Note that plugins can still modify these variables After_options.
        This design decision can easily be changed. *)
-    ocamlc := ocamlfind & A"ocamlc";
-    ocamlopt := ocamlfind & A"ocamlopt";
-    ocamldep := ocamlfind & A"ocamldep";
-    ocamldoc := ocamlfind & A"ocamldoc";
-    ocamlmktop := ocamlfind & A"ocamlmktop";
+	List.iter (fun (option,string) ->
+	  (match !option with
+	  | Sh s
+	  | A s ->
+		Log.eprintf "Warning : Command '-%s %s' overidden by option -use-ocamlfind" string s
+	  | _ -> ()
+	  );
+	  option := S[ocamlfind; A string]
+	) [(ocamlc,"ocamlc");
+	   (ocamlopt,"ocamlopt");
+	   (ocamldep,"ocamldep");
+	   (ocamldoc,"ocamldoc");
+	   (ocamlmktop,"ocamlmktop")]
   end;
 
   let reorder x y = x := !x @ (List.concat (List.rev !y)) in
-- 
1.7.2.5