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.

145 lines
6.0KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_ruby_ext.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_RUBY_EXT
  8. #
  9. # DESCRIPTION
  10. #
  11. # Fetches the linker flags and C compiler flags for compiling and linking
  12. # Ruby binary extensions. The macro substitutes RUBY_VERSION,
  13. # RUBY_EXT_INC, RUBY_EXT_LIB, RUBY_EXT_CPPFLAGS, RUBY_EXT_LDFLAGS and
  14. # RUBY_EXT_DLEXT variables if Ruby executable has been found. It also
  15. # checks the same variables before trying to retrieve them from the Ruby
  16. # configuration.
  17. #
  18. # RUBY_VERSION: version of the Ruby interpreter
  19. # RUBY_EXT_INC: Ruby include directory
  20. # RUBY_EXT_LIB: Ruby extensions destination directory
  21. # RUBY_EXT_CPPFLAGS: C preprocessor flags to compile extensions
  22. # RUBY_EXT_LDFLAGS: linker flags to build extensions
  23. # RUBY_EXT_DLEXT: extensions suffix for ruby modules (e.g. "so")
  24. #
  25. # Examples:
  26. #
  27. # AX_RUBY_EXT
  28. # if test x"$RUBY" = x; then
  29. # AC_ERROR(["cannot find Ruby"])
  30. # fi
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2011 Stanislav Sedov <stas@FreeBSD.org>
  35. #
  36. # Redistribution and use in source and binary forms, with or without
  37. # modification, are permitted provided that the following conditions are
  38. # met:
  39. #
  40. # 1. Redistributions of source code must retain the above copyright
  41. # notice, this list of conditions and the following disclaimer.
  42. #
  43. # 2. Redistributions in binary form must reproduce the above copyright
  44. # notice, this list of conditions and the following disclaimer in the
  45. # documentation and/or other materials provided with the distribution.
  46. #
  47. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  48. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  50. # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
  51. # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  52. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  53. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  54. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  55. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  56. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  57. # THE POSSIBILITY OF SUCH DAMAGE.
  58. #serial 4
  59. AC_DEFUN([AX_RUBY_EXT],[
  60. #
  61. # Check if ruby executable exists.
  62. #
  63. AC_PATH_PROGS(RUBY, ["${RUBY-ruby}"], [])
  64. if test -n "$RUBY" ; then
  65. AC_MSG_NOTICE([Ruby executable: '$RUBY'])
  66. #
  67. # Check Ruby version.
  68. #
  69. AC_MSG_CHECKING([for Ruby version])
  70. [RUBY_VERSION=`$RUBY -e 'puts RUBY_VERSION'`];
  71. AC_MSG_RESULT([$RUBY_VERSION])
  72. AC_SUBST(RUBY_VERSION)
  73. #
  74. # Check for Ruby extensions include path.
  75. #
  76. AC_ARG_VAR(RUBY_EXT_INC, [Directory to include ruby headers from])
  77. AC_MSG_CHECKING([for Ruby headers include path])
  78. if test -z "$RUBY_EXT_INC" ; then
  79. [RUBY_EXT_INC=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]'`];
  80. fi
  81. AC_MSG_RESULT([$RUBY_EXT_INC])
  82. AC_SUBST(RUBY_EXT_INC)
  83. #
  84. # Check for the extensions target directory.
  85. #
  86. AC_ARG_VAR(RUBY_EXT_LIB, [Directory to install ruby extensions into])
  87. AC_MSG_CHECKING([for Ruby extensions target directory])
  88. if test -z "$RUBY_EXT_LIB" ; then
  89. [RUBY_EXT_LIB=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]'`];
  90. fi
  91. AC_MSG_RESULT([$RUBY_EXT_LIB])
  92. AC_SUBST(RUBY_EXT_LIB)
  93. #
  94. # Check for Ruby CPP flags.
  95. #
  96. AC_ARG_VAR(RUBY_EXT_CPPFLAGS, [CPPFLAGS to compile Ruby extensions])
  97. AC_MSG_CHECKING([for Ruby extensions C preprocessor flags])
  98. if test -z "$RUBY_EXT_CPPFLAGS" ; then
  99. [RUBY_EXT_CPPFLAGS=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["CPPFLAGS"]'`];
  100. fi
  101. AC_MSG_RESULT([$RUBY_EXT_CPPFLAGS])
  102. AC_SUBST(RUBY_EXT_CPPFLAGS)
  103. #
  104. # Check for Ruby extensions link flags.
  105. #
  106. AC_ARG_VAR(RUBY_EXT_LDFLAGS, [LDFLAGS to build Ruby extensions])
  107. AC_MSG_CHECKING([for Ruby extensions linker flags])
  108. if test -z "$RUBY_EXT_LDFLAGS" ; then
  109. [RUBY_EXT_LDFLAGS=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["LDFLAGS"]'`];
  110. fi
  111. # Fix LDFLAGS for OS X. We don't want any -arch flags here, otherwise
  112. # linking might fail. We also including the proper flags to create a bundle.
  113. case "$host" in
  114. *darwin*)
  115. RUBY_EXT_LDFLAGS=`echo ${RUBY_EXT_LDFLAGS} | sed -e "s,-arch [[^ ]]*,,g"`
  116. RUBY_EXT_LDFLAGS="${RUBY_EXT_LDFLAGS} -bundle -undefined dynamic_lookup"
  117. ;;
  118. esac
  119. AC_MSG_RESULT([$RUBY_EXT_LDFLAGS])
  120. AC_SUBST(RUBY_EXT_LDFLAGS)
  121. #
  122. # Check for Ruby dynamic library extension.
  123. #
  124. AC_ARG_VAR(RUBY_EXT_DLEXT, [Ruby dynamic library extension])
  125. AC_MSG_CHECKING([for Ruby dynamic library extension])
  126. if test -z "$RUBY_EXT_DLEXT" ; then
  127. [RUBY_EXT_DLEXT=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]'`];
  128. RUBY_EXT_DLEXT=".${RUBY_EXT_DLEXT}"
  129. fi
  130. AC_MSG_RESULT([$RUBY_EXT_DLEXT])
  131. AC_SUBST(RUBY_EXT_DLEXT)
  132. fi
  133. ])