1 dnl Thank you very much Vim for this lovely ruby configuration
2 dnl The hitchhiked code is from Vim configure.in version 1.98
5 AC_DEFUN([EL_CONFIG_SCRIPTING_RUBY],
7 AC_MSG_CHECKING([for Ruby])
9 CONFIG_SCRIPTING_RUBY_WITHVAL="no"
10 CONFIG_SCRIPTING_RUBY="no"
15 [ --with-ruby enable Ruby support],
16 [CONFIG_SCRIPTING_RUBY_WITHVAL="$withval"])
18 if test "$CONFIG_SCRIPTING_RUBY_WITHVAL" != no; then
19 CONFIG_SCRIPTING_RUBY="yes"
22 AC_MSG_RESULT($CONFIG_SCRIPTING_RUBY)
24 if test "$CONFIG_SCRIPTING_RUBY" = "yes"; then
25 if test -d "$CONFIG_SCRIPTING_RUBY_WITHVAL"; then
26 RUBY_PATH="$CONFIG_SCRIPTING_RUBY_WITHVAL:$PATH"
31 AC_PATH_PROG(CONFIG_SCRIPTING_RUBY, ruby, no, $RUBY_PATH)
32 if test "$CONFIG_SCRIPTING_RUBY" != "no"; then
34 AC_MSG_CHECKING(Ruby version)
35 if $CONFIG_SCRIPTING_RUBY -e 'exit((VERSION or RUBY_VERSION) >= "1.6.0")' >/dev/null 2>/dev/null; then
36 ruby_version=`$CONFIG_SCRIPTING_RUBY -e 'puts "#{VERSION rescue RUBY_VERSION}"'`
37 AC_MSG_RESULT($ruby_version)
39 AC_MSG_CHECKING(for Ruby header files)
40 rubyhdrdir=`$CONFIG_SCRIPTING_RUBY -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
42 if test "X$rubyhdrdir" != "X"; then
43 AC_MSG_RESULT($rubyhdrdir)
44 RUBY_CFLAGS="-I$rubyhdrdir"
45 rubylibs=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
47 if test "X$rubylibs" != "X"; then
51 librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
53 if test -f "$rubyhdrdir/$librubyarg"; then
54 librubyarg="$rubyhdrdir/$librubyarg"
57 rubylibdir=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config.expand(Config::CONFIG[["libdir"]])'`
58 if test -f "$rubylibdir/$librubyarg"; then
59 librubyarg="$rubylibdir/$librubyarg"
60 elif test "$librubyarg" = "libruby.a"; then
61 dnl required on Mac OS 10.3 where libruby.a doesn't exist
64 librubyarg=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e "print '$librubyarg'.gsub(/-L\./, %'-L#{Config.expand(Config::CONFIG[\"libdir\"])}')"`
68 if test "X$librubyarg" != "X"; then
69 RUBY_LIBS="$librubyarg $RUBY_LIBS"
72 rubyldflags=`$CONFIG_SCRIPTING_RUBY -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
73 if test "X$rubyldflags" != "X"; then
74 LDFLAGS="$rubyldflags $LDFLAGS"
77 LIBS="$RUBY_LIBS $LIBS"
78 CFLAGS="$RUBY_CFLAGS $CFLAGS"
79 CPPFLAGS="$CPPFLAGS $RUBY_CFLAGS"
81 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[ruby_init();]])],[CONFIG_SCRIPTING_RUBY=yes],[CONFIG_SCRIPTING_RUBY=no])
83 AC_MSG_RESULT([Ruby header files not found])
86 AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
93 if test "$CONFIG_SCRIPTING_RUBY" != "yes"; then
94 if test -n "$CONFIG_SCRIPTING_RUBY_WITHVAL" &&
95 test "$CONFIG_SCRIPTING_RUBY_WITHVAL" != no; then
96 AC_MSG_ERROR([Ruby not found])
99 EL_CONFIG(CONFIG_SCRIPTING_RUBY, [Ruby])
101 LIBS="$LIBS $RUBY_LIBS"
102 AC_SUBST(RUBY_CFLAGS)