source: trunk/cf/rpLangRuby.m4 @ 5128

Last change on this file since 5128 was 3282, checked in by gah, 12 years ago

fixes for 1.9 ruby build

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