[PATCH 2/3] build: add support to build Ruby bindings

Wael Nasreddine wael.nasreddine at gmail.com
Fri May 23 08:04:57 PDT 2014


Felipe Contreras <felipe.contreras at gmail.com> writes:

> 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
Why don't you do an OR check for ruby 1.9, 2.0 and 2.1 allowing it to
build with any Ruby version?

> +    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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-------------- next part --------------
-- 
Wael Nasreddine | SRE at Google | wael.nasreddine at gmail.com | (650) 735-1773
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 180 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20140523/3f2a257a/attachment.pgp>


More information about the notmuch mailing list