dnl Get a key from ruby's configuration table AC_DEFUN([RUBY_CONFIG], [ $RUBY -rrbconfig -e "puts(Config::CONFIG[['$1']] || '')"]) AC_DEFUN([RB_INIT_RUBY], [ AC_ARG_WITH( ruby, AC_HELP_STRING( --with-ruby=PATH, [ path to the ruby interpreter [[ruby]] ]), [ RUBY=$withval ], [ RUBY=ruby ]) AC_ARG_WITH( ruby_sitelibdir, AC_HELP_STRING( --with-ruby-sitelibdir=PATH, [ path to install ruby scripts [[auto-detect]] ]), [ ruby_sitelibdir=$withval ], [ ruby_sitelibdir=NONE ]) AC_SUBST(RUBY) RUBY_VERSION_CODE=`$RUBY -e "puts RUBY_VERSION.gsub(/\./, '')"` AC_SUBST(RUBY_VERSION_CODE) RUBY_CONFIG_SO_NAME=`RUBY_CONFIG(RUBY_SO_NAME)` RUBY_CONFIG_ARCHDIR=`RUBY_CONFIG(archdir)` RUBY_CONFIG_ARCH=`RUBY_CONFIG(arch)` RUBY_CONFIG_LIBDIR=`RUBY_CONFIG(libdir)` RUBY_CONFIG_BINDIR=`RUBY_CONFIG(bindir)` RUBY_CONFIG_RUBYHDRDIR=`RUBY_CONFIG(rubyhdrdir)` RUBY_CONFIG_CFLAGS=`RUBY_CONFIG(CFLAGS)` RUBY_CONFIG_LIBS=`RUBY_CONFIG(LIBS)` RUBY_CONFIG_DLDLIBS=`RUBY_CONFIG(DLDLIBS)` RUBY_CONFIG_LDFLAGS=`RUBY_CONFIG(LDFLAGS)` RUBY_CONFIG_LIBRUBYARG=`RUBY_CONFIG(LIBRUBYARG)` RUBY_CONFIG_LIBRUBYARG_STATIC=`RUBY_CONFIG(LIBRUBYARG_STATIC)` RUBY_CONFIG_CCDLFLAGS=`RUBY_CONFIG(CCDLFLAGS)` if test "x${RUBY_CONFIG_RUBYHDRDIR}x" != "xx"; then # 1.9 RUBY_CPPFLAGS="-I${RUBY_CONFIG_RUBYHDRDIR}" RUBY_CPPFLAGS="${RUBY_CPPFLAGS} -I${RUBY_CONFIG_RUBYHDRDIR}/${RUBY_CONFIG_ARCH}" else # 1.8 RUBY_CPPFLAGS="-I${RUBY_CONFIG_ARCHDIR}" fi AC_SUBST(RUBY_CPPFLAGS) RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}" AC_SUBST(RUBY_CFLAGS) RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}" AC_SUBST(RUBY_CXXFLAGS) RUBY_LDFLAGS="-L${RUBY_CONFIG_ARCHDIR} -L${RUBY_CONFIG_LIBDIR} ${RUBY_CONFIG_LDFLAGS}" AC_SUBST(RUBY_LDFLAGS) RUBY_LIBS="${RUBY_CONFIG_LIBS} ${RUBY_CONFIG_DLDLIBS}" AC_SUBST(RUBY_LIBS) RUBY_LIBRUBYARG="${RUBY_CONFIG_LIBRUBYARG}" AC_SUBST(RUBY_LIBRUBYARG) RUBY_LIBRUBYARG_STATIC="${RUBY_CONFIG_LIBRUBYARG_STATIC}" AC_SUBST(RUBY_LIBRUBYARG_STATIC) dnl If the user specified a prefix, then use it, otherwise defalut to dnl the configured sitelibdir if test "x${ruby_sitelibdir}x" != "xNONEx" then RUBY_SITELIBDIR="${ruby_sitelibdir}" else if test "x${prefix}x" = "xNONEx" then RUBY_SITELIBDIR=`RUBY_CONFIG(sitelibdir)` else sitelibdir_no_prefix=`$RUBY -rrbconfig \ -e "include Config; \ puts CONFIG[['sitelibdir']].sub(CONFIG[['prefix']], '')"` RUBY_SITELIBDIR="${prefix}/${sitelibdir_no_prefix}" fi fi AC_SUBST(RUBY_SITELIBDIR) dnl The fourth parameter to AC_CHECK_HEADER keeps autoconf from dnl searching for standard header files as a side-effect (which we want) CPPFLAGS_save="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${RUBY_CPPFLAGS}" CXXFLAGS="${CPPFLAGS}" AC_CHECK_HEADERS(ruby.h,,AC_MSG_ERROR( could not find ruby.h (check config.log)),[ ]) AC_CHECK_HEADERS(node.h,,,[ #include ]) AC_CHECK_HEADERS(ruby/node.h, [ AC_DEFINE(REALLY_HAVE_RUBY_NODE_H, [], [ Define this macro to use ruby/node.h ]) ], ,[ #include ]) AC_CHECK_HEADERS(version.h,,,[ #include ]) AC_CHECK_HEADERS(env.h,,,[ #include ]) dnl We need to set the LD flags to include the path to this Ruby's dnl library path so that this library check will work for ruby installs dnl sitting in unconvential locations save_ldflags="$LDFLAGS" LDFLAGS="$RUBY_LDFLAGS" AC_CHECK_LIB($RUBY_CONFIG_SO_NAME, rb_class_boot, [ AC_DEFINE(HAVE_RB_CLASS_BOOT, [], [ Define this macro if rb_class_boot is defined ]) ] ) LDFLAGS="$save_ldflags" CPPFLAGS="${CPPFLAGS_save}" AC_MINGW32 if test x"${MINGW32}"x = xyesx; then RB_FIX_MINGW_LIBS fi ]) dnl RB_INIT_RUBY dnl We would like to be able to build using MingW against the one-click dnl installer, which is built using VC6. So, we detect this situation dnl and fix up the link step if this is the case. dnl dnl Static linking isn't likely to work correctly, so we disable it by dnl default, but if the user asks for LIBRUBYARG_STATIC, they'll still dnl get static linking. AC_DEFUN([RB_FIX_MINGW_LIBS], [ RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%oldnames.lib%-lmoldname%"` RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%user32.lib%-luser32%"` RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%advapi32.lib%-ladvapi32%"` RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%ws2_32.lib%-lws2_32%"` RUBY_LIBRUBYARG=`echo ${RUBY_LIBRUBYARG} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_BINDIR}/\1.dll%"` RUBY_LIBRUBYARG_STATIC=`echo ${RUBY_LIBRUBYARG_STATIC} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_LIBDIR}/\1.lib%"` ]) dnl RB_FIX_MINGW_LIBS dnl vim:ft=config