@@ -37,56 +37,58 @@ def msvc?
3737 /mswin/ . match ( RUBY_PLATFORM ) and /^cl\b / . match ( RbConfig ::CONFIG [ "CC" ] )
3838 end
3939
40- def package_config ( package )
40+ def package_config ( package , ** options )
4141 PackageConfig . new ( package ,
42- :msvc_syntax => msvc? ,
43- :override_variables => @@override_variables ,
44- :paths => @@paths )
42+ {
43+ msvc_syntax : msvc? ,
44+ override_variables : @@override_variables ,
45+ paths : @@paths ,
46+ } . merge ( options ) )
4547 end
4648
47- def exist? ( pkg )
48- package_config ( pkg ) . exist?
49+ def exist? ( pkg , ** options )
50+ package_config ( pkg , ** options ) . exist?
4951 end
5052
51- def libs ( pkg )
52- package_config ( pkg ) . libs
53+ def libs ( pkg , ** options )
54+ package_config ( pkg , ** options ) . libs
5355 end
5456
55- def libs_only_l ( pkg )
56- package_config ( pkg ) . libs_only_l
57+ def libs_only_l ( pkg , ** options )
58+ package_config ( pkg , ** options ) . libs_only_l
5759 end
5860
59- def libs_only_L ( pkg )
60- package_config ( pkg ) . libs_only_L
61+ def libs_only_L ( pkg , ** options )
62+ package_config ( pkg , ** options ) . libs_only_L
6163 end
6264
63- def cflags ( pkg )
64- package_config ( pkg ) . cflags
65+ def cflags ( pkg , ** options )
66+ package_config ( pkg , ** options ) . cflags
6567 end
6668
67- def cflags_only_I ( pkg )
68- package_config ( pkg ) . cflags_only_I
69+ def cflags_only_I ( pkg , ** options )
70+ package_config ( pkg , ** options ) . cflags_only_I
6971 end
7072
71- def cflags_only_other ( pkg )
72- package_config ( pkg ) . cflags_only_other
73+ def cflags_only_other ( pkg , ** options )
74+ package_config ( pkg , ** options ) . cflags_only_other
7375 end
7476
75- def modversion ( pkg )
76- package_config ( pkg ) . version
77+ def modversion ( pkg , ** options )
78+ package_config ( pkg , ** options ) . version
7779 end
7880
79- def description ( pkg )
80- package_config ( pkg ) . description
81+ def description ( pkg , ** options )
82+ package_config ( pkg , ** options ) . description
8183 end
8284
83- def variable ( pkg , name )
84- package_config ( pkg ) . variable ( name )
85+ def variable ( pkg , name , ** options )
86+ package_config ( pkg , ** options ) . variable ( name )
8587 end
8688
87- def check_version? ( pkg , major = 0 , minor = 0 , micro = 0 )
88- return false unless exist? ( pkg )
89- ver = modversion ( pkg ) . split ( "." ) . collect { |item | item . to_i }
89+ def check_version? ( pkg , major = 0 , minor = 0 , micro = 0 , ** options )
90+ return false unless exist? ( pkg , ** options )
91+ ver = modversion ( pkg , ** options ) . split ( "." ) . collect { |item | item . to_i }
9092 ( 0 ..2 ) . each { |i | ver [ i ] = 0 unless ver [ i ] }
9193
9294 ( ver [ 0 ] > major ||
@@ -95,27 +97,27 @@ def check_version?(pkg, major=0, minor=0, micro=0)
9597 ver [ 2 ] >= micro ) )
9698 end
9799
98- def have_package ( pkg , major = nil , minor = 0 , micro = 0 )
100+ def have_package ( pkg , major = nil , minor = 0 , micro = 0 , ** options )
99101 message = "#{ pkg } "
100102 unless major . nil?
101103 message << " version (>= #{ major } .#{ minor } .#{ micro } )"
102104 end
103105 major ||= 0
104106 result = checking_for ( checking_message ( message ) , "%s" ) do
105- if check_version? ( pkg , major , minor , micro )
106- "yes (#{ modversion ( pkg ) } )"
107+ if check_version? ( pkg , major , minor , micro , ** options )
108+ "yes (#{ modversion ( pkg , ** options ) } )"
107109 else
108- if exist? ( pkg )
109- "no (#{ modversion ( pkg ) } )"
110+ if exist? ( pkg , ** options )
111+ "no (#{ modversion ( pkg , ** options ) } )"
110112 else
111113 "no (nonexistent)"
112114 end
113115 end
114116 end
115117 enough_version = result . start_with? ( "yes" )
116118 if enough_version
117- libraries = libs_only_l ( pkg )
118- dldflags = libs ( pkg )
119+ libraries = libs_only_l ( pkg , ** options )
120+ dldflags = libs ( pkg , ** options )
119121 dldflags = ( Shellwords . shellwords ( dldflags ) -
120122 Shellwords . shellwords ( libraries ) )
121123 dldflags = dldflags . map { |s | /\s / =~ s ? "\" #{ s } \" " : s } . join ( " " )
@@ -125,11 +127,11 @@ def have_package(pkg, major=nil, minor=0, micro=0)
125127 else
126128 $LDFLAGS += " " + dldflags
127129 end
128- $CFLAGS += " " + cflags_only_other ( pkg )
130+ $CFLAGS += " " + cflags_only_other ( pkg , ** options )
129131 if defined? ( $CXXFLAGS)
130- $CXXFLAGS += " " + cflags_only_other ( pkg )
132+ $CXXFLAGS += " " + cflags_only_other ( pkg , ** options )
131133 end
132- $INCFLAGS += " " + cflags_only_I ( pkg )
134+ $INCFLAGS += " " + cflags_only_I ( pkg , ** options )
133135 end
134136 enough_version
135137 end
@@ -408,6 +410,7 @@ def initialize(name, options={})
408410 @paths . unshift ( *( @options [ :paths ] || [ ] ) )
409411 @paths = normalize_paths ( @paths )
410412 @msvc_syntax = @options [ :msvc_syntax ]
413+ @static = @options [ :static ]
411414 @variables = @declarations = nil
412415 override_variables = self . class . custom_override_variables
413416 @override_variables = parse_override_variables ( override_variables )
@@ -528,7 +531,12 @@ def collect_requires(&block)
528531
529532 private
530533 def collect_cflags
531- target_packages = [ self , *all_required_packages ]
534+ target_packages = [ self ]
535+ if @static
536+ target_packages += all_required_packages
537+ else
538+ target_packages += required_packages
539+ end
532540 cflags_set = [ ]
533541 target_packages . each do |package |
534542 cflags_set << package . declaration ( "Cflags" )
@@ -580,7 +588,12 @@ def normalize_cflags(cflags)
580588 end
581589
582590 def collect_libs
583- target_packages = [ *required_packages , self ]
591+ if @static
592+ target_packages = all_required_packages
593+ else
594+ target_packages = required_packages
595+ end
596+ target_packages += [ self ]
584597 libs_set = [ ]
585598 target_packages . each do |package |
586599 libs_set << package . declaration ( "Libs" )
0 commit comments