-
Notifications
You must be signed in to change notification settings - Fork 17
/
discover.ml
71 lines (61 loc) · 1.68 KB
/
discover.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
type os =
| Windows
| Mac
| Linux
| Unknown
let uname () =
let ic = Unix.open_process_in "uname" in
let uname = input_line ic in
let () = close_in ic in
uname;;
let get_os =
match Sys.os_type with
| "Win32" -> Windows
| _ -> match uname () with
| "Darwin" -> Mac
| "Linux" -> Linux
| _ -> Unknown
let root = Sys.getenv "cur__root"
let c_flags = ["-I"; (Sys.getenv "GLFW_INCLUDE_PATH"); "-I"; Filename.concat root "include"; "-I"; Filename.concat root "src"]
let c_flags = match get_os with
| Linux -> c_flags @ ["-fPIC"]
| _ -> c_flags
;;
let libPath = "-L" ^ (Sys.getenv "GLFW_LIB_PATH")
let ccopt s = ["-ccopt"; s]
let cclib s = ["-cclib"; s]
let flags =
match get_os with
| Windows -> []
@ ccopt(libPath)
@ cclib("-lglfw3")
@ cclib("-lgdi32")
| Linux -> []
@ ccopt(libPath)
@ cclib("-lGL")
@ cclib("-lGLU")
@ cclib("-lglfw3")
@ cclib("-lX11")
@ cclib("-lXxf86vm")
@ cclib("-lXrandr")
@ cclib("-lXinerama")
@ cclib("-lXcursor")
@ cclib("-lpthread")
@ cclib("-lXi")
@ cclib("-lstdc++")
| _ -> []
@ ccopt(libPath)
@ cclib("-lglfw3")
@ ccopt("-framework OpenGL")
@ ccopt("-framework Cocoa")
@ ccopt("-framework IOKit")
@ ccopt("-framework CoreVideo")
;;
let cxx_flags =
match get_os with
| Windows -> c_flags @ ["-fno-exceptions"; "-fno-rtti"; "-lstdc++"]
| _ -> c_flags
;;
Configurator.V1.Flags.write_sexp "c_flags.sexp" c_flags;
Configurator.V1.Flags.write_sexp "cxx_flags.sexp" cxx_flags;
Configurator.V1.Flags.write_sexp "flags.sexp" flags;