@@ -45,6 +45,16 @@ def sqlcipher?
4545 def configure_system_libraries
4646 pkg_config ( libname )
4747 append_cppflags ( "-DUSING_SQLCIPHER" ) if sqlcipher?
48+
49+ if find_header ( "sqlite3.h" )
50+ # noop
51+ elsif sqlcipher? && find_header ( "sqlcipher/sqlite3.h" )
52+ append_cppflags ( "-DUSING_SQLCIPHER_INC_SUBDIR" )
53+ else
54+ abort_could_not_find ( "sqlite3.h" )
55+ end
56+
57+ abort_could_not_find ( libname ) unless find_library ( libname , "sqlite3_libversion_number" , "sqlite3.h" )
4858 end
4959
5060 def configure_packaged_libraries
@@ -65,29 +75,9 @@ def configure_packaged_libraries
6575 unless File . exist? ( File . join ( recipe . target , recipe . host , recipe . name , recipe . version ) )
6676 recipe . cook
6777 end
68- recipe . activate
69-
70- # on macos, pkg-config will not return --cflags without this
71- ENV [ "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS" ] = "t"
72-
73- # only needed for Ruby 3.1.3, see https://bugs.ruby-lang.org/issues/19233
74- RbConfig ::CONFIG [ "PKG_CONFIG" ] = config_string ( "PKG_CONFIG" ) || "pkg-config"
75-
76- lib_path = File . join ( recipe . path , "lib" )
77- pcfile = File . join ( lib_path , "pkgconfig" , "sqlite3.pc" )
78- abort_pkg_config ( "pkg_config" ) unless pkg_config ( pcfile )
79-
80- # see https://bugs.ruby-lang.org/issues/18490
81- ldflags = xpopen ( [ "pkg-config" , "--libs" , "--static" , pcfile ] , err : [ :child , :out ] , &:read )
82- abort_pkg_config ( "xpopen" ) unless $?. success?
83- ldflags = ldflags . split
84-
85- # see https://github.com/flavorjones/mini_portile/issues/118
86- "-L#{ lib_path } " . tap do |lib_path_flag |
87- ldflags . prepend ( lib_path_flag ) unless ldflags . include? ( lib_path_flag )
88- end
8978
90- ldflags . each { |ldflag | append_ldflags ( ldflag ) }
79+ recipe . mkmf_config ( pkg : libname , static : libname )
80+ have_func ( "sqlite3_libversion_number" , "sqlite3.h" ) || abort_could_not_find ( libname )
9181 end
9282 end
9383
@@ -98,16 +88,6 @@ def configure_extension
9888
9989 append_cflags ( "-fvisibility=hidden" ) # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
10090
101- if find_header ( "sqlite3.h" )
102- # noop
103- elsif sqlcipher? && find_header ( "sqlcipher/sqlite3.h" )
104- append_cppflags ( "-DUSING_SQLCIPHER_INC_SUBDIR" )
105- else
106- abort_could_not_find ( "sqlite3.h" )
107- end
108-
109- abort_could_not_find ( libname ) unless find_library ( libname , "sqlite3_libversion_number" , "sqlite3.h" )
110-
11191 # Functions defined in 1.9 but not 1.8
11292 have_func ( 'rb_proc_arity' )
11393
@@ -131,6 +111,8 @@ def configure_extension
131111 end
132112
133113 def minimal_recipe
114+ require "rubygems"
115+ gem "mini_portile2" , "2.8.5.rc2" # gemspec is not respected at install time
134116 require "mini_portile2"
135117
136118 MiniPortile . new ( libname , sqlite3_config [ :version ] ) . tap do |recipe |
0 commit comments