File: ruby.m4

package info (click to toggle)
swftools 0.9.2%2Bgit20130725-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,680 kB
  • ctags: 17,348
  • sloc: ansic: 108,712; sh: 8,494; cpp: 8,040; yacc: 2,260; lisp: 904; makefile: 601; python: 300
file content (94 lines) | stat: -rw-r--r-- 2,794 bytes parent folder | download | duplicates (3)
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
AC_DEFUN([RFX_CHECK_RUBY],
[
AC_PATH_PROG([RUBY], [ruby],,)

RUBY_CPPFLAGS=""
RUBY_LDFLAGS=""
RUBY_LIBS=""

rubylib=ruby18

AC_MSG_CHECKING([for ruby's include directory])
if test "x$RUBY" '!=' "x";then
    rubyinc=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "archdir"))' 2>/dev/null`
    if test -d $rubyinc;then
	AC_MSG_RESULT($rubyinc)

	# If we got a sensible archdir, we also ask ruby to supply us with CPPFLAGS
	# and LDFLAGS.
	AC_MSG_CHECKING([for ruby's cpp flags])
	rubycpp=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "CPPFLAGS"))' 2>/dev/null`
	AC_MSG_RESULT($rubycpp)
	
	AC_MSG_CHECKING([for ruby's ld flags])
	rubyld=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBYARG_SHARED"))' 2>/dev/null`
	rubyld2=`$RUBY -e 'require "rbconfig";v=Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBY_LDSHARED"));puts v.gsub(/^g?cc/,"")' 2>/dev/null`
	AC_MSG_RESULT("$rubyld $rubyld2")
	
	AC_MSG_CHECKING([for ruby library name])
	rubylib=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "RUBY_SO_NAME"))' 2>/dev/null`
	AC_MSG_RESULT($rubylib)
	
	RUBY_CPPFLAGS="$rubycpp -I$rubyinc $RUBY_CPPFLAGS"
	RUBY_LDFLAGS="$rubyld $rubyld2 $RUBY_LDFLAGS"
	RUBY_INSTALLDIR="$rubyinc"
    else
	AC_MSG_RESULT('unknown')
    fi
else
    AC_MSG_RESULT('unknown')
fi

#OLDLDFLAGS="$LDFLAGS"
#LDFLAGS="$LDFLAGS $RUBY_LDFLAGS"
#AC_CHECK_LIB($rubylib, rb_define_method, HAVE_RUBY_LIB=1,)
#LDFLAGS="$OLDLDFLAGS"

OLDCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
AC_CHECK_HEADERS([ruby.h],[HAVE_RUBY_H=1])
CPPFLAGS="$OLDCPPFLAGS"

AC_MSG_CHECKING([whether we should compile the ruby module])
if test "x${HAVE_RUBY_H}" '!=' "x";then
    #RUBY_LIBS="$RUBY_LIBS -l$rubylib"

    cat > conftest.c << EOF
#include <ruby.h>
static VALUE foobar;
VALUE foobar_set_foo(VALUE module, VALUE _key, VALUE _value)
{
    return Qnil;
}
int Init_foobar()
{
    foobar = rb_define_module("foobar");
    rb_define_module_function(foobar, "set_foo", foobar_set_foo, 2);
    return 0;
}
int main() {return 0;}
EOF
    ac_link='$CC $SHARED $CPPFLAGS $RUBY_CPPFLAGS $CFLAGS conftest.c $LDFLAGS $RUBY_LDFLAGS $LIBS $RUBY_LIBS -o conftest${SLEXT}'
    if { (eval echo ruby.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${SLEXT}; then
	RUBY_OK=yes
    else
        echo "configure: failed program was:" >&5
        cat conftest.c >&5
    fi
    rm -f conftest*
fi

if test "x${RUBY_OK}" '=' "xyes"; then 
    AC_MSG_RESULT([yes])
    AC_SUBST(RUBY_LIBS)
    AC_SUBST(RUBY_CPPFLAGS)
    AC_SUBST(RUBY_LDFLAGS)
    AC_SUBST(RUBY_INSTALLDIR)
else
    AC_MSG_RESULT([no])
    RUBY_CPPFLAGS=""
    RUBY_LDFLAGS=""
    RUBY_LIBS=""
    RUBY_INSTALLDIR=""
fi
])