diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-07-06 14:06:15 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-07-06 14:06:15 -0700 |
commit | 8f1a1ee1c9ee1247ae53d885d91ab41d6ac3da86 (patch) | |
tree | 768cbc765ef95157105ad31ca09b9f6e35acaf99 /ext/ffi_yajl | |
parent | bb45b2de7e9fc22f6ebcec001a3bca9058fb722b (diff) | |
download | ffi-yajl-8f1a1ee1c9ee1247ae53d885d91ab41d6ac3da86.tar.gz |
avoid find_library adding -lyajl
Diffstat (limited to 'ext/ffi_yajl')
-rw-r--r-- | ext/ffi_yajl/ext/encoder/extconf.rb | 15 | ||||
-rw-r--r-- | ext/ffi_yajl/ext/parser/extconf.rb | 13 |
2 files changed, 12 insertions, 16 deletions
diff --git a/ext/ffi_yajl/ext/encoder/extconf.rb b/ext/ffi_yajl/ext/encoder/extconf.rb index e752b28..0107112 100644 --- a/ext/ffi_yajl/ext/encoder/extconf.rb +++ b/ext/ffi_yajl/ext/encoder/extconf.rb @@ -28,16 +28,12 @@ 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..." +# NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately +# avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen) +if !windows? && !find_header('yajl/yajl_tree.h') + puts "libyajl2 headers not found 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 @@ -54,7 +50,8 @@ if !windows? && !found_libyajl2 # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib dir_config('yajl', HEADER_DIRS, LIB_DIRS) - if !found_libyajl2 + # here we use find_library in order to deliberately link with -lyajl as a useful side-effect + if !(find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')) abort "libyajl2 is missing. please install libyajl2" end end diff --git a/ext/ffi_yajl/ext/parser/extconf.rb b/ext/ffi_yajl/ext/parser/extconf.rb index 3edc502..3154142 100644 --- a/ext/ffi_yajl/ext/parser/extconf.rb +++ b/ext/ffi_yajl/ext/parser/extconf.rb @@ -28,12 +28,10 @@ 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..." +# NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately +# avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen) +if !windows? && !find_header('yajl/yajl_tree.h') + puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..." HEADER_DIRS = [ "/opt/local/include", # MacPorts @@ -52,7 +50,8 @@ if !windows? && !found_libyajl2 # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib dir_config('yajl', HEADER_DIRS, LIB_DIRS) - if !found_libyajl2 + # here we use find_library in order to deliberately link with -lyajl as a useful side-effect + if !(find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')) abort "libyajl2 is missing. please install libyajl2" end end |