File: am_path_ruby.m4

package info (click to toggle)
libprelude 4.1.0-4.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 21,452 kB
  • sloc: ansic: 103,807; cpp: 64,944; sh: 13,563; perl: 679; makefile: 674; awk: 343; yacc: 241; lex: 178; python: 89; xml: 65
file content (118 lines) | stat: -rw-r--r-- 5,138 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# AM_PATH_RUBY([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [PATH])
# ---------------------------------------------------------------------------
# Adds support for distributing Ruby modules and packages.  To
# install modules, copy them to $(rubydir), using the ruby_RUBY
# automake variable.  To install a package with the same name as the
# automake package, install to $(pkgrubydir), or use the
# pkgruby_RUBY automake variable.
#
# The variables $(rbexecdir) and $(pkgrbexecdir) are provided as
# locations to install ruby extension modules (shared libraries).
# Another macro is required to find the appropriate flags to compile
# extension modules.
#
AC_DEFUN([AM_PATH_RUBY],
 [
  dnl Find a Ruby interpreter.
  m4_define_default([_AM_RUBY_INTERPRETER_LIST],
                    [ruby ruby1.8 ruby1.7 ruby1.6])

  m4_if([$1],[],[
    dnl No version check is needed.
    # Find any Ruby interpreter.
    if test -z "$RUBY"; then
      AC_PATH_PROGS([RUBY], _AM_RUBY_INTERPRETER_LIST, :, $4)
    fi
    am_display_RUBY=ruby
  ], [
    dnl A version check is needed.
    if test -n "$RUBY"; then
      # If the user set $RUBY, use it and don't search something else.
      #AC_MSG_CHECKING([whether $RUBY version >= $1])
      #AM_RUBY_CHECK_VERSION([$RUBY], [$1],
      #                        [AC_MSG_RESULT(yes)],
      #                        [AC_MSG_ERROR(too old)])
      am_display_RUBY=$RUBY
    else
      # Otherwise, try each interpreter until we find one that satisfies
      # VERSION.
      AC_CACHE_CHECK([for a Ruby interpreter with version >= $1],
        [am_cv_pathless_RUBY],[
        for am_cv_pathless_RUBY in _AM_RUBY_INTERPRETER_LIST none; do
          test "$am_cv_pathless_RUBY" = none && break
          #AM_RUBY_CHECK_VERSION([$am_cv_pathless_RUBY], [$1], [break])
        done])
      # Set $RUBY to the absolute path of $am_cv_pathless_RUBY.
      if test "$am_cv_pathless_RUBY" = none; then
        RUBY=:
      else
        AC_PATH_PROG([RUBY], [$am_cv_pathless_RUBY], , $4)
      fi
      am_display_RUBY=$am_cv_pathless_RUBY
    fi
  ])

  if test "$RUBY" = :; then
  dnl Run any user-specified action, or abort.
    m4_default([$3], [AC_MSG_ERROR([no suitable Ruby interpreter found])])
  else

  dnl Query Ruby for its version number.  Getting [:3] seems to be
  dnl the best way to do this; it's what "site.py" does in the standard
  dnl library.

  AC_CACHE_CHECK([for $am_display_RUBY version], [am_cv_ruby_version],
    [am_cv_ruby_version=`$RUBY -e "print RUBY_VERSION"`])
  AC_SUBST([RUBY_VERSION], [$am_cv_ruby_version])

  dnl Use the values of $prefix and $exec_prefix for the corresponding
  dnl values of RUBY_PREFIX and RUBY_EXEC_PREFIX.  These are made
  dnl distinct variables so they can be overridden if need be.  However,
  dnl general consensus is that you shouldn't need this ability.

  AC_SUBST([RUBY_PREFIX], ['${prefix}'])
  AC_SUBST([RUBY_EXEC_PREFIX], ['${exec_prefix}'])

  dnl At times (like when building shared libraries) you may want
  dnl to know which OS platform Ruby thinks this is.

  AC_CACHE_CHECK([for $am_display_RUBY platform], [am_cv_ruby_platform],
    [am_cv_ruby_platform=`$RUBY -e "print RUBY_PLATFORM"`])
  AC_SUBST([RUBY_PLATFORM], [$am_cv_ruby_platform])


  dnl Set up 4 directories:
  dnl rubydir -- where to install ruby scripts.
  AC_CACHE_CHECK([for $am_display_RUBY script directory],
    [am_cv_ruby_rubydir],
    [am_cv_ruby_rubydir=`$RUBY -rrbconfig -e "drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/; prefix = Regexp.new('\\A' + Regexp.quote(RbConfig::CONFIG[['prefix']])); \\$prefix = RbConfig::CONFIG[['prefix']].sub(drive, ''); \\$archdir = RbConfig::CONFIG[['archdir']].sub(prefix, '\\$(prefix)').sub(drive, ''); print \\$archdir;"`])
  AC_SUBST([rubydir], [$am_cv_ruby_rubydir])

  dnl pkgrubydir -- $PACKAGE directory under rubydir.
  AC_SUBST([pkgrubydir], [\${rubydir}/$PACKAGE])

  dnl rbexecdir -- directory for installing ruby extension modules
  dnl   (shared libraries)
  AC_CACHE_CHECK([for $am_display_RUBY extension module directory],
    [am_cv_ruby_rbexecdir],
    [am_cv_ruby_rbexecdir=`$RUBY -r rbconfig -e "print RbConfig::CONFIG[['vendorarchdir']]"`])
  AC_SUBST([rbexecdir], [$am_cv_ruby_rbexecdir])

  dnl if PKG-CONFIG is available, we use it. Else, we try to dectect RUBY_INCLUDES manually
  RUBY_VER=`$RUBY -rrbconfig -e "print RbConfig::CONFIG[['ruby_pc']]" | sed 's/.pc//g'`
  PKG_CHECK_MODULES(RUBY_PKG_CONFIG, $RUBY_VER, [RUBY_INCLUDES=`pkg-config $RUBY_VER --cflags`], [RUBY_INCLUDES=`$RUBY -r rbconfig -e '
               if RbConfig::CONFIG[["archdir"]] then print " -I" + RbConfig::CONFIG[["archdir"]] end
               if RbConfig::CONFIG[["rubyhdrdir"]] then print " -I" + RbConfig::CONFIG[["rubyhdrdir"]] end
               if RbConfig::CONFIG[["rubyhdrdir"]] and RbConfig::CONFIG[["sitearch"]] then print " -I" + RbConfig::CONFIG[["rubyhdrdir"]] + "/" + RbConfig::CONFIG[["sitearch"]] end'`] )

  AC_SUBST([RUBY_INCLUDES])

  dnl pkgrbexecdir -- $(rbexecdir)/$(PACKAGE)

  AC_SUBST([pkgrbexecdir], [\${rbexecdir}/$PACKAGE])

  dnl Run any user-specified action.
  $2
  fi

])