3 # dtrace-prelink.sh: DTrace helper script for Mono
6 # Andreas Faerber <andreas.faerber@web.de>
9 # Assume that PIC object files live in .libs/, non-PIC code in ./
11 if test "$1" = "--pic"; then
28 # Extract relevant object files to temporary directories
29 for FILE
in ${FILES}; do
30 if echo "${FILE}" |
grep .la
> /dev
/null
; then
31 LIBDIR
=`dirname ${FILE}`
32 LIB
=".libs/`basename ${FILE} .la`.a"
33 DIR
="${TMPDIR}/`basename ${FILE}`"
35 (cd "${DIR}" && ${AR} x "../../${LIBDIR}/${LIB}")
36 TMPOBJS
=`ls -1 "${DIR}"`
37 for TMPOBJ
in ${TMPOBJS}; do
38 LO
=`basename "${TMPOBJ}" .o`.lo
40 if test x
${PIC} = xyes
; then
41 SRCOBJ
=".libs/${SRCOBJ}"
43 # Overwrite with original version
44 cp "${LIBDIR}/${SRCOBJ}" "${DIR}/${TMPOBJ}" || cp "${LIBDIR}/${TMPOBJ}" "${DIR}/${TMPOBJ}" ||
exit
46 OBJS
="${OBJS} ${DIR}/${TMPOBJ}"
49 if echo "${FILE}" |
grep .lo
> /dev
/null
; then
51 SRCOBJ
=`basename ${FILE} .lo`.o
52 if test x
${PIC} = xyes
; then
53 SRCOBJ
=".libs/${SRCOBJ}"
55 OBJS
="${OBJS} ${DIR}/${SRCOBJ}"
59 # Run dtrace -G over the temporary objects
60 ${DTRACE} -G ${DTRACEFLAGS} -s "${PROV}" -o "${OBJ}" ${OBJS} ||
exit
62 # Update the archives with the temporary, modified object files so that they are linked in
63 for FILE
in ${FILES}; do
64 if echo "${FILE}" |
grep .la
> /dev
/null
; then
65 LIBDIR
=`dirname ${FILE}`
66 LIB
=".libs/`basename ${FILE} .la`.a"
67 DIR
="${TMPDIR}/`basename ${FILE}`"
68 (cd "${DIR}" && ${AR} r "../../${LIBDIR}/${LIB}" *.o
)
70 # .lo files were modified in-place