1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # # "auto": check with pkg-config or so, show '--disable-xxx'
15 # # "": disabled by default, show '--enable-xxx'
16 # # non-empty string: enabled by default, show '--disable-xxx'
17 # -configure-enable-disable-vars- +=
18 # "sqlite" USE_SQLITE "auto" "don't use sqlite"
19 # "gtkhtml" USE_GTKHTML "auto" "don't use GTKHTML"
20 # "gtkspell" USE_GTKSPELL "auto" "don't use GTKSpell"
21 # "svg" USE_RSVG "auto" "don't use librsvg"
22 # "soup" USE_SOUP "auto" "don't use libsoup"
23 # "curl" USE_CURL "auto" "don't use libcurl"
24 # "dock" USE_DOCK "tan" "disable dock icon"
29 # $(2): option arg (if any)
30 rule -configure-show-default-help- {
32 Echo 'jam configure for package `' $(PROJECT_NAME) ''' supports:' : -S ;
34 Echo 'jam configure supports:' ;
36 Echo 'common options:' ;
37 Echo ' --prefix=dir install prefix: [/usr/local]' ;
38 if $(-configure-enable-disable-vars-) {
39 Echo 'package options:' ;
40 -configure-show-enable-disable-help- ;
42 if [ HaveRule -configure-user-help- ] { -configure-user-help- ; }
46 rule -configure-options-help- {
47 -configure-show-default-help- ;
52 rule -configure-options-prefix- {
54 Exit 'ERROR: --prefix needs argument!' ;
56 -configure-add-line- "PREFIX ?= $(2) ;" ;
57 Echo "MSG: prefix set to $(2)" ;
61 # will be called before -configure-
62 # can set CONFIGURE_DONT_PARSE_OPTIONS
63 rule -configure-preinit- {
67 rule -configure-add-line- {
70 if $(_CONFIGURE_FATAL_) != 'tan' {
72 Depends config : $(str) ;
73 -Action-Configure-WriteLine- $(str) ;
78 # $(1): library name to display
79 # $(2): arg to pkg-config
80 # $(3): string to write if present
81 # $(4): string to write if not present
82 # $(5): fail with this message if not present
83 # returns non-empty string if package exists
84 rule -configure-pkg-config- {
85 local flg lib ex res ;
87 if $(_CONFIGURE_FATAL_) != 'tan' {
88 Echo "checking for $(1) ... " : -n ;
89 ex = [ pkg-config-exists $(2) ] ;
92 -configure-add-line- '#' $(1) ;
93 flg = [ lib-config-ex "pkg-config '$(2)' --cflags" ] ;
94 lib = [ lib-config-ex "pkg-config '$(2)' --libs" ] ;
96 -configure-add-line- 'CFLAGS.all +=' $(flg) ';' ;
99 -configure-add-line- 'LINKLIBS.all +=' $(lib) ';' ;
101 if $(3) { -configure-add-line- $(3) ; }
110 -configure-add-line- '#' $(1) ;
111 -configure-add-line- $(4) ;
120 # $(1) list of packages:
121 # 'display name' 'pkg-config-str'
122 # optional: set PROJECT_NAME to project name
123 rule -configure-pkg-config-necessary- {
126 _pn = $(PROJECT_NAME) ;
127 if ! $(_pn) { _pn = 'this project' ; }
130 -configure-pkg-config- $(_dn) : $(_t) : : : 'FATAL: you need' $(_t) 'to build' $(_pn) ;
139 # $(1): library name to display
140 # $(2): arg to pkg-config
141 # $(3): fail with this message if not present
143 # $(5): USE var; if it is set to '0' -- skip this package
144 # return empty list if package is missing, change USE-var value if necessary
147 # -configure-pkg-config-get-flags- 'PCRE' : 'libpcre' : : 'PCRE' : 'MYPKG_USE_PCRE' ;
148 # this will write MYPKG_USE_PCRE flag, PCRE_CFLAGS and PCRE_LIBS
149 # if MYPKG_USE_PCRE is empty at the time of call, library will be count as missing
150 rule -configure-pkg-config-get-flags- {
151 local flg lib res = ;
152 local displibname = $(1) ;
153 local pcargs = $(2) ;
154 local failmsg = $(3) ;
155 local flagspfx = $(4) ;
156 local usevar = $(5) ;
158 if $(_CONFIGURE_FATAL_) != 'tan' {
159 if $(usevar) && ! $($(usevar)) {
160 Echo "checking for $(displibname) ... disabled" ;
161 -configure-add-line- "$(usevar)" '= ;' ;
167 Echo "checking for $(displibname) ... " : -n ;
168 -configure-add-line- '#' $(displibname) ;
169 flg = [ lib-config-ex "pkg-config $(pcargs) --cflags" ] ;
170 lib = [ lib-config-ex "pkg-config $(pcargs) --libs" ] ;
171 if ! $(flg) && ! $(lib) {
180 -configure-add-line- "$(usevar)" '= ;' ;
183 -configure-add-line- "$(flagspfx)_CFLAGS = ;" ;
184 -configure-add-line- "$(flagspfx)_LIBS = ;" ;
191 -configure-add-line- "$(usevar)" '= tan ;' ;
194 -configure-add-line- "$(flagspfx)_CFLAGS =" "$(flg)" ';' ;
195 -configure-add-line- "$(flagspfx)_LIBS =" "$(lib)" ';' ;
205 # $(1): action display name for 'checking XXX ...'
208 # $(4): additional search pathes
209 # $(5): rule to call if found: $(1) will be returned prefix, $(2) -- libraries
210 # $(6): rule to call if not found
211 # $(7): 'allow-any-lib' 'allow-any-header'
212 rule -configure-detect-library- {
215 if $(_CONFIGURE_FATAL_) != 'tan' {
216 Echo "checking for $(1) ... " : -n ;
217 -configure-add-line- '#' $(1) ;
218 pfx = [ DetectLibrary $(2) : $(3) : $(4) : $(5) ] ;
221 if $(5) { [ $(5) $(pfx) : $(2) ] ; }
224 if $(6) { [ $(6) $(pfx) : $(2) ] ; }
230 rule -configure-show-enable-disable-help- {
231 if ! $(-configure-enable-disable-vars-) { return ; }
234 # calculate maximum option name length
236 while $(-configure-enable-disable-vars-[$(f)]) {
237 local oname val help ;
238 oname = $(-configure-enable-disable-vars-[$(f)]) ;
239 f = [ ExprI1 $(f) + 3 ] ;
240 help = $(-configure-enable-disable-vars-[$(f)]) ;
241 f = [ ExprI1 $(f) + 1 ] ;
243 # this option is not hidden
244 local len = $(oname:W) ;
245 if [ ExprI1 $(len) '>' $(maxlen) ] { maxlen = $(len) ; }
248 maxlen = [ ExprI1 $(maxlen) + 13 ] ;
250 while $(-configure-enable-disable-vars-[$(f)]) {
251 local oname vname val help ;
252 oname = $(-configure-enable-disable-vars-[$(f)]) ;
253 f = [ ExprI1 $(f) + 1 ] ;
254 vname = $(-configure-enable-disable-vars-[$(f)]) ;
255 f = [ ExprI1 $(f) + 1 ] ;
256 val = $(-configure-enable-disable-vars-[$(f)]) ;
257 f = [ ExprI1 $(f) + 1 ] ;
258 help = $(-configure-enable-disable-vars-[$(f)]) ;
259 f = [ ExprI1 $(f) + 1 ] ;
261 # this option is not hidden
262 if $(val) == 'auto' {
263 help += '(default: autodetect)' ;
264 ostr = " --disable-$(oname)" ;
266 help += '(default: enabled)' ;
267 ostr = " --disable-$(oname)" ;
269 help += '(default: disabled)' ;
270 ostr = " --enable-$(oname)" ;
272 Echo $(ostr:W=$(maxlen)) $(help) ;
278 # $(1): option name without enable/disable
279 # $(2): 'enable' or 'disable'
280 rule -configure-do-enable-disable- {
281 if $(-configure-enable-disable-vars-) {
282 #Echo 'option:' $(1) 'flag:' $(2) ;
285 while $(-configure-enable-disable-vars-[$(f)]) {
286 local oname vname val ;
287 oname = $(-configure-enable-disable-vars-[$(f)]) ;
288 f = [ ExprI1 $(f) + 1 ] ;
289 vname = $(-configure-enable-disable-vars-[$(f)]) ;
290 f = [ ExprI1 $(f) + 1 ] ;
291 val = $(-configure-enable-disable-vars-[$(f)]) ;
292 f = [ ExprI1 $(f) + 2 ] ;
293 if $(oname) == $(1) {
294 if $(2) == 'enable' { $(vname) = 'tan' ; } else { $(vname) = "" ; }
299 Exit 'ERROR: unknown option:' "$(ca)" ;
303 rule -configure-process-enable-disable- {
304 if ! $(-configure-enable-disable-vars-) { return ; }
306 while $(-configure-enable-disable-vars-[$(f)]) {
308 vname = $(-configure-enable-disable-vars-[$(f)]) ;
309 f = [ ExprI1 $(f) + 1 ] ;
310 val = $(-configure-enable-disable-vars-[$(f)]) ;
311 f = [ ExprI1 $(f) + 3 ] ;
313 #Echo 'vname:' $(vname) 'val:' $(val) 'var:' $($(vname)) ;
318 rule -configure-fatal- {
319 _CONFIGURE_FATAL_ = tan ;
323 rule -configure-main- {
324 local ca nv rln rla rn have_val ;
326 Echo 'configuring...' ;
328 -Action-Configure-Start- ___start___ ;
329 Depends config : ___start___ ;
331 CONFIGURE_DONT_PARSE_OPTIONS = ;
333 if $(JAMCONFIGARGS) {
334 -configure-add-line- '# configure options' ;
335 -configure-add-line- '#' "$(JAMCONFIGARGS)" ;
337 -configure-add-line- "" ;
339 -configure-process-enable-disable- ;
340 -configure-preinit- ;
342 if ! $(CONFIGURE_DONT_PARSE_OPTIONS) {
343 for ca in $(JAMCONFIGARGS) {
344 nv = [ Match '^--([^=]+)=(.*)$' : $(ca) ] ;
350 nv = [ Match '^--(.+)$' : $(ca) ] ;
355 rln = -configure-options-$(rn)- ;
356 if [ HaveRule $(rln) ] {
357 $(rln) $(rn) : $(rla) ;
360 nv = [ Match '^--(enable|disable)-(.+)$' : $(ca) ] ;
362 -configure-do-enable-disable- $(nv[2]) : $(nv[1]) ;
364 Exit 'ERROR: unknown option:' "$(ca)" ;
367 Exit 'ERROR: unknown option:' "$(ca)" ;
375 if $(_CONFIGURE_FATAL_) = 'tan' {
376 Exit 'FATAL: configure failed' ;
378 Echo "MESSAGE: Now you can run 'jam' to build software." ;
383 actions quietly -Action-Configure-Start- {
384 if [ "z$(_CONFIGURE_FATAL_)" = "ztan" ]; then
385 rm "$(K8JAM-CONFIGURE-FILE)" 2>/dev/null
388 echo "# autogenerated by 'jam configure'" >"$(K8JAM-CONFIGURE-FILE)"
389 echo "_CONFIGURE_COMPLETE_ = tan ;" >>"$(K8JAM-CONFIGURE-FILE)"
393 actions quietly -Action-Configure-WriteLine- {
394 if [ "z$(_CONFIGURE_FATAL_)" = "zona" ]; then
395 echo '$(<)' >>"$(K8JAM-CONFIGURE-FILE)"
407 K8JAM-CONFIGURE-FILE ?= $(TOP)/Jamrules.auto.configure ;
408 _CONFIGURE_FATAL_ = ona ;
409 Clean distclean : $(K8JAM-CONFIGURE-FILE) ;
410 if $(xtgt) anyin $(JAM_TARGETS) || $(__DO_TARGET_CLEAN__) { _doit = ; }
412 xtgt = config configure ;
413 if ! ( $(xtgt) anyin $(JAM_TARGETS) ) { softinclude $(K8JAM-CONFIGURE-FILE) ; }
415 if ! $(_CONFIGURE_COMPLETE_) { JAM_TARGETS = config ; }
416 if 'configure' in $(JAM_TARGETS) { JAM_TARGETS = config ; }
417 if 'config' in $(JAM_TARGETS) {
418 JAM_OPTION_MAKE_UPDATES_SILENT = tan ;
419 JAM_TARGETS = config ;
423 -configure-main- config ;
426 _CONFIGURE_COMPLETE_ = tan ;
427 #if $(__DO_CONFIG_CLEAN__) { Clean clean : $(K8JAM-CONFIGURE-FILE) ; }
428 softinclude $(K8JAM-CONFIGURE-FILE) ;
432 . Jambase.configure.compile
433 . Jambase.configure.utils