This repository was archived by the owner on Nov 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlmlmk.m
36 lines (35 loc) · 1.46 KB
/
lmlmk.m
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
#include "getdepend.t"
#include "getmodtime.t"
#include "makemod.t"
#include "makeexe.t"
#include "order.t"
#include "filenames.t"
#include "utils.t"
#include "argv.t"
let show_file (name,time) = name @ (if isopt "b"
then "(" @ show_When time @ ")"
else "")
in let show_dep (obj,ts)= show_file obj @ ": " @ mix (map show_file ts) " "
in let show_deps = map show_dep
in let modificationTimes = (map o apair o pairwith map o pairwith) filemodtime
in let strip = map (apair (pairwith map objectFileName) o asnd tl)
in let order' g = (decorate g o scctsort o closegraph o strip) g
in let build_graph = asnd (map modificationTimes) o order' o snd o extractDependencies
in let visited = fst o extractDependencies
and show_names = map (\ns.mix (map (fst o fst) ns) " ")
in let show_cycles [] = []
|| show_cycles cys =[TOSTDERR] @ "Cyclic dependencies:\n" @
mklines (map (\y.mix y " ") cys) @ [TOSTDOUT]
in if modules=[]
then TOSTDERR."Usage: lmlmk [+b] [+d] [+g] [+t] target ...\n"
else let (cycles,timedg) = build_graph modules
in let objcmds = makeModules timedg
and execmds = makeExecutables timedg modules
in ifdebug ["Depencency graph:"] @
ifopt ["g"] (concmap show_deps timedg) @
ifdebug ["";"tsorted dependencies:"] @
ifopt ["t"] (show_names timedg) @
show_cycles (filter ((>1) o length) cycles) @
ifdebug ["";"Commands:"] @
ifnotopt ["t";"g"] (objcmds @ execmds) @
ifdebug ("Visited=".map (\(_,ns).mix ns " ") (visited modules))