Revert "Hummm..."
[llpp.git] / doocaml.sh
blobf4651f5e26ce9e80da13beedd11e67c742e6665e
1 #!/bin/sh
2 set -e
4 compiler="$1"
5 out="$2"
6 in="$3"
7 outdir="$(dirname "$out")"
8 srcdir="$(pwd -P)"
10 shift 3
12 dodep ()
14 (cd >/dev/null $srcdir && ocamldep.opt ${1+"$@"} $(basename $in)) | \
15 (sed >$objdir/$out.d \
16 -e '/\(.cmx\|:$\)/d' \
17 -e 's;\([[:alnum:]\.]\+\);'$outdir'/\1;g')
20 test "x" = "x$pp" || {
21 ef=$(mktemp)
22 trap 'test -n "$ef" && rm -f "$ef"' 0
23 (cd >/dev/null $outdir && $compiler -pp "$pp" $incs 2>$ef "$@" -o $out $in)
24 rc=$?
25 if test "$rc" != 0; then
26 sed 1>&2 "s;File \"\([^\"]*\)\"\(.*\)$;File $in\2;" $ef
27 else
28 dodep -pp "$pp"
30 exit $rc
31 } && {
32 (cd >/dev/null $outdir && $compiler "$@" $incs -o $out $in) && dodep