5 # This script adds a new crosscompiler target for MLton.
7 # It takes four arguments.
9 # 1. <crossTarget>, which is what MLton would pass via the -b flag to the GCC
10 # cross-compiler tools. You don't need to have installed these tools in order
11 # to run this script, since it uses ssh and the native gcc on the target.
12 # Examples of $crossTarget are i386-pc-cygwin and sparc-sun-solaris.
14 # 2. <crossArch> specifies the target architecture.
16 # 3. <crossOS> specifies the target OS.
18 # 4. <machine> specifies a remote machine of the target type. This script
19 # will ssh to $machine to compile the runtime and to compile and run the
20 # program that will print the values of all the constants that the MLton
21 # basis library needs.
23 # Here are some example uses of this script.
25 # add-cross i386-pc-cygwin x86 cygwin cygwin
26 # add-cross sparc-sun-solaris sparc solaris blade
28 # (Here cygwin happens to be the name of my Cygwin machine and blade
29 # happens to be the name of my Sparc machine.)
31 # You also may need to set $libDir, which determines where the
32 # cross-compiler target will be installed.
40 die
"usage: $name <crossTarget> <crossArch> <crossOS> <machine>"
58 src
=`cd "$dir/.." && pwd`
62 # libDir is the mlton lib directory where you would like the
63 # cross-compiler information to be installed. If you have installed
64 # from the rpms, this will usually be /usr/lib/mlton. You must have
65 # write permission there.
67 lib
="$src/build/lib/mlton"
69 # You shouldn't need to change anything below this line.
71 rm -rf "$lib/targets/$crossTarget"
72 mkdir
-p "$lib/targets/$crossTarget" || die
"Cannot write to $lib."
74 tmp
='/tmp/mlton-add-cross'
77 mmake TARGET
=$crossTarget TARGET_ARCH
=$crossArch TARGET_OS
=$crossOS \
80 ssh $machine "rm -rf $tmp && mkdir $tmp"
83 ( cd "$src" && tar cf
- --exclude '*.o' --exclude '*.a' Makefile basis-library bin include runtime
) |
84 ssh $machine "cd $tmp && tar xf - &&
85 if [ ! $crossArch == \`./bin/host-arch\` ]; then echo $machine is \`./bin/host-arch\`, not $crossArch; exit 1; fi &&
86 if [ ! $crossOS == \`./bin/host-os\` ]; then echo $machine is \`./bin/host-os\`, not $crossOS; exit 1; fi"
88 echo "Making runtime on $machine."
89 ssh $machine "cd $tmp && ./bin/mmake CPPFLAGS=\"$CPPFLAGS\" LDFLAGS=\"$LDFLAGS\" COMPILE_FAST=yes OMIT_BYTECODE=yes clean dirs runtime"
91 ssh $machine "cd $tmp/build/lib/targets/self && tar cf - ." |
92 ( cd "$lib/targets/$crossTarget" && tar xf
- )
94 mmake TARGET
=$crossTarget TARGET_ARCH
=$crossArch TARGET_OS
=$crossOS \
106 # Copied from mlton-script
133 osOpts
='-I/usr/local/include -I/opt/local/include -I/sw/include -L/usr/local/lib -L/opt/local/lib -L/sw/lib'
136 osOpts
='-I/usr/local/include -L/usr/local/lib/'
148 libs
='-lws2_32 -lkernel32 -lpsapi -lnetapi32 -lwinmm'
151 osOpts
='-I/usr/pkg/include -Wl,-R/usr/pkg/lib -L/usr/pkg/lib/'
154 osOpts
='-I/usr/local/include -L/usr/local/lib/'
157 osOpts
='-lnsl -lsocket -lrt'
161 exe
='print-constants'
162 echo "Compiling and running print-constants on $machine."
163 "$src/build/bin/mlton" -target $crossTarget -build-constants true |
164 ssh $machine "cd $tmp/runtime &&
166 gcc $archOpts $osOpts $CPPFLAGS -I. -o $exe $exe.c libmlton.a libgdtoa.a $LDFLAGS -lgmp -lm"
167 ssh $machine "$tmp/runtime/$exe$suf" >"$lib/targets/$crossTarget/constants"
168 ssh $machine "rm -rf $tmp"