1 | dnl Get a key from ruby's configuration table |
---|
2 | AC_DEFUN([RUBY_CONFIG], [ |
---|
3 | $RUBY -rrbconfig -e "puts(Config::CONFIG[['$1']] || '')"]) |
---|
4 | |
---|
5 | AC_DEFUN([RP_LANG_RUBY], [ |
---|
6 | |
---|
7 | AC_ARG_WITH( |
---|
8 | ruby, |
---|
9 | AC_HELP_STRING( |
---|
10 | --with-ruby=PATH, |
---|
11 | [ path to the ruby interpreter [[ruby]] ]), |
---|
12 | [ RUBY=$withval ], |
---|
13 | [ RUBY=ruby ]) |
---|
14 | AC_ARG_WITH( |
---|
15 | ruby_sitelibdir, |
---|
16 | AC_HELP_STRING( |
---|
17 | --with-ruby-sitelibdir=PATH, |
---|
18 | [ path to install ruby scripts [[auto-detect]] ]), |
---|
19 | [ ruby_sitelibdir=$withval ], |
---|
20 | [ ruby_sitelibdir=NONE ]) |
---|
21 | |
---|
22 | AC_SUBST(RUBY) |
---|
23 | |
---|
24 | RUBY_VERSION_CODE=`$RUBY -e "puts RUBY_VERSION.gsub(/\./, '')"` |
---|
25 | AC_SUBST(RUBY_VERSION_CODE) |
---|
26 | |
---|
27 | RUBY_CONFIG_SO_NAME=`RUBY_CONFIG(RUBY_SO_NAME)` |
---|
28 | RUBY_CONFIG_ARCHDIR=`RUBY_CONFIG(archdir)` |
---|
29 | RUBY_CONFIG_ARCH=`RUBY_CONFIG(arch)` |
---|
30 | RUBY_CONFIG_LIBDIR=`RUBY_CONFIG(libdir)` |
---|
31 | RUBY_CONFIG_BINDIR=`RUBY_CONFIG(bindir)` |
---|
32 | RUBY_CONFIG_RUBYHDRDIR=`RUBY_CONFIG(rubyhdrdir)` |
---|
33 | RUBY_CONFIG_CFLAGS=`RUBY_CONFIG(CFLAGS)` |
---|
34 | RUBY_CONFIG_LIBS=`RUBY_CONFIG(LIBS)` |
---|
35 | RUBY_CONFIG_DLDLIBS=`RUBY_CONFIG(DLDLIBS)` |
---|
36 | RUBY_CONFIG_LDFLAGS=`RUBY_CONFIG(LDFLAGS)` |
---|
37 | RUBY_CONFIG_LIBRUBYARG=`RUBY_CONFIG(LIBRUBYARG)` |
---|
38 | RUBY_CONFIG_LIBRUBYARG_STATIC=`RUBY_CONFIG(LIBRUBYARG_STATIC)` |
---|
39 | RUBY_CONFIG_CCDLFLAGS=`RUBY_CONFIG(CCDLFLAGS)` |
---|
40 | |
---|
41 | if test "x${RUBY_CONFIG_RUBYHDRDIR}x" != "xx"; then |
---|
42 | # 1.9 |
---|
43 | RUBY_CPPFLAGS="-I${RUBY_CONFIG_RUBYHDRDIR}" |
---|
44 | RUBY_CPPFLAGS="${RUBY_CPPFLAGS} -I${RUBY_CONFIG_RUBYHDRDIR}/${RUBY_CONFIG_ARCH}" |
---|
45 | else |
---|
46 | # 1.8 |
---|
47 | RUBY_CPPFLAGS="-I${RUBY_CONFIG_ARCHDIR}" |
---|
48 | fi |
---|
49 | AC_SUBST(RUBY_CPPFLAGS) |
---|
50 | |
---|
51 | RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}" |
---|
52 | AC_SUBST(RUBY_CFLAGS) |
---|
53 | |
---|
54 | RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}" |
---|
55 | AC_SUBST(RUBY_CXXFLAGS) |
---|
56 | |
---|
57 | RUBY_LDFLAGS="-L${RUBY_CONFIG_ARCHDIR} -L${RUBY_CONFIG_LIBDIR} ${RUBY_CONFIG_LDFLAGS}" |
---|
58 | AC_SUBST(RUBY_LDFLAGS) |
---|
59 | |
---|
60 | RUBY_LIBS="${RUBY_CONFIG_LIBS} ${RUBY_CONFIG_DLDLIBS}" |
---|
61 | AC_SUBST(RUBY_LIBS) |
---|
62 | |
---|
63 | RUBY_LIBRUBYARG="${RUBY_CONFIG_LIBRUBYARG}" |
---|
64 | AC_SUBST(RUBY_LIBRUBYARG) |
---|
65 | |
---|
66 | RUBY_LIBRUBYARG_STATIC="${RUBY_CONFIG_LIBRUBYARG_STATIC}" |
---|
67 | AC_SUBST(RUBY_LIBRUBYARG_STATIC) |
---|
68 | |
---|
69 | dnl If the user specified a prefix, then use it, otherwise defalut to |
---|
70 | dnl the configured sitelibdir |
---|
71 | if test "x${ruby_sitelibdir}x" != "xNONEx" |
---|
72 | then |
---|
73 | RUBY_SITELIBDIR="${ruby_sitelibdir}" |
---|
74 | else |
---|
75 | if test "x${prefix}x" = "xNONEx" |
---|
76 | then |
---|
77 | RUBY_SITELIBDIR=`RUBY_CONFIG(sitelibdir)` |
---|
78 | else |
---|
79 | sitelibdir_no_prefix=`$RUBY -rrbconfig \ |
---|
80 | -e "include Config; \ |
---|
81 | puts CONFIG[['sitelibdir']].sub(CONFIG[['prefix']], '')"` |
---|
82 | RUBY_SITELIBDIR="${prefix}/${sitelibdir_no_prefix}" |
---|
83 | fi |
---|
84 | fi |
---|
85 | AC_SUBST(RUBY_SITELIBDIR) |
---|
86 | |
---|
87 | dnl The fourth parameter to AC_CHECK_HEADER keeps autoconf from |
---|
88 | dnl searching for standard header files as a side-effect (which we want) |
---|
89 | CPPFLAGS_save="${CPPFLAGS}" |
---|
90 | CPPFLAGS="${CPPFLAGS} ${RUBY_CPPFLAGS}" |
---|
91 | CXXFLAGS="${CPPFLAGS}" |
---|
92 | AC_CHECK_HEADERS(ruby.h) |
---|
93 | HAVE_RUBY_H=${ac_cv_header_ruby_h} |
---|
94 | AC_SUBST(HAVE_RUBY_H) |
---|
95 | |
---|
96 | AC_CHECK_HEADERS(node.h,,,[ |
---|
97 | #include <ruby.h> |
---|
98 | ]) |
---|
99 | AC_CHECK_HEADERS(ruby/node.h, |
---|
100 | [ AC_DEFINE(REALLY_HAVE_RUBY_NODE_H, [], |
---|
101 | [ Define this macro to use ruby/node.h ]) ], |
---|
102 | ,[ |
---|
103 | #include <ruby.h> |
---|
104 | ]) |
---|
105 | AC_CHECK_HEADERS(version.h,,,[ |
---|
106 | #include <ruby.h> |
---|
107 | ]) |
---|
108 | AC_CHECK_HEADERS(env.h,,,[ |
---|
109 | #include <ruby.h> |
---|
110 | ]) |
---|
111 | |
---|
112 | CPPFLAGS="${CPPFLAGS_save}" |
---|
113 | |
---|
114 | AC_MINGW32 |
---|
115 | |
---|
116 | if test x"${MINGW32}"x = xyesx; then |
---|
117 | RB_FIX_MINGW_LIBS |
---|
118 | fi |
---|
119 | |
---|
120 | ]) dnl RB_INIT_RUBY |
---|
121 | |
---|
122 | dnl We would like to be able to build using MingW against the one-click |
---|
123 | dnl installer, which is built using VC6. So, we detect this situation |
---|
124 | dnl and fix up the link step if this is the case. |
---|
125 | dnl |
---|
126 | dnl Static linking isn't likely to work correctly, so we disable it by |
---|
127 | dnl default, but if the user asks for LIBRUBYARG_STATIC, they'll still |
---|
128 | dnl get static linking. |
---|
129 | AC_DEFUN([RB_FIX_MINGW_LIBS], [ |
---|
130 | RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%oldnames.lib%-lmoldname%"` |
---|
131 | RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%user32.lib%-luser32%"` |
---|
132 | RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%advapi32.lib%-ladvapi32%"` |
---|
133 | RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%ws2_32.lib%-lws2_32%"` |
---|
134 | RUBY_LIBRUBYARG=`echo ${RUBY_LIBRUBYARG} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_BINDIR}/\1.dll%"` |
---|
135 | RUBY_LIBRUBYARG_STATIC=`echo ${RUBY_LIBRUBYARG_STATIC} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_LIBDIR}/\1.lib%"` |
---|
136 | ]) dnl RB_FIX_MINGW_LIBS |
---|
137 | |
---|
138 | dnl vim:ft=config |
---|