summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-07-06 13:12:54 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-07-06 13:12:54 -0700
commit521e4de22d2e689d714f6abf4e296ebe2161ec1c (patch)
treee624dd4948c0ed4d7dc927afb76eb1763c142d9b /ext
parentcfb7f95130410d687aaea80e883e1c2d35cbd40e (diff)
downloadffi-yajl-521e4de22d2e689d714f6abf4e296ebe2161ec1c.tar.gz
build with system libs if libyajl2-gem missing libs
libyajl2-gem with USE_SYSTEM_LIBYAJL2=1 is just missing the libs and includes in the path, so if we can't find libyajl2 after setting up the libyajl2-gem, then go hunting for libyajl2 in the system and/or use the --with-yajl-include/dir/lib options
Diffstat (limited to 'ext')
-rw-r--r--ext/ffi_yajl/ext/encoder/extconf.rb31
-rw-r--r--ext/ffi_yajl/ext/parser/extconf.rb31
2 files changed, 62 insertions, 0 deletions
diff --git a/ext/ffi_yajl/ext/encoder/extconf.rb b/ext/ffi_yajl/ext/encoder/extconf.rb
index 9d048ee..e752b28 100644
--- a/ext/ffi_yajl/ext/encoder/extconf.rb
+++ b/ext/ffi_yajl/ext/encoder/extconf.rb
@@ -28,6 +28,37 @@ if windows?
$libs = "#{$libs} -lyajldll"
end
+def found_libyajl2
+ find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
+end
+
+if !windows? && !found_libyajl2
+ puts "libyajl2 not embedded in libyajl2-gem, searching for system libraries..."
+
+ HEADER_DIRS = [
+ # FIXME: embedded version number in Homebrew path will change
+ "/usr/local/Cellar/yajl/2.1.0/include", # Homebrew (yick)
+ "/opt/local/include", # MacPorts
+ "/usr/local/include", # /usr/local
+ RbConfig::CONFIG['includedir'], # Ruby
+ "/usr/include", # (default)
+ ]
+
+ LIB_DIRS = [
+ "/opt/local/lib", # MacPorts
+ "/usr/local/lib", # /usr/local + Homebrew
+ RbConfig::CONFIG['libdir'], # Ruby
+ "/usr/lib", # (default)
+ ]
+
+ # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
+ dir_config('yajl', HEADER_DIRS, LIB_DIRS)
+
+ if !found_libyajl2
+ abort "libyajl2 is missing. please install libyajl2"
+ end
+end
+
dir_config 'encoder'
create_makefile 'ffi_yajl/ext/encoder'
diff --git a/ext/ffi_yajl/ext/parser/extconf.rb b/ext/ffi_yajl/ext/parser/extconf.rb
index 602f679..e5ff74d 100644
--- a/ext/ffi_yajl/ext/parser/extconf.rb
+++ b/ext/ffi_yajl/ext/parser/extconf.rb
@@ -28,6 +28,37 @@ if windows?
$libs = "#{$libs} -lyajldll"
end
+def found_libyajl2
+ find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
+end
+
+if !windows? && !found_libyajl2
+ puts "libyajl2 not embedded in libyajl2-gem, searching for system libraries..."
+
+ HEADER_DIRS = [
+ # FIXME: embedded version number in Homebrew path will change
+ "/usr/local/Cellar/yajl/2.1.0/include", # Homebrew (yick)
+ "/opt/local/include", # MacPorts
+ "/usr/local/include", # /usr/local
+ RbConfig::CONFIG['includedir'], # Ruby
+ "/usr/include", # (default)
+ ]
+
+ LIB_DIRS = [
+ "/opt/local/lib", # MacPorts
+ "/usr/local/lib", # /usr/local + Homebrew
+ RbConfig::CONFIG['libdir'], # Ruby
+ "/usr/lib", # (default)
+ ]
+
+ # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
+ dir_config('yajl', HEADER_DIRS, LIB_DIRS)
+
+ if !found_libyajl2
+ abort "libyajl2 is missing. please install libyajl2"
+ end
+end
+
dir_config 'parser'
create_makefile 'ffi_yajl/ext/parser'