configure: Use pkg-config to determine Ruby CFLAGS/LIBS
authorTobias Brunner <tobias@strongswan.org>
Wed, 7 Jun 2017 14:22:11 +0000 (16:22 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 7 Jun 2017 14:48:02 +0000 (16:48 +0200)
configure.ac
src/dumm/Makefile.am
src/dumm/ext/dumm.c
src/dumm/irdumm.c

index 1ca254e..e4832b3 100644 (file)
@@ -1011,37 +1011,9 @@ if test x$dumm = xtrue; then
        AC_SUBST(gtk_CFLAGS)
        AC_SUBST(gtk_LIBS)
        AC_CHECK_PROGS(RUBY, ruby)
-       AC_MSG_CHECKING([for Ruby header files])
-       if test -n "$RUBY"; then
-               RUBYINCLUDE=
-               RUBYDIR=`($RUBY -r rbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || ""') 2>/dev/null`
-               if test -n "$RUBYDIR" -a -r "$RUBYDIR/ruby.h"; then
-                       RUBYARCH=`($RUBY -r rbconfig -e 'print RbConfig::CONFIG[["arch"]] || ""') 2>/dev/null`
-                       if test -n "$RUBYARCH"; then
-                               AC_MSG_RESULT([$RUBYDIR])
-                               RUBYINCLUDE="-I$RUBYDIR -I$RUBYDIR/$RUBYARCH"
-                       fi
-               else
-                       RUBYDIR=`($RUBY -r rbconfig -e 'print RbConfig::CONFIG[["archdir"]] || ""') 2>/dev/null`
-                       if test -n "$RUBYDIR" -a -r "$RUBYDIR/ruby.h"; then
-                               AC_MSG_RESULT([$RUBYDIR])
-                               RUBYINCLUDE="-I$RUBYDIR"
-                       fi
-               fi
-               if test -z "$RUBYINCLUDE"; then
-                       AC_MSG_ERROR([ruby.h not found])
-               fi
-               AC_SUBST(RUBYINCLUDE)
-       else
-               AC_MSG_ERROR([don't know how to run ruby])
-       fi
-       AC_MSG_CHECKING([for libruby])
+       PKG_CHECK_MODULES(ruby, [ruby])
        saved_LIBS=$LIBS
-       LIBS=`($RUBY -r rbconfig -e 'print RbConfig::CONFIG[["LIBRUBYARG_SHARED"]] || ""') 2>/dev/null`
-       AC_TRY_LINK_FUNC(ruby_init,
-               [AC_MSG_RESULT([$LIBS]); RUBYLIB=$LIBS],
-               [AC_MSG_ERROR([not found])])
-       AC_SUBST(RUBYLIB)
+       LIBS=$ruby_LIBS
        AC_CHECK_FUNCS(rb_errinfo)
        LIBS=$saved_LIBS
 fi
index 1c6a68f..0d1cfb7 100644 (file)
@@ -11,15 +11,14 @@ irdumm_SOURCES = irdumm.c
 
 libdumm_la_LIBADD = -lbridge -lfuse -lutil $(top_builddir)/src/libstrongswan/libstrongswan.la
 dumm_LDADD = libdumm.la ${gtk_LIBS} $(top_builddir)/src/libstrongswan/libstrongswan.la
-irdumm_LDADD = libdumm.la ${RUBYLIB} $(top_builddir)/src/libstrongswan/libstrongswan.la
+irdumm_LDADD = libdumm.la ${ruby_LIBS} $(top_builddir)/src/libstrongswan/libstrongswan.la
 
 AM_CPPFLAGS = \
        -D_FILE_OFFSET_BITS=64 \
-       -I$(top_srcdir)/src/libstrongswan \
-       ${RUBYINCLUDE}
+       -I$(top_srcdir)/src/libstrongswan
 
-AM_CFLAGS = \
-       ${gtk_CFLAGS}
+dumm_CFLAGS = ${gtk_CFLAGS}
+irdumm_CFLAGS = ${ruby_CFLAGS}
 
 all-local: ext
 
index df7ec47..b898a25 100644 (file)
@@ -30,6 +30,8 @@
 #undef PACKAGE_STRING
 #undef PACKAGE_BUGREPORT
 #undef PACKAGE_URL
+#undef HAVE_DLADDR
+#undef HAVE_QSORT_R
 /* avoid redefintiion of snprintf etc. */
 #define RUBY_DONT_SUBST
 /* undef our _GNU_SOURCE, as it gets redefined by <ruby.h> */
index d309737..1a4235c 100644 (file)
@@ -19,6 +19,8 @@
 #undef PACKAGE_STRING
 #undef PACKAGE_BUGREPORT
 #undef PACKAGE_URL
+#undef HAVE_DLADDR
+#undef HAVE_QSORT_R
 #include <ruby.h>
 
 #ifdef HAVE_RB_ERRINFO