source: trunk/cf/rpLangRuby.m4 @ 3277

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