pandora_with_ruby.m4 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
  2. dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  3. dnl
  4. dnl pandora-build: A pedantic build system
  5. dnl Copyright (C) 2009 Sun Microsystems, Inc.
  6. dnl This file is free software; Sun Microsystems
  7. dnl gives unlimited permission to copy and/or distribute it,
  8. dnl with or without modifications, as long as this notice is preserved.
  9. dnl
  10. dnl From Monty Taylor
  11. AC_DEFUN([PANDORA_WITH_RUBY], [
  12. AC_ARG_WITH([ruby],
  13. [AS_HELP_STRING([--with-ruby],
  14. [Build Ruby Bindings @<:@default=yes@:>@])],
  15. [with_ruby=$withval],
  16. [with_ruby=ruby])
  17. AS_IF([test "x$with_ruby" != "xno"],[
  18. AS_IF([test "x$with_ruby" != "xyes"],
  19. [ac_chk_ruby=$with_ruby],
  20. [ac_chk_ruby=ruby1.8 ruby])
  21. AC_CHECK_PROGS(RUBY,$ac_chk_ruby)
  22. ])
  23. AS_IF([test "x$RUBY" != "x"],[
  24. AC_MSG_CHECKING(for ruby devel)
  25. dnl need to change quotes to allow square brackets
  26. changequote(<<, >>)dnl
  27. ruby_prefix=`$RUBY -rrbconfig -e "print Config::CONFIG['archdir']"`
  28. strip_ruby_prefix=`$RUBY -rrbconfig -e "print Config::CONFIG['prefix']" | sed 's/\//./g'`
  29. RUBY_LIB=`$RUBY -rrbconfig -e "puts Config::CONFIG['ruby_install_name']"`
  30. LIBRUBYARG_SHARED=`$RUBY -rrbconfig -e "puts Config::CONFIG['LIBRUBYARG_SHARED']"`
  31. RUBY_DIR=`$RUBY -rrbconfig -e "puts Config::CONFIG['archdir']"`
  32. RUBY_ARCH_DIR=`echo $RUBY_DIR | sed "s/$strip_ruby_prefix//"`
  33. RUBY_LIBDIR=`$RUBY -rrbconfig -e "puts Config::CONFIG['rubylibdir']"`
  34. RUBY_INCLUDES="-I$ruby_prefix"
  35. changequote([, ])dnl
  36. ac_save_CFLAGS="$CFLAGS"
  37. ac_save_CPPFLAGS="$CPPFLAGS"
  38. ac_save_LDFLAGS="$LDFLAGS"
  39. CFLAGS="$ac_save_CFLAGS $RUBY_INCLUDES"
  40. CPPFLAGS="$ac_save_CPPFLAGS $RUBY_INCLUDES"
  41. LDFLAGS="$ac_save_LDFLAGS $LIBRUBYARG_SHARED"
  42. 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)])
  43. CPPFLAGS="$ac_save_CPPFLAGS"
  44. CFLAGS="$ac_save_CFLAGS"
  45. LDFLAGS="$ac_save_LDFLAGS"
  46. ],[
  47. # This allows 'make clean' in the ruby directory to work when
  48. # ruby isn't available
  49. RUBY=
  50. RUBY_INCLUDES=
  51. LIBRUBYARG_SHARED=
  52. RUBY_LIB=
  53. RUBY_DIR=
  54. RUBY_LIBDIR=
  55. RUBY_ARCH_DIR=
  56. with_ruby="no"
  57. ])
  58. AC_SUBST(RUBY_INCLUDES)
  59. AC_SUBST(LIBRUBYARG_SHARED)
  60. AC_SUBST(RUBY_LIB)
  61. AC_SUBST(RUBY_DIR)
  62. AC_SUBST(RUBY_LIBDIR)
  63. AC_SUBST(RUBY_ARCH_DIR)
  64. AS_IF([test "x$RUBY_DIR" = "x"],[with_ruby="no"])
  65. AM_CONDITIONAL(BUILD_RUBY, test "$with_ruby" = "yes")
  66. ])