@@ -86,18 +86,40 @@ function _memcache()
8686 return memcache .cache (" package.tools.autoconf" )
8787end
8888
89- -- has `--with-pic`?
90- function _has_with_pic (package )
91- local has_with_pic = _memcache ():get2 (tostring (package ), " with_pic" )
92- if has_with_pic == nil then
89+ -- has flag ?
90+ function _has_flag (package , flag )
91+ local flag_name = flag :gsub (" -" , " " )
92+ local has_flag = _memcache ():get2 (tostring (package ), flag_name )
93+ if has_flag == nil then
9394 local result = try {function () return os .iorunv (" ./configure" , {" --help" }, {shell = true }) end }
94- if result and result :find (" --with-pic " , 1 , true ) then
95- has_with_pic = true
95+ if result and result :find (flag , 1 , true ) then
96+ has_flag = true
9697 end
97- has_with_pic = has_with_pic or false
98- _memcache ():set2 (tostring (package ), " with_pic " , has_with_pic )
98+ has_flag = has_flag or false
99+ _memcache ():set2 (tostring (package ), flag_name , has_flag )
99100 end
100- return has_with_pic
101+ return has_flag
102+ end
103+
104+
105+ -- has `--with-pic`?
106+ function _has_with_pic (package )
107+ return _has_flag (package , " --with-pic" )
108+ end
109+
110+ -- has `--enable-debug`?
111+ function _has_enable_debug (package )
112+ return _has_flag (package , " --enable-debug" )
113+ end
114+
115+ -- has `--enable-static` and `--enable-shared`?
116+ function _has_enable_kind (package )
117+ return _has_flag (package , " --enable-static" ) and _has_flag (package , " --enable-shared" )
118+ end
119+
120+ -- has `--disable-static` and `--disable-shared`?
121+ function _has_disable_kind (package )
122+ return _has_flag (package , " --disable-static" ) and _has_flag (package , " --disable-shared" )
101123end
102124
103125-- get configs
@@ -170,6 +192,21 @@ function _get_configs(package, configs)
170192 package :config (" pic" ) ~= false and _has_with_pic (package ) then
171193 table.insert (configs , " --with-pic" )
172194 end
195+ if package :is_debug () and _has_enable_debug (package ) then
196+ table.insert (configs , " --enable-debug" )
197+ end
198+ if package :is_library () then
199+ if _has_enable_kind (package ) then
200+ table.insert (configs , " --enable-shared=" .. (package :config (" shared" ) and " yes" or " no" ))
201+ table.insert (configs , " --enable-static=" .. (package :config (" shared" ) and " no" or " yes" ))
202+ elseif _has_disable_kind (package ) then
203+ if package :config (" shared" ) then
204+ table.insert (configs , " --disable-static" )
205+ else
206+ table.insert (configs , " --disable-shared" )
207+ end
208+ end
209+ end
173210 return configs
174211end
175212
0 commit comments