forked from geneweb/geneweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ml
151 lines (140 loc) · 4.33 KB
/
configure.ml
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
(* ocaml ./configure.ml *)
#use "topfind"
#require "unix"
let strip = ref true
let rm = ref ""
let ext = ref ""
let os_type = ref ""
let installed pkg = 0 = Sys.command ("ocamlfind query -qo -qe " ^ pkg)
let nnp_compiler =
if not Sys.win32 then 1 = Sys.command "$(ocamlc -config-var naked_pointers)"
else false
let errmsg = "usage: " ^ Sys.argv.(0) ^ " [options]"
let api = ref false
let sosa = ref `None
let gwdb = ref `None
let syslog = ref false
let caching = ref false
let set_caching () = caching := true
let set_api () = api := true
let set_syslog () = syslog := true
let set_sosa_legacy () =
assert (!sosa = `None);
sosa := `Legacy
let set_sosa_zarith () =
assert (!sosa = `None);
sosa := `Zarith
let set_sosa_num () =
assert (!sosa = `None);
sosa := `Num
let set_gwdb_legacy () =
assert (!gwdb = `None);
gwdb := `Legacy
let release = ref false
let speclist =
[
("--gwdb-legacy", Arg.Unit set_gwdb_legacy, " Use legacy backend");
( "--release",
Arg.Set release,
" Use release profile: no debug information (default: "
^ string_of_bool !release ^ ")" );
( "--debug",
Arg.Clear release,
" Use dev profile: no optimization, debug information (default: "
^ string_of_bool (not !release)
^ ")" );
( "--sosa-legacy",
Arg.Unit set_sosa_legacy,
" Use legacy Sosa module implementation" );
( "--sosa-num",
Arg.Unit set_sosa_num,
" Use Sosa module implementation based on `num` library" );
( "--sosa-zarith",
Arg.Unit set_sosa_zarith,
" Use Sosa module implementation based on `zarith` library" );
("--syslog", Arg.Unit set_syslog, " Log gwd errors using syslog");
( "--gwd-caching",
Arg.Unit set_caching,
" Enable database preloading (Unix-only)" );
]
|> List.sort compare |> Arg.align
let () =
Arg.parse speclist failwith errmsg;
let dune_dirs_exclude = ref "" in
let exclude_dir s = dune_dirs_exclude := !dune_dirs_exclude ^ " " ^ s in
let syslog_d, syslog_pkg =
match !syslog with true -> (" -D SYSLOG", "syslog") | false -> ("", "")
in
if !sosa = `None then
if installed "zarith" then set_sosa_zarith ()
else if installed "num" then set_sosa_num ()
else set_sosa_legacy ();
let sosa_d, sosa_pkg =
match !sosa with
| `Legacy ->
exclude_dir "sosa_num";
exclude_dir "sosa_zarith";
("", "geneweb_sosa_array")
| `Num ->
exclude_dir "sosa_array";
exclude_dir "sosa_zarith";
(" -D SOSA_NUM ", "geneweb_sosa_num")
| `Zarith ->
exclude_dir "sosa_array";
exclude_dir "sosa_num";
(" -D SOSA_ZARITH ", "geneweb_sosa_zarith")
| `None -> assert false
in
let gwdb_d, gwdb_pkg =
match !gwdb with
| `None | `Legacy -> (" -D GENEWEB_GWDB_LEGACY", "geneweb.gwdb-legacy")
in
let dune_profile = if !release then "release" else "dev" in
let os_type, os_d, ext, rm, strip =
match
let p = Unix.open_process_in "uname -s" in
let line = input_line p in
close_in p;
line
with
| ("Linux" | "Darwin" | "FreeBSD") as os_type ->
(os_type, " -D UNIX", "", "/bin/rm -f", "strip")
| _ -> ("Win", " -D WINDOWS", ".exe", "rm -f", "true")
in
let ancient_lib, ancient_file =
let no_cache = ("", "gw_ancient.dum.ml") in
if nnp_compiler then
if installed "ancient" then ("ancient", "gw_ancient.wrapped.ml")
else (
if !caching then
Printf.eprintf
"Warning: ocaml-ancient not installed. Cannot enable database \
caching.\n";
no_cache)
else (
if !caching then
Printf.eprintf
"Warning: Compiler not set to no-naked-pointers. Cannot enable \
database caching.\n";
no_cache)
in
let ch = open_out "Makefile.config" in
let writeln s = output_string ch @@ s ^ "\n" in
let var name value = writeln @@ name ^ "=" ^ value in
writeln @@ "# This file is generated by " ^ Sys.argv.(0) ^ ".";
var "OS_TYPE" os_type;
var "STRIP" strip;
var "RM" rm;
var "EXT" ext;
var "GWDB_D" gwdb_d;
var "OS_D" os_d;
var "SOSA_D" sosa_d;
var "SYSLOG_D" syslog_d;
var "GWDB_PKG" gwdb_pkg;
var "SOSA_PKG" sosa_pkg;
var "SYSLOG_PKG" syslog_pkg;
var "DUNE_DIRS_EXCLUDE" !dune_dirs_exclude;
var "DUNE_PROFILE" dune_profile;
var "ANCIENT_LIB" ancient_lib;
var "ANCIENT_FILE" ancient_file;
close_out ch