File: mlton-script

package info (click to toggle)
mlton 20070826-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 33,184 kB
  • ctags: 70,419
  • sloc: ansic: 16,154; lisp: 2,727; makefile: 1,635; sh: 1,234; pascal: 256; asm: 97
file content (112 lines) | stat: -rw-r--r-- 4,020 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash

# This script calls MLton.

set -e

dir=`dirname "$0"`
lib=`cd "$dir/../lib" && pwd`
eval `"$lib/platform"`
gcc='gcc'
case "$HOST_OS" in
mingw)
	exe='.exe'
;;
*)
	exe=''
;;
esac
mlton="$lib/mlton-compile$exe"
world="$lib/world.mlton"
nj='sml'
# Try to use the SML/NJ .arch-n-opsys
if .arch-n-opsys >/dev/null 2>&1; then
        eval `.arch-n-opsys`
        njHeap="$lib/mlton.$HEAP_SUFFIX"
        unset `.arch-n-opsys | sed 's#=[^ ]*##g'`
else
        njHeap="$lib/mlton.$HOST_ARCH-$HOST_OS"
fi

declare -a rargs
case "$1" in
@MLton)
        shift
        while [ "$#" -gt 0 -a "$1" != "--" ]; do
                rargs[${#rargs[@]}]="$1"
                shift
        done
        if [ "$#" -gt 0 -a "$1" == "--" ]; then
                shift
        else    
                echo '@MLton missing --'
                exit 1
        fi
        ;;
esac

# If $mlton is executable and $world exists and is not older than
# $njHeap (which exists), then use MLton, otherwise use SML/NJ.
doit () {
        if [ -x "$mlton" -a -s "$world" -a ! "$njHeap" -nt "$world" ]; then
                exec "$mlton" @MLton load-world "$world" ram-slop 0.5 "${rargs[@]}" -- "$@"
        elif [ -s "$njHeap" ]; then
                exec "$nj" @SMLload="$njHeap" "$@"
        fi
        echo 'Unable to run MLton.  Check that lib is set properly.' >&2
        exit 1
}

# For align-{functions,jumps,loops}, we use -m for now instead of
# -f because old gcc's will barf on -f, while newer ones only warn
# about -m.  Someday, when we think we won't run into older gcc's,
# these should be changed to -f.

# You may need to add a line with -cc-opt 'I/path/to/gmp.h' so the
# C compiler can find gmp.h
# You may need to add a line with -link-opt '-L/path/to/libgmp' so
# that the linker can find libgmp.

# The darwin linker complains (loudly) about non-existent library
# search paths.
darwinLinkOpts=''
if [ -d '/opt/local/lib' ]; then
        darwinLinkOpts="$darwinLinkOpts -L/opt/local/lib"
fi
if [ -d '/sw/lib' ]; then
        darwinLinkOpts="$darwinLinkOpts -L/sw/lib"
fi

doit "$lib" \
        -cc "$gcc"                                               \
        -cc-opt-quote "-I$lib/include"                           \
        -cc-opt '-O1'                                            \
        -cc-opt '-fno-strict-aliasing -fomit-frame-pointer -w'   \
        -link-opt '-lgdtoa -lm -lgmp'                            \
        -mlb-path-map "$lib/mlb-path-map"                        \
        -target-as-opt amd64 '-m64'                              \
        -target-cc-opt amd64 '-m64'                              \
        -target-cc-opt darwin                                    \
                '-I/opt/local/include -I/sw/include'             \
        -target-cc-opt freebsd '-I/usr/local/include'            \
        -target-cc-opt netbsd '-I/usr/pkg/include'               \
        -target-cc-opt openbsd '-I/usr/local/include'            \
        -target-cc-opt sparc '-m32 -mcpu=v8 -Wa,-xarch=v8plusa'  \
        -target-cc-opt x86                                       \
                '-fno-strength-reduce
                -fschedule-insns
                -fschedule-insns2
                -malign-functions=5
                -malign-jumps=2
                -malign-loops=2'                                 \
        -target-link-opt amd64 '-m64'                            \
        -target-link-opt darwin "$darwinLinkOpts"                \
        -target-link-opt freebsd '-L/usr/local/lib/'             \
        -target-link-opt mingw                                   \
                '-lws2_32 -lkernel32 -lpsapi -lnetapi32'         \
        -target-link-opt netbsd                                  \
                '-Wl,-R/usr/pkg/lib -L/usr/pkg/lib/'             \
        -target-link-opt openbsd '-L/usr/local/lib/'             \
        -target-link-opt solaris '-lnsl -lsocket -lrt'           \
        -profile-exclude '\$\(SML_LIB\)'                         \
        "$@"