-
Notifications
You must be signed in to change notification settings - Fork 3
/
wsmlton-secondphase-ensbox
executable file
·97 lines (80 loc) · 2.81 KB
/
wsmlton-secondphase-ensbox
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
#!/bin/bash
# This takes the .sml file down to a binary.
# RRN: Not using this ensbox source method any more:
# export WSMLCINCLUDES="$WSMLCINCLUDES $REGIMENTD/src/ws/passes/mlton_bkend/ensbox_new.c"
GLIB_PATH=`pkg-config glib-2.0 --libs`
if [ "$EMLIB" == "" ]; then export EMLIB='/scratch/girod/emstar'; fi
# "a" for static linking "so" for dynamic:
EXT=a
if [ "$EMLIBLIB" == "" ]; then export EMLIBLIB=$EMLIB/obj.nims-stargate/lib ; fi
export EMLIBH=$EMLIB/include
export ENSBOXLD=" \
$EMLIBLIB/libwavescope2.$EXT \
$EMLIBLIB/libvxp_ws.$EXT \
$EMLIBLIB/libemrun.$EXT \
$EMLIBLIB/liblink.$EXT \
$EMLIBLIB/libdev.$EXT \
$EMLIBLIB/libsync.$EXT \
$EMLIBLIB/libevent.$EXT \
$EMLIBLIB/libdev.$EXT \
$EMLIBLIB/libmisc.$EXT \
$EMLIBLIB/libfusd.$EXT \
$EMLIBLIB/libremstore.$EXT \
$EMLIBLIB/libmisc.$EXT \
-lm -lasound $GLIB_PATH \
"
rm -f query.*.c
rm -f .tmp.*.o
export MLTONARGS="$MLTONARGS -codegen c -stop g "
## RRN [2007.08.16] Changing this to O3!!!
if [ "$WSMLGCC" == "" ]; then
echo MLton cross compile to ARM ENSbox. Setting up environment.;
export PATH=$PATH:/usr/arm-linux/bin;
export WSMLGCC=arm-linux-gcc;
export GCCLINK=' -L/usr/arm-linux/lib -L/usr/lib/mlton/arm-linux -lmlton -lgdtoa -lm -lgmp -lfftw3f '
export GCCBUILD="-I/usr/arm-linux/include -std=gnu99 -I/usr/lib/mlton/arm-linux/include \
-I/usr/lib/mlton/include -O3 -fno-strict-aliasing \
-I$EMLIBH \
-fomit-frame-pointer -w \
-I$REGIMENTD/src/ws/passes/mlton_bkend"
fi
## Now call the vanilla version:
export WSMLOUTPUT='query._.c'
source wsmlton-secondphase $*
export WSMLOUTPUT=query.ensbox.mlton.exe
shift
echo;echo ARGS $*; echo
# if [ "$1" == "-dbg" ]; then
# echo Configuring GCC for debug mode.
# export GCCLINK="$GCCLINK -g";
# export GCCBUILD="$GCCBUILD -g";
# fi
#echo; echo; echo "OUT OF WSMLTON-SECONDPHASE, WSMLCINCLUDES = $WSMLCINCLUDES"
#echo "AND PATH: $PATH"; echo; echo
################################################################################
echo "Beginning GCC cross compile (foreign and mlton-generated C code)."
start=`date +%s`
FILES=`ls query.*.c`
OBJS=''
for fn in $FILES $WSMLCINCLUDES
do
# RRN:
# HACKING these calls to gcc in here directly.
# The reason for this is that the machines I'm working on (breeze, patridge)
# don't support "gcc -b" for some reason.
echo " Compiling $fn"
OBJ=".tmp.`basename $fn`.o"
OBJS="$OBJS $OBJ"
$WSMLGCC $GCCBUILD -c -o $OBJ $fn
done
echo
echo "Now Linking: $OBJS"
LINKEXEC="$WSMLGCC -o $WSMLOUTPUT $OBJS $GCCLINK $ENSBOXLD"
#echo " $LINKEXEC"
if $LINKEXEC
then end=`date +%s`;
echo
echo " Time spent in gcc compiler: "$[($end) - ($start)]" second(s)";
echo "MLton/GCC output to $WSMLOUTPUT.";
else echo "gcc returned error!!"; exit -1
fi