]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/ruby/extconf.rb
Merge branch 'release'
[notmuch] / bindings / ruby / extconf.rb
index 933f34a98db3e57d940bd39f68302843b6aa3d77..6160db26e2ea10286fb16065c2c030ea90a0c07e 100644 (file)
@@ -5,28 +5,27 @@
 
 require 'mkmf'
 
-NOTDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
-NOTHDR = File.join(NOTDIR, 'notmuch.h')
-NOTLIB = File.join(NOTDIR, 'libnotmuch.a')
+dir = File.join('..', '..', 'lib')
 
-unless File.exists? NOTHDR
-  $stderr.puts "notmuch.h is missing under #{NOTDIR}"
-  exit 1
+# includes
+$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
 
-unless File.exists? NOTLIB
-  $stderr.puts "libnotmuch.a is missing under #{NOTDIR}"
+if not have_local_library('libnotmuch.so', dir, 'notmuch_database_create', 'notmuch.h')
   exit 1
 end
 
-# Small hack to build with in-tree version not the installed one.
-# find_header() and friends use standard include/library paths first.
-$stderr.puts "Added -I#{NOTDIR} to $INCFLAGS"
-$INCFLAGS = "-I#{NOTDIR}".quote + " " + $INCFLAGS
-find_header('notmuch.h', NOTDIR)
-
-$LOCAL_LIBS += NOTLIB
-
 # Create Makefile
 dir_config('notmuch')
 create_makefile('notmuch')