7 let jobs, targets
, dodeplist
, dotarlist
= getopt
();;
10 match getval
"src" with
11 | None
-> failwith
"no source dir"
16 cmopp ~flags
:"-g -I +lablGL -thread" ~dirname
:srcdir "apc";
19 "-ccopt '-Wall -o ml_apc.o'"
21 (StrSet.singleton
"ml_apc.o")
22 [Filename.concat
srcdir "ml_apc.c"]
27 "-Wall -Werror -g -c" ""
29 [Filename.concat
srcdir (base ^
".c")]
41 "-custom -thread -g -I +lablGL lablgl.cma lablglut.cma unix.cma threads.cma"
43 (StrSet.singleton
"apc")
44 ["ml_apc.o"; "apc.cmo"]
48 let moddir = Filename.concat
srcdir "mod" in
49 let modconts = Sys.readdir
moddir in
50 let deps = Array.fold_left
(fun deps s
->
51 if String.length s
> 0 && s
.[0] != '
.'
53 let src = Filename.concat
moddir s
in
54 add_target s
(StrSet.singleton
src) (StrSet.singleton s
) (StrSet.singleton
src);
57 [Run
("cp " ^
Filename.quote
src ^
" " ^
Filename.quote s
)]
62 { get_commands
= commands
64 ; get_presentation
= presentation
67 State.put_build_info s
build;
71 ) StrSet.empty
modconts
74 let commands _ = [Run
("make")]
76 and presentation
_ = "KBUILD" in
77 { get_commands
= commands
79 ; get_presentation
= presentation
82 add_phony
"mod" deps "";
83 State.put_build_info
"mod" build;
89 let start = Unix.gettimeofday
() in
90 (* Scan.all targets; *)
93 List.iter
State.print_deps targets
97 let built = Unix.handle_unix_error
Build.path path
in
101 then print_endline
(path ^
" has been built")
102 else print_endline
("nothing to be done for " ^ path
)
109 let rec loop i tids
= if i
= jobs then tids
else
110 let tid = Thread.create
(fun () -> iter
build targets
) () in
111 loop (succ i
) (tid :: tids
)
113 let tids = loop 0 [] in
114 iter
Thread.join
tids
117 Cache.save
!State.Config.cache
;
118 let stop = Unix.gettimeofday
() in
119 Format.eprintf
"build took %f seconds@." (stop -. start);