| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
top_builddir=$1 |
| 4 |
top_srcdir=$2 |
| 5 |
option=$3 |
| 6 |
|
| 7 |
gc_makefile=${top_builddir}/gc/Makefile |
| 8 |
gc_config=${top_builddir}/gc/include/config.h |
| 9 |
|
| 10 |
if [ ! -e "$gc_makefile" ]; then |
| 11 |
echo "$gc_makefile doesn't exist---you have to run configure script." |
| 12 |
exit 1 |
| 13 |
fi |
| 14 |
|
| 15 |
case $option in |
| 16 |
--cflags) |
| 17 |
cflags=`sed -n -e 's@ATOMIC_OPS_CFLAGS =\(.*\)@\1@p' $gc_makefile` |
| 18 |
sed_text1='$(top_builddir)' |
| 19 |
sed_text2=`echo "${top_builddir}/gc" | sed -e 's/[\@&]/\\&/g'` |
| 20 |
cflags=`echo "$cflags" | sed -e "s@$sed_text1@$sed_text2@"` |
| 21 |
sed_text1='$(top_srcdir)' |
| 22 |
sed_text2=`echo "${top_srcdir}/gc" | sed -e 's/[\@&]/\\&/g'` |
| 23 |
cflags=`echo "$cflags" | sed -e "s@$sed_text1@$sed_text2@"` |
| 24 |
if grep 'define GC_BUILTIN_ATOMIC' $gc_config > /dev/null; then |
| 25 |
cflags="-DGC_BUILTIN_ATOMIC $cflags" |
| 26 |
fi |
| 27 |
echo $cflags |
| 28 |
;; |
| 29 |
--libs) |
| 30 |
sed -n -e 's@ATOMIC_OPS_LIBS =\(.*\)@\1@p' $gc_makefile |
| 31 |
;; |
| 32 |
*) |
| 33 |
echo "Usage: get-atomic-ops-flags.sh TOP_BUILDDIR TOP_SRCDIR --cflags|--libs" |
| 34 |
exit 1 |
| 35 |
;; |
| 36 |
esac |