Use Info.Title for Window title (if available)
[llpp.git] / build.ml
blob675a4cff034e3837f7a79f4130a8ef23972a4d8a
1 let start = Unix.gettimeofday ();;
3 open List;;
4 open Typs;;
5 open Utils;;
6 open State;;
7 open Helpers;;
9 let jobs, targets, dodeplist, dotarlist = getopt ();;
11 let get key msg =
12 match getval key with | None -> failwith msg | Some s -> s
15 let getdef key def =
16 match getval key with | None -> def | Some s -> s
19 let srcdir = get "src" "no source dir";;
20 let cc = getdef "cc" "cc";;
21 let ccopt = getdef "ccopt" "";;
22 let mupdflibpath = get "mupdflibpath" "no mupdf libpath";;
24 let boc flags src =
25 let o = src ^ ".o" in
26 let c = src ^ ".c" in
27 ocaml
28 "ocamlc.opt"
29 ("-cc '" ^ cc ^ "' -ccopt '" ^ flags ^ " " ^ ccopt ^ " -o " ^ o ^ "'")
31 (StrSet.singleton o)
32 [Filename.concat srcdir c]
33 (StrSet.empty)
37 let ocaml1 prog flags1 flags2 mainoutput outputs inputs deps f =
38 let flags = flags1 ^ " -o " ^ Filename.quote mainoutput in
39 let build =
40 let commands _ =
41 let s = String.concat " " (map Filename.quote (f ())) in
42 [Run (prog ^ " " ^ flags ^ " " ^ s ^ flags2)]
44 let cookie _ = prog ^ flags in
45 let presentation _ = "OCAMLC " ^ mainoutput in
46 { get_commands = commands
47 ; get_cookie = cookie
48 ; get_presentation = presentation
51 let inputs = fold_right StrSet.add inputs StrSet.empty in
52 let deps = StrSet.union inputs deps in
53 StrSet.iter (fun output ->
54 put_build_info output build;
55 let deps = StrSet.remove output deps in
56 add_target output inputs outputs deps
57 ) outputs;
60 let ocaml' prog flags1 flags2 mainoutput outputs inputs deps =
61 ocaml1 prog flags1 flags2 mainoutput outputs inputs deps (fun () -> inputs)
64 let bso name objs =
65 let so = name ^ ".so" in
66 let mupdf_libs =
67 " -L" ^ mupdflibpath ^
68 " -lmupdf -lopenjpeg -ljbig2dec -ljpeg -lz -lfreetype"
70 let o = List.map (fun s -> s ^ ".o") objs in
71 ocaml'
73 ("-shared -lpthread -o " ^ so ^ mupdf_libs)
74 (mupdf_libs)
76 (StrSet.singleton so)
78 StrSet.empty
83 let () =
84 boc "-g" "link";
85 let so = bso "link" ["link"] in
86 let prog name cmos =
87 ocaml
88 "ocamlc.opt"
89 ("-g -I +lablGL lablgl.cma lablglut.cma str.cma unix.cma -dllpath "
90 ^ Sys.getcwd ())
91 name
92 (StrSet.singleton name)
93 (State.dep_sort cmos)
94 StrSet.empty
96 let main =
97 cmopp ~flags:"-g -w y -I +lablGL -thread" ~dirname:srcdir "main";
98 "main.cmo"
100 prog "llpp" [so; main];
103 let () =
104 let objs =
105 c cc "-c -Wall -Werror -Wextra -g" srcdir "test";
106 ["test.o"]
108 let objsgl =
109 c cc "-c -Wall -Werror -Wextra -g" srcdir "testgl";
110 ["testgl.o"]
112 let prog name objs =
115 ~doscan:false
116 ~flags1:""
117 ~flags2:"-lX11 -lXext"
118 ~output:name
119 objs
121 let proggl name objs =
124 ~doscan:false
125 ~flags1:""
126 ~flags2:"-lX11 -lXext -lGL"
127 ~output:name
128 objs
130 prog "test" objs;
131 proggl "testgl" objsgl;
134 let () =
135 run start jobs targets dodeplist dotarlist;