|
root / lang / ocaml-fmt / build.sh
build.sh Bash 44 lines 1.3 KB
 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
37
38
39
40
41
42
43
#!/bin/zsh
# Build script for OCaml fmt library
set -e
cd "$SRCDIR"

export PATH="$PREFIX/bin:$PATH"
export LD_LIBRARY_PATH="/usr/lib:${LD_LIBRARY_PATH:-}"
export LIBRARY_PATH="/usr/lib:${LIBRARY_PATH:-}"

# Build with topkg
ocaml pkg/pkg.ml build

# Install from .install file without opam-installer
install_from_dotinstall() {
    local installfile="$1" prefix="$2" pkgname="$3"
    local section="" src dest dir
    while IFS= read -r line; do
        if [[ "$line" =~ '^([a-z_]+):' ]]; then
            section="${match[1]}"
            continue
        fi
        [[ -z "$section" || "$line" =~ '^\]' ]] && { [[ "$line" =~ '^\]' ]] && section=""; continue; }
        src="${${line#*\"}%%\"*}"
        [[ -z "$src" || ! -f "$src" ]] && continue
        if [[ "$line" =~ '\{"?([^}"]+)"?\}' ]]; then
            dest="${match[1]}"
        else
            dest="${src:t}"
        fi
        case "$section" in
            lib|libexec) dir="$prefix/lib/ocaml/$pkgname" ;;
            bin) dir="$prefix/bin" ;;
            share) dir="$prefix/share/$pkgname" ;;
            doc) dir="$prefix/doc/$pkgname" ;;
            man) dir="$prefix/man" ;;
            *) continue ;;
        esac
        mkdir -p "$dir/$(dirname "$dest")"
        cp "$src" "$dir/$dest"
    done < "$installfile"
}

install_from_dotinstall fmt.install "$PKGDIR$PREFIX" fmt