-
Notifications
You must be signed in to change notification settings - Fork 3
/
RaiiBuild.sh
executable file
·84 lines (64 loc) · 1.84 KB
/
RaiiBuild.sh
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
#! /bin/bash
#CPLUSPLUS=clang++
#CPLUSPLUSFLAGS="-std=gnu++0x"
CPLUSPLUS=c++
if getconf GNU_LIBPTHREAD_VERSION | grep NPTL >/dev/null ; then
HAVE_TLS="-DHAVE_TLS"
else
HAVE_TLS=""
fi
if [ -z "$HAVE_TLS" ] ; then
TLS_SUFFIX="tsd"
else
TLS_SUFFIX="tls"
fi
#NO_INLINE="-fno-inline -DNO_INLINE"
NO_INLINE="-fno-inline"
#NO_INLINE=
#RAIIDIR=/home/guigui/sa/raii/libapache2-mod-raii
RAIIDIR=/usr/include/raii
CPLUSPLUSFLAGS="$CPLUSPLUSFLAGS -march=native -mfpmath=sse $HAVE_TLS $NO_INLINE -D_REENTRANT -D_GNU_SOURCE -ggdb3 -fPIC -DPIC -I$RAIIDIR -I `apxs2 -q INCLUDEDIR` `apr-config --includes` `apxs2 -q CFLAGS` `apr-config --cppflags` `apr-config --cflags` -Wall"
LINKFLAGS="-Wl,-E -fPIC `apxs2 -q CFLAGS_SHLIB` -shared"
if [ $# -eq 0 ] ; then
echo "$CPLUSPLUS"
exit 0
fi
if [ "$1" = "--cplusplusflags" ] ; then
echo "-I.. $CPLUSPLUSFLAGS"
exit 0
fi
if [ "$1" = "--linkflags" ] ; then
echo "$LINKFLAGS -lraii"
exit 0
fi
ARCH="$1"
TMPDIR="$2"
DSODIR="$3"
RAIIFILE="$4"
CFILE="${TMPDIR}/${RAIIFILE}.C"
DATE=$(stat -c %Y "$RAIIFILE")
SOFILE="${DSODIR}/${RAIIFILE}.${TLS_SUFFIX}.${ARCH}.so.${DATE}"
BUILDOPT="$(dirname $RAIIFILE)/.build"
if [ -r "$BUILDOPT" ] ; then
BUILD_ADDITION="$(cat "$BUILDOPT")"
BUILD_ADDITION="$(eval "echo \"$BUILD_ADDITION\"")"
CPLUSPLUSFLAGS="$BUILD_ADDITION $CPLUSPLUSFLAGS"
fi
mkdir -p "$(dirname "$CFILE")" "$(dirname "$SOFILE" )"
if [ "$SOFILE" -nt "$RAIIFILE" ] ; then
echo "$0: « $SOFILE » is up to date." >&2
exit 0
fi
rm -f "$SOFILE" "$CFILE"
if [ "${RAIIFILE//*./}" = "csp" ] ; then
raiipp "$RAIIFILE" "$CFILE"
RET=$?
if [ $RET -ne 0 ] ; then
exit $RET
fi
else
CFILE="$RAIIFILE"
fi
TICKET=$(dd if=/dev/urandom bs=1 count=8 2>/dev/null | hexdump -v -e '/1 "%02X"')
$CPLUSPLUS "-DRAIIMARK(name)=Servlet_${TICKET}_ ## name" $CPLUSPLUSFLAGS $LINKFLAGS -o "$SOFILE" "$CFILE"
exit $?