-
Notifications
You must be signed in to change notification settings - Fork 3
/
wsc2-gcc
executable file
·88 lines (73 loc) · 2.05 KB
/
wsc2-gcc
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
#!/bin/bash
if [ "$CFILE" = "" ];
then CFILE=query.c
fi
# Currently, this script is only called for wsc2, so we insist that -DWSC2 be included in the flags.
#WS_LINK+=" -DWSC2 "
WS_LINK="$WS_LINK -DWSC2 "
FIRST=`head -n1 "$CFILE"`
MATCH=`echo $FIRST | grep "^//WSLIBDEPS:"`
if [ "$MATCH" != "" ];
then
EXTRALIBS=`echo $FIRST | sed "s/\/\/WSLIBDEPS://"`
WS_LINK="$WS_LINK $EXTRALIBS"
if [ "$REGIMENT_QUIET" == "" ];
then echo Linking extra libraries requested by query file: $EXTRALIBS;
fi
fi
#========================================
if [ "$COPTFLAG" == "" ]; then COPTFLAG=0; fi
case "$COPTFLAG" in
--O1 | O1 | 1 )
OPTFLAGS=""
;;
--O2 | O2 | 2 )
OPTFLAGS="-O2 ";
;;
--O3 | O3 | 3 )
# max-unroll-times Seems to be 8 by default.
OPTFLAGS="-O3 -funroll-loops --param max-unroll-times=16 ";
;;
--O0 | --dbg | dbg | O0 | 0 )
OPTFLAGS="-g -O0";;
*)
echo WARNING: UNMATCHED OPT FLAG: \"$COPTFLAG\"
## DEBUG MODE:
OPTFLAGS="-g -O0";;
esac
# Default to gcc:
if [ "$CC" = "" ];
then CC="gcc $OPTFLAGS";
elif [ "$CC" = "gcc" ];
then CC="gcc $OPTFLAGS";
elif [ "$CC" = "icc" ];
then CC="icc $OPTFLAGS";
#else echo "Using alternate C compiler $CC.";
fi
WS_LINK_POST=""
# Only the libraries should be included again at the end:
for lnk in $WS_LINK; do
if [ "${lnk:0:2}" = "-l" ]
then WS_LINK_POST+=" $lnk "
fi
done
EXEFILE=`echo $CFILE | sed 's/\.c$/.exe/'`
## ACK - include WS_LINK at front and end?!?
CMD="$CC $WS_LINK -lm -I $REGIMENTD/lib -I $REGIMENTD/src/linked_lib -o $EXEFILE $CFILE $WS_LINK_POST -lm"
if [ "$REGIMENT_QUIET" == "" ];
then echo "$CMD"
fi
#if gcc -I$TOSROOT/support/sdk/c -L$TOSROOT/support/sdk/c -lmote -I$TOSROOT/support/sdk/c/tos/types/ -lm -g -O0 -o query.exe query.c -I$TOSROOT/support/sdk/c -L$TOSROOT/support/sdk/c -lmote -I$TOSROOT/support/sdk/c/tos/types/
if [ "$REGIMENT_QUIET" == "" ]; then
if time $CMD;
then echo Compiled .c output successfully.
wc $CFILE
else echo ERROR, C compiler failed.;
exit 1
fi
else
if ! $CMD;
then echo ERROR, C compiler failed.;
exit 1
fi
fi