forked from autoconf-archive/autoconf-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ax_ruby_devel.m4
180 lines (168 loc) · 6.34 KB
/
ax_ruby_devel.m4
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_ruby_devel.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_RUBY_DEVEL([version])
#
# DESCRIPTION
#
# This macro checks for Ruby and tries to get the include path to
# 'ruby.h'. It provides the $(RUBY_CPPFLAGS) and $(RUBY_LDFLAGS) output
# variables. It also exports $(RUBY_EXTRA_LIBS) for embedding Ruby in your
# code.
#
# You can search for some particular version of Ruby by passing a
# parameter to this macro, for example "2.2.1".
#
# LICENSE
#
# Copyright (c) 2008 Rafal Rzepecki <[email protected]>
# Copyright (c) 2008 Sebastian Huber <[email protected]>
# Copyright (c) 2008 Alan W. Irwin
# Copyright (c) 2008 Rafael Laboissiere <[email protected]>
# Copyright (c) 2008 Andrew Collier
# Copyright (c) 2008 Matteo Settenvini <[email protected]>
# Copyright (c) 2008 Horst Knorr <[email protected]>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 15
AC_DEFUN([AX_RUBY_DEVEL],[
AX_WITH_PROG(RUBY,ruby)
AS_IF([test -n "$1"], [
AX_PROG_RUBY_VERSION([$1],[],[
AC_MSG_ERROR([this package requires Ruby $1])
])
])
#
# Check if you have rbconfig, else fail
#
AC_MSG_CHECKING([for the rbconfig Ruby package])
ac_rbconfig_result=`$RUBY -rrbconfig -e ";" 2>&1`
if test -z "$ac_rbconfig_result"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot import Ruby module "rbconfig".
Please check your Ruby installation. The error was:
$ac_rbconfig_result])
fi
#
# Check for Ruby include path
#
AC_MSG_CHECKING([for Ruby include path])
if test -z "$RUBY_CPPFLAGS"; then
ruby_path=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]]'`
ruby_arch_path=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyarchhdrdir"]]'`
if test -n "${ruby_path}"; then
ruby_path="-I$ruby_path"
fi
if test -n "${ruby_arch_path}"; then
ruby_arch_path="-I$ruby_arch_path"
fi
RUBY_CPPFLAGS="$ruby_path $ruby_arch_path"
fi
AC_MSG_RESULT([$RUBY_CPPFLAGS])
AC_SUBST([RUBY_CPPFLAGS])
#
# Check for Ruby library path
#
AC_MSG_CHECKING([for Ruby library path])
if test -z "$RUBY_LDFLAGS"; then
RUBY_LDFLAGS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBRUBYARG_SHARED"]]'`
fi
AC_MSG_RESULT([$RUBY_LDFLAGS])
AC_SUBST([RUBY_LDFLAGS])
#
# Check for site packages
#
AC_MSG_CHECKING([for Ruby site-packages path])
if test -z "$RUBY_SITE_PKG"; then
RUBY_SITE_PKG=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["sitearchdir"]]'`
fi
AC_MSG_RESULT([$RUBY_SITE_PKG])
AC_SUBST([RUBY_SITE_PKG])
#
# libraries which must be linked in when embedding
#
AC_MSG_CHECKING(ruby extra libraries)
if test -z "$RUBY_EXTRA_LIBS"; then
RUBY_EXTRA_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["SOLIBS"]]'`
fi
AC_MSG_RESULT([$RUBY_EXTRA_LIBS])
AC_SUBST(RUBY_EXTRA_LIBS)
#
# linking flags needed when embedding
# (is it even needed for Ruby?)
#
# AC_MSG_CHECKING(ruby extra linking flags)
# if test -z "$RUBY_EXTRA_LDFLAGS"; then
# RUBY_EXTRA_LDFLAGS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LINKFORSHARED"]]'`
# fi
# AC_MSG_RESULT([$RUBY_EXTRA_LDFLAGS])
# AC_SUBST(RUBY_EXTRA_LDFLAGS)
# this flags breaks ruby.h, and is sometimes defined by KDE m4 macros
CFLAGS="`echo "$CFLAGS" | sed -e 's/-std=iso9899:1990//g;'`"
#
# final check to see if everything compiles alright
#
AC_MSG_CHECKING([consistency of all components of ruby development environment])
AC_LANG_PUSH([C])
# save current global flags
ac_save_LIBS="$LIBS"
LIBS="$ac_save_LIBS $RUBY_LDFLAGS"
ac_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$ac_save_CPPFLAGS $RUBY_CPPFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <ruby.h>
]], [[
ruby_init();
]])],[rubyexists=yes],[rubyexists=no])
AC_MSG_RESULT([$rubyexists])
if test ! "$rubyexists" = "yes"; then
AC_MSG_ERROR([
Could not link test program to Ruby. Maybe the main Ruby library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/ruby/lib"
============================================================================
ERROR!
You probably have to install the development version of the Ruby package
for your distribution. The exact name of this package varies among them.
============================================================================
])
RUBY_VERSION=""
fi
AC_LANG_POP
# turn back to default flags
CPPFLAGS="$ac_save_CPPFLAGS"
LIBS="$ac_save_LIBS"
#
# all done!
#
])