1
dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
dnl pandora-build: A pedantic build system
5
dnl Copyright (C) 2009 Sun Microsystems, Inc.
6
dnl This file is free software; the Free Software Foundation
7
dnl gives unlimited permission to copy and/or distribute it,
8
dnl with or without modifications, as long as this notice is preserved.
13
AC_DEFUN([PANDORA_WITH_RUBY], [
16
[AS_HELP_STRING([--with-ruby],
17
[Build Ruby Bindings @<:@default=yes@:>@])],
21
AS_IF([test "x$with_ruby" != "xno"],[
22
AS_IF([test "x$with_ruby" != "xyes"],
23
[ac_chk_ruby=$with_ruby],
24
[ac_chk_ruby=ruby1.8 ruby])
25
AC_CHECK_PROGS(RUBY,$ac_chk_ruby)
28
AS_IF([test "x$RUBY" != "x"],[
30
AC_MSG_CHECKING(for ruby devel)
32
dnl need to change quotes to allow square brackets
33
changequote(<<, >>)dnl
34
ruby_prefix=`$RUBY -rrbconfig -e "print Config::CONFIG['archdir']"`
35
strip_ruby_prefix=`$RUBY -rrbconfig -e "print Config::CONFIG['prefix']" | sed 's/\//./g'`
37
RUBY_LIB=`$RUBY -rrbconfig -e "puts Config::CONFIG['ruby_install_name']"`
38
LIBRUBYARG_SHARED=`$RUBY -rrbconfig -e "puts Config::CONFIG['LIBRUBYARG_SHARED']"`
39
RUBY_DIR=`$RUBY -rrbconfig -e "puts Config::CONFIG['archdir']"`
40
RUBY_ARCH_DIR=`echo $RUBY_DIR | sed "s/$strip_ruby_prefix//"`
41
RUBY_LIBDIR=`$RUBY -rrbconfig -e "puts Config::CONFIG['rubylibdir']"`
42
RUBY_INCLUDES="-I$ruby_prefix"
45
ac_save_CFLAGS="$CFLAGS"
46
ac_save_CPPFLAGS="$CPPFLAGS"
47
ac_save_LDFLAGS="$LDFLAGS"
48
CFLAGS="$ac_save_CFLAGS $RUBY_INCLUDES"
49
CPPFLAGS="$ac_save_CPPFLAGS $RUBY_INCLUDES"
50
LDFLAGS="$ac_save_LDFLAGS $LIBRUBYARG_SHARED"
52
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ruby.h>]], [[VALUE rb_ac_test = rb_define_module("actest");]])],[with_ruby="yes";AC_MSG_RESULT(found)],[with_ruby="no";AC_MSG_RESULT(missing)])
54
CPPFLAGS="$ac_save_CPPFLAGS"
55
CFLAGS="$ac_save_CFLAGS"
56
LDFLAGS="$ac_save_LDFLAGS"
58
# This allows 'make clean' in the ruby directory to work when
59
# ruby isn't available
70
AC_SUBST(RUBY_INCLUDES)
71
AC_SUBST(LIBRUBYARG_SHARED)
75
AC_SUBST(RUBY_ARCH_DIR)
77
AS_IF([test "x$RUBY_DIR" = "x"],[with_ruby="no"])
78
AM_CONDITIONAL(BUILD_RUBY, test "$with_ruby" = "yes")