Skip to content

Commit

Permalink
Fix ruby detection script to be Debian and CentOS compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
rescrv committed Feb 10, 2014
1 parent 126b256 commit 86bcc2f
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions m4/ax_ruby_ext.m4
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ AC_DEFUN([AX_RUBY_EXT],[
#
# Check for Ruby extensions include path.
#
ruby_use_rubyhdrdir=yes
AC_ARG_VAR(RUBY_EXT_INC, [Directory to include ruby headers from])
AC_MSG_CHECKING([for Ruby headers include path])
if test -z "$RUBY_EXT_INC" ; then
[RUBY_EXT_INC=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'`];
[RUBY_EXT_INC=`$RUBY -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]' 2>/dev/null`];
if test x"$RUBY_EXT_INC" = xnil ; then
[RUBY_EXT_INC=`$RUBY -rrbconfig -e 'puts Config::CONFIG["archdir"]' 2>/dev/null`];
ruby_use_rubyhdrdir=no;
fi
fi
AC_MSG_RESULT([$RUBY_EXT_INC])
AC_SUBST(RUBY_EXT_INC)
Expand All @@ -97,7 +102,11 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_ARCHINC, [Another directory to include ruby headers from])
AC_MSG_CHECKING([for other Ruby headers include path])
if test -z "$RUBY_EXT_ARCHINC" ; then
[RUBY_EXT_ARCHINC=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"] + "/" + RbConfig::CONFIG["arch"]'`];
if test x"${ruby_use_rubyhdrdir}" = xyes ; then
[RUBY_EXT_ARCHINC=`$RUBY -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"] + "/" + Config::CONFIG["arch"]' 2>/dev/null`];
else
[RUBY_EXT_ARCHINC=`$RUBY -rrbconfig -e 'puts Config::CONFIG["sitearchdir"]' 2>/dev/null`];
fi
fi
AC_MSG_RESULT([$RUBY_EXT_ARCHINC])
AC_SUBST(RUBY_EXT_ARCHINC)
Expand All @@ -108,7 +117,7 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_CPPFLAGS, [CPPFLAGS to compile Ruby extensions])
AC_MSG_CHECKING([for Ruby extensions C preprocessor flags])
if test -z "$RUBY_EXT_CPPFLAGS" ; then
[RUBY_EXT_CPPFLAGS=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["CPPFLAGS"]'`];
[RUBY_EXT_CPPFLAGS=`$RUBY -rrbconfig -e 'puts Config::CONFIG["CPPFLAGS"]' 2>/dev/null`];
fi
AC_MSG_RESULT([$RUBY_EXT_CPPFLAGS])
AC_SUBST(RUBY_EXT_CPPFLAGS)
Expand All @@ -119,7 +128,7 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_LDFLAGS, [LDFLAGS to build Ruby extensions])
AC_MSG_CHECKING([for Ruby extensions linker flags])
if test -z "$RUBY_EXT_LDFLAGS" ; then
[RUBY_EXT_LDFLAGS=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["LDFLAGS"]'`];
[RUBY_EXT_LDFLAGS=`$RUBY -rrbconfig -e 'puts Config::CONFIG["LDFLAGS"]' 2>/dev/null`];
fi
# Fix LDFLAGS for OS X. We don't want any -arch flags here, otherwise
# linking might fail. We also including the proper flags to create a bundle.
Expand All @@ -138,7 +147,7 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_DLEXT, [Ruby dynamic library extension])
AC_MSG_CHECKING([for Ruby dynamic library extension])
if test -z "$RUBY_EXT_DLEXT" ; then
[RUBY_EXT_DLEXT=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]'`];
[RUBY_EXT_DLEXT=`$RUBY -rrbconfig -e 'puts Config::CONFIG["DLEXT"]' 2>/dev/null`];
RUBY_EXT_DLEXT=".${RUBY_EXT_DLEXT}"
fi
AC_MSG_RESULT([$RUBY_EXT_DLEXT])
Expand All @@ -150,7 +159,7 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_SITEARCH, [Ruby site arch dir])
AC_MSG_CHECKING([for Ruby extensions site arch dir])
if test -z "$RUBY_EXT_SITEARCH" ; then
[RUBY_EXT_SITEARCH=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]'`];
[RUBY_EXT_SITEARCH=`$RUBY -rrbconfig -e 'puts Config::CONFIG["sitearchdir"]' 2>/dev/null`];
elif test -z "$RUBY_EXT_LIB" ; then
[RUBY_EXT_LIB="${RUBY_EXT_SITEARCH}"];
fi
Expand All @@ -163,7 +172,7 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_VENDORARCH, [Ruby vendor arch dir])
AC_MSG_CHECKING([for Ruby extensions vendor arch dir])
if test -z "$RUBY_EXT_VENDORARCH" ; then
[RUBY_EXT_VENDORARCH=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]'`];
[RUBY_EXT_VENDORARCH=`$RUBY -rrbconfig -e 'puts Config::CONFIG["vendorarchdir"]' 2>/dev/null`];
elif test -z "$RUBY_EXT_LIB" ; then
[RUBY_EXT_LIB="$RUBY_EXT_VENDORARCH"];
fi
Expand All @@ -172,14 +181,14 @@ AC_DEFUN([AX_RUBY_EXT],[
AC_ARG_VAR(RUBY_EXT_LIB, [Ruby extension dir])
if test -z "$RUBY_EXT_LIB" ; then
if test -n "$prefix" && echo $RUBY_EXT_VENDORARCH | sed -e "s:^${prefix}:.:" | grep '^\.' >/dev/null; then
if test -n "$prefix" && echo $RUBY_EXT_VENDORARCH | sed -e "s:^${prefix}:.:" | grep '^\.' >/dev/null 2>/dev/null; then
RUBY_EXT_LIB=$RUBY_EXT_VENDORARCH
elif test -n "$prefix" && echo $RUBY_EXT_SITEARCH | sed -e "s:^${prefix}:.:" | grep '^\.' >/dev/null; then
elif test -n "$prefix" && echo $RUBY_EXT_SITEARCH | sed -e "s:^${prefix}:.:" | grep '^\.' >/dev/null 2>/dev/null; then
RUBY_EXT_LIB=$RUBY_EXT_SITEARCH
elif echo $RUBY_EXT_VENDORARCH | sed -e "s:^${ac_default_prefix}:.:" | grep '^\.' >/dev/null; then
RUBY_EXT_LIB='$(prefix)'/`echo $RUBY_EXT_VENDORARCH | sed -e "s:^${ac_default_prefix}:.:"`
elif echo $RUBY_EXT_SITEARCH | sed -e "s:^${ac_default_prefix}:.:" | grep '^\.' >/dev/null; then
RUBY_EXT_LIB='$(prefix)'/`echo $RUBY_EXT_SITEARCH | sed -e "s:^${ac_default_prefix}:.:"`
elif echo $RUBY_EXT_VENDORARCH | sed -e "s:^${ac_default_prefix}:.:" | grep '^\.' >/dev/null 2>/dev/null; then
RUBY_EXT_LIB='$(prefix)'/`echo $RUBY_EXT_VENDORARCH | sed -e "s:^${ac_default_prefix}:.:" 2>/dev/null`
elif echo $RUBY_EXT_SITEARCH | sed -e "s:^${ac_default_prefix}:.:" | grep '^\.' >/dev/null 2>/dev/null; then
RUBY_EXT_LIB='$(prefix)'/`echo $RUBY_EXT_SITEARCH | sed -e "s:^${ac_default_prefix}:.:" 2>/dev/null`
fi
fi
if test -z "$RUBY_EXT_LIB" ; then
Expand Down

0 comments on commit 86bcc2f

Please sign in to comment.