Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
6.3KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_ruby_devel.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_RUBY_DEVEL([version])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro checks for Ruby and tries to get the include path to
  12. # 'ruby.h'. It provides the $(RUBY_CPPFLAGS) and $(RUBY_LDFLAGS) output
  13. # variables. It also exports $(RUBY_EXTRA_LIBS) for embedding Ruby in your
  14. # code.
  15. #
  16. # You can search for some particular version of Ruby by passing a
  17. # parameter to this macro, for example "2.2.1".
  18. #
  19. # LICENSE
  20. #
  21. # Copyright (c) 2008 Rafal Rzepecki <divided.mind@gmail.com>
  22. # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
  23. # Copyright (c) 2008 Alan W. Irwin
  24. # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
  25. # Copyright (c) 2008 Andrew Collier
  26. # Copyright (c) 2008 Matteo Settenvini <matteo@member.fsf.org>
  27. # Copyright (c) 2008 Horst Knorr <hk_classes@knoda.org>
  28. #
  29. # This program is free software: you can redistribute it and/or modify it
  30. # under the terms of the GNU General Public License as published by the
  31. # Free Software Foundation, either version 3 of the License, or (at your
  32. # option) any later version.
  33. #
  34. # This program is distributed in the hope that it will be useful, but
  35. # WITHOUT ANY WARRANTY; without even the implied warranty of
  36. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  37. # Public License for more details.
  38. #
  39. # You should have received a copy of the GNU General Public License along
  40. # with this program. If not, see <https://www.gnu.org/licenses/>.
  41. #
  42. # As a special exception, the respective Autoconf Macro's copyright owner
  43. # gives unlimited permission to copy, distribute and modify the configure
  44. # scripts that are the output of Autoconf when processing the Macro. You
  45. # need not follow the terms of the GNU General Public License when using
  46. # or distributing such scripts, even though portions of the text of the
  47. # Macro appear in them. The GNU General Public License (GPL) does govern
  48. # all other use of the material that constitutes the Autoconf Macro.
  49. #
  50. # This special exception to the GPL applies to versions of the Autoconf
  51. # Macro released by the Autoconf Archive. When you make and distribute a
  52. # modified version of the Autoconf Macro, you may extend this special
  53. # exception to the GPL to apply to your modified version as well.
  54. #serial 14
  55. AC_DEFUN([AX_RUBY_DEVEL],[
  56. AX_WITH_PROG(RUBY,ruby)
  57. AS_IF([test -n "$1"], [
  58. AX_PROG_RUBY_VERSION([$1],[],[
  59. AC_MSG_ERROR([this package requires Ruby $1])
  60. ])
  61. ])
  62. #
  63. # Check if you have rbconfig, else fail
  64. #
  65. AC_MSG_CHECKING([for the rbconfig Ruby package])
  66. ac_rbconfig_result=`$RUBY -rrbconfig -e ";" 2>&1`
  67. if test -z "$ac_rbconfig_result"; then
  68. AC_MSG_RESULT([yes])
  69. else
  70. AC_MSG_RESULT([no])
  71. AC_MSG_ERROR([cannot import Ruby module "rbconfig".
  72. Please check your Ruby installation. The error was:
  73. $ac_rbconfig_result])
  74. fi
  75. #
  76. # Check for Ruby include path
  77. #
  78. AC_MSG_CHECKING([for Ruby include path])
  79. if test -z "$RUBY_CPPFLAGS"; then
  80. ruby_path=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]]'`
  81. ruby_arch_path=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyarchhdrdir"]]'`
  82. if test -n "${ruby_path}"; then
  83. ruby_path="-I$ruby_path"
  84. fi
  85. if test -n "${ruby_arch_path}"; then
  86. ruby_arch_path="-I$ruby_arch_path"
  87. fi
  88. RUBY_CPPFLAGS="$ruby_path $ruby_arch_path"
  89. fi
  90. AC_MSG_RESULT([$RUBY_CPPFLAGS])
  91. AC_SUBST([RUBY_CPPFLAGS])
  92. #
  93. # Check for Ruby library path
  94. #
  95. AC_MSG_CHECKING([for Ruby library path])
  96. if test -z "$RUBY_LDFLAGS"; then
  97. RUBY_LDFLAGS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBRUBYARG_SHARED"]]'`
  98. fi
  99. AC_MSG_RESULT([$RUBY_LDFLAGS])
  100. AC_SUBST([RUBY_LDFLAGS])
  101. #
  102. # Check for site packages
  103. #
  104. AC_MSG_CHECKING([for Ruby site-packages path])
  105. if test -z "$RUBY_SITE_PKG"; then
  106. RUBY_SITE_PKG=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["sitearchdir"]]'`
  107. fi
  108. AC_MSG_RESULT([$RUBY_SITE_PKG])
  109. AC_SUBST([RUBY_SITE_PKG])
  110. #
  111. # libraries which must be linked in when embedding
  112. #
  113. AC_MSG_CHECKING(ruby extra libraries)
  114. if test -z "$RUBY_EXTRA_LIBS"; then
  115. RUBY_EXTRA_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["SOLIBS"]]'`
  116. fi
  117. AC_MSG_RESULT([$RUBY_EXTRA_LIBS])
  118. AC_SUBST(RUBY_EXTRA_LIBS)
  119. #
  120. # linking flags needed when embedding
  121. # (is it even needed for Ruby?)
  122. #
  123. # AC_MSG_CHECKING(ruby extra linking flags)
  124. # if test -z "$RUBY_EXTRA_LDFLAGS"; then
  125. # RUBY_EXTRA_LDFLAGS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LINKFORSHARED"]]'`
  126. # fi
  127. # AC_MSG_RESULT([$RUBY_EXTRA_LDFLAGS])
  128. # AC_SUBST(RUBY_EXTRA_LDFLAGS)
  129. # this flags breaks ruby.h, and is sometimes defined by KDE m4 macros
  130. CFLAGS="`echo "$CFLAGS" | sed -e 's/-std=iso9899:1990//g;'`"
  131. #
  132. # final check to see if everything compiles alright
  133. #
  134. AC_MSG_CHECKING([consistency of all components of ruby development environment])
  135. AC_LANG_PUSH([C])
  136. # save current global flags
  137. ac_save_LIBS="$LIBS"
  138. LIBS="$ac_save_LIBS $RUBY_LDFLAGS"
  139. ac_save_CPPFLAGS="$CPPFLAGS"
  140. CPPFLAGS="$ac_save_CPPFLAGS $RUBY_CPPFLAGS"
  141. AC_TRY_LINK([
  142. #include <ruby.h>
  143. ],[
  144. ruby_init();
  145. ],[rubyexists=yes],[rubyexists=no])
  146. AC_MSG_RESULT([$rubyexists])
  147. if test ! "$rubyexists" = "yes"; then
  148. AC_MSG_ERROR([
  149. Could not link test program to Ruby. Maybe the main Ruby library has been
  150. installed in some non-standard library path. If so, pass it to configure,
  151. via the LDFLAGS environment variable.
  152. Example: ./configure LDFLAGS="-L/usr/non-standard-path/ruby/lib"
  153. ============================================================================
  154. ERROR!
  155. You probably have to install the development version of the Ruby package
  156. for your distribution. The exact name of this package varies among them.
  157. ============================================================================
  158. ])
  159. RUBY_VERSION=""
  160. fi
  161. AC_LANG_POP
  162. # turn back to default flags
  163. CPPFLAGS="$ac_save_CPPFLAGS"
  164. LIBS="$ac_save_LIBS"
  165. #
  166. # all done!
  167. #
  168. ])