source: trunk/cf/rpLangRuby.m4 @ 3281

Last change on this file since 3281 was 3281, checked in by gah, 8 years ago

fixes for 1.9 ruby build

File size: 4.2 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)
93if test "x${ac_cv_header_ruby_h}" != "x" ; then
94  HAVE_RUBY_H=yes
95  AC_CHECK_HEADERS(node.h,,,[
96#include <ruby.h>
97  ])
98  AC_CHECK_HEADERS(ruby/node.h,
99    [ AC_DEFINE(REALLY_HAVE_RUBY_NODE_H, [],
100    [ Define this macro to use ruby/node.h ]) ],
101                             ,[
102                             #include <ruby.h>
103  ])
104  AC_CHECK_HEADERS(version.h,,,[
105#include <ruby.h>
106  ])
107  AC_CHECK_HEADERS(env.h,,,[
108  #include <ruby.h>
109  ])
110else
111  HAVE_RUBY_H=no
112fi
113AC_SUBST(HAVE_RUBY_H)
114
115CPPFLAGS="${CPPFLAGS_save}"
116
117AC_MINGW32
118
119if test x"${MINGW32}"x = xyesx; then
120  RB_FIX_MINGW_LIBS
121fi
122
123]) dnl RB_INIT_RUBY
124
125dnl We would like to be able to build using MingW against the one-click
126dnl installer, which is built using VC6.  So, we detect this situation
127dnl and fix up the link step if this is the case.
128dnl
129dnl Static linking isn't likely to work correctly, so we disable it by
130dnl default, but if the user asks for LIBRUBYARG_STATIC, they'll still
131dnl get static linking.
132AC_DEFUN([RB_FIX_MINGW_LIBS], [
133RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%oldnames.lib%-lmoldname%"`
134RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%user32.lib%-luser32%"`
135RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%advapi32.lib%-ladvapi32%"`
136RUBY_LIBS=`echo ${RUBY_LIBS} | sed -e "s%ws2_32.lib%-lws2_32%"`
137RUBY_LIBRUBYARG=`echo ${RUBY_LIBRUBYARG} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_BINDIR}/\1.dll%"`
138RUBY_LIBRUBYARG_STATIC=`echo ${RUBY_LIBRUBYARG_STATIC} | sed -e "s%\(msvcrt-ruby.*\).lib%${RUBY_CONFIG_LIBDIR}/\1.lib%"`
139]) dnl RB_FIX_MINGW_LIBS
140
141dnl vim:ft=config
Note: See TracBrowser for help on using the repository browser.