-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby.ac
150 lines (126 loc) · 4.61 KB
/
ruby.ac
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
dnl Get a key from ruby's configuration table
AC_DEFUN([RUBY_CONFIG], [
$RUBY -rrbconfig -e "puts(Config::CONFIG[['$1']] || '')"])
AC_DEFUN([RB_INIT_RUBY], [
AC_ARG_WITH(
ruby,
AC_HELP_STRING(
--with-ruby=PATH,
[ path to the ruby interpreter [[ruby]] ]),
[ RUBY=$withval ],
[ RUBY=ruby ])
AC_ARG_WITH(
ruby_sitelibdir,
AC_HELP_STRING(
--with-ruby-sitelibdir=PATH,
[ path to install ruby scripts [[auto-detect]] ]),
[ ruby_sitelibdir=$withval ],
[ ruby_sitelibdir=NONE ])
AC_SUBST(RUBY)
RUBY_VERSION_CODE=`$RUBY -e "puts RUBY_VERSION.gsub(/\./, '')"`
AC_SUBST(RUBY_VERSION_CODE)
RUBY_CONFIG_SO_NAME=`RUBY_CONFIG(RUBY_SO_NAME)`
RUBY_CONFIG_ARCHDIR=`RUBY_CONFIG(archdir)`
RUBY_CONFIG_ARCH=`RUBY_CONFIG(arch)`
RUBY_CONFIG_LIBDIR=`RUBY_CONFIG(libdir)`
RUBY_CONFIG_BINDIR=`RUBY_CONFIG(bindir)`
RUBY_CONFIG_RUBYHDRDIR=`RUBY_CONFIG(rubyhdrdir)`
RUBY_CONFIG_CFLAGS=`RUBY_CONFIG(CFLAGS)`
RUBY_CONFIG_LIBS=`RUBY_CONFIG(LIBS)`
RUBY_CONFIG_DLDLIBS=`RUBY_CONFIG(DLDLIBS)`
RUBY_CONFIG_LDFLAGS=`RUBY_CONFIG(LDFLAGS)`
RUBY_CONFIG_LIBRUBYARG=`RUBY_CONFIG(LIBRUBYARG)`
RUBY_CONFIG_LIBRUBYARG_STATIC=`RUBY_CONFIG(LIBRUBYARG_STATIC)`
RUBY_CONFIG_CCDLFLAGS=`RUBY_CONFIG(CCDLFLAGS)`
if test "x${RUBY_CONFIG_RUBYHDRDIR}x" != "xx"; then
# 1.9
RUBY_CPPFLAGS="-I${RUBY_CONFIG_RUBYHDRDIR}"
RUBY_CPPFLAGS="${RUBY_CPPFLAGS} -I${RUBY_CONFIG_RUBYHDRDIR}/${RUBY_CONFIG_ARCH}"
else
# 1.8
RUBY_CPPFLAGS="-I${RUBY_CONFIG_ARCHDIR}"
fi
AC_SUBST(RUBY_CPPFLAGS)
RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
AC_SUBST(RUBY_CFLAGS)
RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
AC_SUBST(RUBY_CXXFLAGS)
RUBY_LDFLAGS="-L${RUBY_CONFIG_ARCHDIR} -L${RUBY_CONFIG_LIBDIR} ${RUBY_CONFIG_LDFLAGS}"
AC_SUBST(RUBY_LDFLAGS)
RUBY_LIBS="${RUBY_CONFIG_LIBS} ${RUBY_CONFIG_DLDLIBS}"
AC_SUBST(RUBY_LIBS)
RUBY_LIBRUBYARG="${RUBY_CONFIG_LIBRUBYARG}"
AC_SUBST(RUBY_LIBRUBYARG)
RUBY_LIBRUBYARG_STATIC="${RUBY_CONFIG_LIBRUBYARG_STATIC}"
AC_SUBST(RUBY_LIBRUBYARG_STATIC)
dnl If the user specified a prefix, then use it, otherwise defalut to
dnl the configured sitelibdir
if test "x${ruby_sitelibdir}x" != "xNONEx"
then
RUBY_SITELIBDIR="${ruby_sitelibdir}"
else
if test "x${prefix}x" = "xNONEx"
then
RUBY_SITELIBDIR=`RUBY_CONFIG(sitelibdir)`
else
sitelibdir_no_prefix=`$RUBY -rrbconfig \
-e "include Config; \
puts CONFIG[['sitelibdir']].sub(CONFIG[['prefix']], '')"`
RUBY_SITELIBDIR="${prefix}/${sitelibdir_no_prefix}"
fi
fi
AC_SUBST(RUBY_SITELIBDIR)
dnl The fourth parameter to AC_CHECK_HEADER keeps autoconf from
dnl searching for standard header files as a side-effect (which we want)
CPPFLAGS_save="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${RUBY_CPPFLAGS}"
CXXFLAGS="${CPPFLAGS}"
AC_CHECK_HEADERS(ruby.h,,AC_MSG_ERROR(
could not find ruby.h (check config.log)),[ ])
AC_CHECK_HEADERS(node.h,,,[
#include <ruby.h>
])
AC_CHECK_HEADERS(ruby/node.h,
[ AC_DEFINE(REALLY_HAVE_RUBY_NODE_H, [],
[ Define this macro to use ruby/node.h ]) ],
,[
#include <ruby.h>
])
AC_CHECK_HEADERS(version.h,,,[
#include <ruby.h>
])
AC_CHECK_HEADERS(env.h,,,[
#include <ruby.h>
])
dnl We need to set the LD flags to include the path to this Ruby's
dnl library path so that this library check will work for ruby installs
dnl sitting in unconvential locations
save_ldflags="$LDFLAGS"
LDFLAGS="$RUBY_LDFLAGS"
AC_CHECK_LIB($RUBY_CONFIG_SO_NAME,
rb_class_boot,
[ AC_DEFINE(HAVE_RB_CLASS_BOOT, [], [
Define this macro if rb_class_boot is defined ]) ] )
LDFLAGS="$save_ldflags"
CPPFLAGS="${CPPFLAGS_save}"
AC_MINGW32
if test x"${MINGW32}"x = xyesx; then
RB_FIX_MINGW_LIBS
fi
]) dnl RB_INIT_RUBY
dnl We would like to be able to build using MingW against the one-click
dnl installer, which is built using VC6. So, we detect this situation
dnl and fix up the link step if this is the case.
dnl
dnl Static linking isn't likely to work correctly, so we disable it by
dnl default, but if the user asks for LIBRUBYARG_STATIC, they'll still
dnl get static linking.
AC_DEFUN([RB_FIX_MINGW_LIBS], [
RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%oldnames.lib%-lmoldname%"`
RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%user32.lib%-luser32%"`
RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%advapi32.lib%-ladvapi32%"`
RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%ws2_32.lib%-lws2_32%"`
RUBY_LIBRUBYARG=`echo ${RUBY_LIBRUBYARG} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_BINDIR}/\1.dll%"`
RUBY_LIBRUBYARG_STATIC=`echo ${RUBY_LIBRUBYARG_STATIC} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_LIBDIR}/\1.lib%"`
]) dnl RB_FIX_MINGW_LIBS
dnl vim:ft=config