4 date --version |
grep -q "GNU" && dfmt
="%s.%N" || dfmt
="%s"
9 command -v md5sum >/dev
/null
&& alias sum=md5sum
12 test $?
-eq 0 && msg
="ok" || msg
="ko"
13 echo "$msg $(echo "scale
=3; ($
(now
) - $tstart)/1" | bc -l) sec"
23 test -n "$1" || die
"usage: $0 build-directory"
29 test -e "$1" && test -r "$1.past" && {
41 eval ocamlc
-depend -bytecode -one-line $incs $s |
{
44 for d
in $
(eval echo $depl); do
50 cmd
="ocamlc $incs -c -o $o $s"
52 grep -q "$o" $outd/ordered ||
{
53 echo "$o" >>$outd/ordered
54 isfresh
"$o" "$cmd$(eval $keycmd)" ||
{
55 printf "%*.s%s -> %s\n" $n '' "${s#$srcd/}" "$o"
57 echo "k='$cmd$(eval $keycmd)'" >$o.past
58 } && $vecho "fresh '$o'"
66 test ${wocmi%help.cmo} != $wocmi && {
70 test "$o" = "$wocmi" && s
=${o%.cmo}.ml || s
=$wocmi.mli
74 incs
="-I lablGL -I $outd/lablGL -I wsi/x11 -I $outd/wsi/x11 -I $outd"
82 muinc
="-I $mudir/include -I $mudir/thirdparty/freetype/include"
83 cmd
="ocamlc -ccopt \"-O2 $muinc -MMD -MF $o.dep -MT_ -o $o\" $s"
84 test -r $o.dep
&& read _ d
<$o.dep
85 keycmd
='sum $o $d 2>/dev/null'
86 isfresh
"$o" "$cmd$(eval $keycmd)" ||
{
87 printf "%s -> %s\n" "${s#$srcd/}" "$o"
90 echo "k='$cmd$(eval $keycmd)'" >$o.past
94 mkdir
-p $outd/wsi
/x11
99 ocaml str.cma
-stdin $srcd/KEYS
<<EOF
100 let fixup = let open Str in
101 let dash = regexp {|\([^ ]*\) +- +\(.*\)|}
102 and head = regexp {|-----\(.*\)-----|} in fun s ->
103 String.escaped s |> global_replace dash {|\1\t\2|}
104 |> global_replace head {|\xc2\xb7\1|};;
105 let rec iter ic = match input_line ic with
106 | s -> Printf.printf "\"%s\";\\n" @@ fixup s; iter ic
107 | exception End_of_file -> ();;
108 Printf.printf "let keys = [\\n";
109 iter @@ open_in Sys.argv.(1);;
110 Printf.printf "] and version = \"$ver\";;"
114 ver
=$
(cd $srcd && git describe
--tags) ||
echo unknown
115 cmd
="mkhelp >$outd/help.ml"
116 keycmd
="sum $srcd/KEYS; echo $ver"
117 isfresh
"$outd/help.ml" '$cmd$(eval keycmd)$ver' ||
{
119 echo "k='$cmd$(eval $keycmd)$ver'" >$outd/help.ml.past
122 for m
in lablGL
/glMisc.cmo lablGL
/glTex.cmo wsi
/x11
/wsi.cmo main.cmo
; do
127 libs
="str.cma unix.cma"
128 clibs
="-lGL -lX11 -L$mudir/build/native -lmupdf -lmupdfthird -lpthread"
130 for f
in ml_gl ml_glarray ml_raw
; do
132 globjs
="$globjs $outd/lablGL/$f.o"
135 ord
=$
(echo $
(eval grep -v \.cmi
$outd/ordered
))
136 cmd
="ocamlc -custom $libs -o $outd/llpp $ord"
137 cmd
="$cmd $globjs $outd/link.o -cclib \"$clibs\""
138 keycmd
="sum $outd/llpp $ord"
139 isfresh
"$outd/llpp" "$cmd$(eval $keycmd)" ||
{
140 echo linking
$outd/llpp
142 echo "k='$cmd$(eval $keycmd)'" >$outd/llpp.past