6 test "$unameN" = Darwin
&& {
15 if $
(expr >/dev
/null
"$(date --version 2>/dev/null)" : ".*GNU"); then
20 alias vecho
=${vecho-:}
21 command -v md5sum >/dev
/null || true
&& alias sum=md5sum
24 sum "$@" 2>/dev
/null |
while read h _
; do ah
="$ah$h"; done
29 test $?
-eq 0 && msg
="ok" || msg
="ko"
30 echo "$msg $(echo "scale
=3; ($
(now
) - $tstart)/1" | bc -l) sec"
40 test $
(ocamlc
-version |
{ IFS
=.
read a b _
; echo $a$b; } ) -lt 406 && {
41 die OCaml version
4.06+ is required
44 test -n "${1-}" || die
"usage: $0 build-directory"
49 muinc
="-I $mudir/include -I $mudir/thirdparty/freetype/include"
52 test -e "$1" && test -r "$1.past" && {
60 main.cmo|utils.cmo|config.cmo|parser.cmo|wsi.cmi|
$wsi/wsi.cmo
)
61 f
="-g -strict-sequence -strict-formats -warn-error a";;
64 echo "-I lablGL -I $outd/lablGL -I $wsi -I $outd/$wsi -I $outd $f"
70 f
="-g -std=c99 -O2 $muinc -Wall -Werror -pedantic-errors"
71 $darwin && echo "$f -D__COCOA__" ||
echo $f;;
72 */ml_gl.o
) echo "-g -Wno-pointer-sign -O2";;
77 mflags
() { echo "-I $(ocamlc -where) -g -O2"; }
80 eval ocamlc
-depend -bytecode -one-line $incs $s |
{
82 for d
in $
(eval echo $depl); do
83 bocaml
${d#$srcd/} $
((n
+1))
86 cmd
="ocamlc $(oflags $o) -c -o $o $s"
88 grep -q "$o" $outd/ordered ||
{
89 echo "$o" >>"$outd/ordered"
90 isfresh
"$o" "$cmd$(eval $keycmd)" ||
{
91 printf "%*.s%s -> %s\n" $n '' "${s#$srcd/}" "$o"
93 echo "k='$cmd$(eval $keycmd)'" >"$o.past"
94 } && vecho
"fresh '$o'"
102 test ${wocmi%help.cmo} != $wocmi && {
106 test "$o" = "$wocmi" && s
=$srcd/${o%.cmo}.ml || s
=$srcd/$wocmi.mli
109 incs
="-I lablGL -I $outd/lablGL -I $wsi -I $outd/$wsi -I $outd"
116 cmd
="ocamlc -ccopt \"$(cflags $o) -MMD -MF $o.dep -MT_ -o $o\" $s"
117 test -r $o.dep
&& read _ d
<$o.dep || d
=
118 keycmd
='digest $o $d'
119 isfresh
"$o" "$cmd$(eval $keycmd)" ||
{
120 printf "%s -> %s\n" "${s#$srcd/}" "$o"
123 echo "k='$cmd$(eval $keycmd)'" >"$o.past"
124 } && vecho
"fresh $o"
130 cmd
="$mcomp $(mflags $o) -MMD -MF $o.dep -MT_ -c -o $o $s"
131 test -r $o.dep
&& read _ d
<$o.dep || d
=
132 keycmd
='digest $o $d'
133 isfresh
"$o" "$cmd$(eval $keycmd)" ||
{
134 printf "%s -> %s\n" "${s#$srcd/}" "$o"
137 echo "k='$cmd$(eval $keycmd)'" >"$o.past"
138 } && vecho
"fresh $o"
142 mkdir
-p $outd/lablGL
146 ocaml str.cma
-stdin $srcd/KEYS
<<EOF
147 let fixup = let open Str in
148 let dash = regexp {|\([^ ]*\) +- +\(.*\)|}
149 and head = regexp {|-----\(.*\)-----|} in fun s ->
150 String.escaped s |> global_replace dash {|\1\t\2|}
151 |> global_replace head {|\xc2\xb7\1|};;
152 let rec iter ic = match input_line ic with
153 | s -> Printf.printf "\"%s\";\\n" @@ fixup s; iter ic
154 | exception End_of_file -> ();;
155 Printf.printf "let keys = [\\n";
156 iter @@ open_in Sys.argv.(1);;
157 Printf.printf "] and version = \"$ver\";;"
161 ver
=$
(cd $srcd && git describe
--tags --dirty) ||
echo unknown
162 cmd
="mkhelp >$outd/help.ml"
163 keycmd
="digest $srcd/KEYS; echo $ver"
164 isfresh
"$outd/help.ml" '$cmd$(eval $keycmd)$ver' ||
{
166 echo "k='$cmd$(eval $keycmd)$ver'" >"$outd/help.ml.past"
167 } && vecho
"fresh $outd/help.ml"
173 for m
in llpp llppac llpphtml
; do
177 keycmd
="digest $xml $man"
178 conf
="$srcd/man/asciidoc.conf"
179 cmd
="asciidoc -d manpage -b docbook -f $conf -o '$xml' '$man'"
180 isfresh
"$xml" "$cmd$(eval $keycmd)" ||
{
182 echo "k='$cmd$(eval $keycmd)'" >"$md/$m.past"
184 keycmd
="digest $out $xml"
185 cmd
="xmlto man -o $md $xml"
186 isfresh
"$out" "$cmd$(eval $keycmd)" ||
{
188 echo "k='$cmd$(eval $keycmd)'" >"$out.past"
195 # following is disgusting (from "generalize everything" perspective),
196 # but generic method of derviving .ml's location from .mli's is not
197 # immediately obvious
198 for m
in lablGL
/glMisc.cmo lablGL
/glTex.cmo
$wsi/wsi.cmo main.cmo
; do
204 libs
="str.cma unix.cma"
205 clibs
="-L$mudir/build/native -lmupdf -lmupdfthird -lpthread"
207 mcomp
=$
(ocamlc
-config |
grep bytecomp_c_co |
{ read _ c
; echo $c; })
208 clibs
="$clibs -framework Cocoa -framework OpenGL"
210 cobjs
="$cobjs $outd/main_osx.o"
212 clibs
="$clibs -lGL -lX11"
216 for f
in ml_gl ml_glarray ml_raw
; do
218 globjs
="$globjs $outd/lablGL/$f.o"
221 ord
=$
(echo $
(grep -v \.cmi
$outd/ordered
))
222 cmd
="ocamlc -custom $libs -o $outd/llpp $cobjs $ord"
223 cmd
="$cmd $globjs -cclib \"$clibs\""
224 keycmd
="digest $outd/llpp $outd/link.o $ord"
225 isfresh
"$outd/llpp" "$cmd$(eval $keycmd)" ||
{
226 echo linking
$outd/llpp
227 eval $cmd ||
echo "$cmd failed"
228 echo "k='$cmd$(eval $keycmd)'" >"$outd/llpp.past"
229 } && vecho
"fresh llpp"
232 out
="$outd/llpp.app/Contents/Info.plist"
233 keycmd
="digest $out $srcd/misc/Info.plist.sh"
234 isfresh
$out "$(eval $keycmd)" ||
{
235 shortver
=$
(echo $ver |
{ IFS
='-' read s _
; echo ${s#v}; })
237 test -d "$d" || mkdir
-p "$d"
238 .
$srcd/misc
/Info.plist.sh
>"$out"
239 echo "k=$(eval $keycmd)" >"$out.past"
240 } && vecho
"fresh plist"
242 out
=$outd/llpp.app
/Contents
/MacOS
/llpp
243 keycmd
="digest $out $outd/llpp"
244 isfresh
$out "$(eval $keycmd)" ||
{
248 echo "k=$(eval $keycmd)" >"$out.past"
249 } && vecho
"fresh bundle"