[PATCH 2/3] build: add support to build Ruby bindings
Felipe Contreras
felipe.contreras at gmail.com
Fri May 23 03:34:26 PDT 2014
So there's no need for the user to manually do that.
Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
bindings/ruby/Makefile.local | 21 +++++++++++++++++++++
bindings/ruby/extconf.rb | 14 ++------------
configure | 21 +++++++++++++++++++++
3 files changed, 44 insertions(+), 12 deletions(-)
create mode 100644 bindings/ruby/Makefile.local
diff --git a/bindings/ruby/Makefile.local b/bindings/ruby/Makefile.local
new file mode 100644
index 0000000..8b1837c
--- /dev/null
+++ b/bindings/ruby/Makefile.local
@@ -0,0 +1,21 @@
+dir := bindings/ruby
+
+ifeq ($(WITH_RUBY),1)
+all: $(dir)/notmuch.so
+install: install-ruby
+clean: clean-ruby
+endif
+
+$(dir)/Makefile: $(dir)/extconf.rb
+ @ruby -C $(dir) extconf.rb --vendor
+
+$(dir)/notmuch.so: | $(dir)/Makefile lib/libnotmuch.so
+ @$(MAKE) -C $(dir) notmuch.so
+
+install-ruby: | $(dir)/Makefile
+ @$(MAKE) -C $(dir) install prefix=$(DESTDIR)/$(prefix)
+
+clean-ruby: | $(dir)/Makefile
+ $(MAKE) -C $(dir) clean
+
+.PHONY: install-ruby
diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb
index 6160db2..abd67fc 100644
--- a/bindings/ruby/extconf.rb
+++ b/bindings/ruby/extconf.rb
@@ -13,18 +13,8 @@ $INCFLAGS = "-I#{dir} #{$INCFLAGS}"
# make sure there are no undefined symbols
$LDFLAGS += ' -Wl,--no-undefined'
-def have_local_library(lib, path, func, headers = nil)
- checking_for checking_message(func, lib) do
- lib = File.join(path, lib)
- if try_func(func, lib, headers)
- $LOCAL_LIBS += lib
- end
- end
-end
-
-if not have_local_library('libnotmuch.so', dir, 'notmuch_database_create', 'notmuch.h')
- exit 1
-end
+# library
+$LOCAL_LIBS += "#{dir}/libnotmuch.so"
# Create Makefile
dir_config('notmuch')
diff --git a/configure b/configure
index 9bde2eb..3bdf6d7 100755
--- a/configure
+++ b/configure
@@ -21,6 +21,7 @@ srcdir=$(dirname "$0")
subdirs="util compat lib parse-time-string completion doc emacs"
subdirs="${subdirs} performance-test test test/test-databases"
+subdirs="${subdirs} bindings/ruby"
# For a non-srcdir configure invocation (such as ../configure), create
# the directory structure and copy Makefiles.
@@ -65,6 +66,7 @@ LIBDIR=
WITH_EMACS=1
WITH_BASH=1
WITH_ZSH=1
+WITH_RUBY=1
# Compatible GMime versions (with constraints).
# If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a
@@ -212,6 +214,14 @@ for option; do
elif [ "${option#*=}" = '2.6' ]; then
WITH_GMIME_VERSIONS=$GMIME_26_VERSION
fi
+ elif [ "${option%%=*}" = '--with-ruby' ]; then
+ if [ "${option#*=}" = 'no' ]; then
+ WITH_RUBY=0
+ else
+ WITH_RUBY=1
+ fi
+ elif [ "${option}" = '--without-ruby' ] ; then
+ WITH_RUBY=0
elif [ "${option%%=*}" = '--build' ] ; then
true
elif [ "${option%%=*}" = '--host' ] ; then
@@ -383,6 +393,14 @@ else
WITH_BASH=0
fi
+printf "Checking for ruby... "
+if pkg-config --exists ruby-2.1; then
+ printf "Yes.\n"
+else
+ printf "No (will not install Ruby bindings).\n"
+ WITH_RUBY=0
+fi
+
if [ -z "${EMACSLISPDIR}" ]; then
if pkg-config --exists emacs; then
EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
@@ -906,6 +924,9 @@ WITH_BASH = ${WITH_BASH}
# Support for zsh completion
WITH_ZSH = ${WITH_ZSH}
+# Support for Ruby
+WITH_RUBY = ${WITH_RUBY}
+
# Combined flags for compiling and linking against all of the above
CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
-DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\
--
1.9.3+fc1~5~gfaddd51
More information about the notmuch
mailing list