1 # # "auto": check with pkg-config or so, show '--disable-xxx'
2 # # "": disabled by default, show '--enable-xxx'
3 # # non-empty string: enabled by default, show '--disable-xxx'
4 # -configure-enable-disable-vars- +=
5 # "sqlite" USE_SQLITE "auto" "don't use sqlite"
6 # "gtkhtml" USE_GTKHTML "auto" "don't use GTKHTML"
7 # "gtkspell" USE_GTKSPELL "auto" "don't use GTKSpell"
8 # "svg" USE_RSVG "auto" "don't use librsvg"
9 # "soup" USE_SOUP "auto" "don't use libsoup"
10 # "curl" USE_CURL "auto" "don't use libcurl"
11 # "dock" USE_DOCK "tan" "disable dock icon"
16 # $(2): option arg (if any)
17 rule -configure-show-default--help- {
19 Echo "jam configure for package" $(PROJECT_NAME) "supports:" ;
21 Echo "jam configure supports:" ;
23 Echo "common options:" ;
24 Echo " --prefix=dir install prefix: [/usr/local]" ;
25 if $(-configure-enable-disable-vars-) {
26 Echo "package options:" ;
27 -configure-show-enable-disable-help- ;
33 rule -configure-options-help- {
34 -configure-show-default--help- ;
38 rule -configure-options-prefix- {
40 Exit "ERROR: --prefix needs argument!" ;
42 -configure-add-line- "PREFIX ?= $(2) ;" ;
43 Echo "MSG: prefix set to $(2)" ;
47 # will be called before -configure-
48 # can set CONFIGURE_DONT_PARSE_OPTIONS
49 rule -configure-preinit- {
53 rule -configure-add-line- {
56 if $(_CONFIGURE_FATAL_) != "tan" {
57 str = $(1:J=|space|) ;
58 Depends config : $(str) ;
59 -Action-Configure-WriteLine- $(str) ;
64 # $(1): library name to display
65 # $(2): arg to pkg-config
66 # $(3): string to write if present
67 # $(4): string to write if not present
68 # $(5): fail with this message if not present
69 # returns non-empty string if package exists
70 rule -configure-pkg-config- {
71 local flg lib ex res ;
73 if $(_CONFIGURE_FATAL_) != "tan" {
74 Echo-n "checking for $(1) ..." ;
75 ex = [ pkg-config-exists $(2) ] ;
78 -configure-add-line- "#" $(1) ;
79 flg = [ lib-config-ex "pkg-config '$(2)' --cflags" ] ;
80 lib = [ lib-config-ex "pkg-config '$(2)' --libs" ] ;
82 -configure-add-line- "CFLAGS.all +=" $(flg) ";" ;
85 -configure-add-line- "LINKLIBS.all +=" $(lib) ";" ;
87 if $(3) { -configure-add-line- $(3) ; }
96 -configure-add-line- "#" $(1) ;
97 -configure-add-line- $(4) ;
106 # $(1) list of packages:
107 # "display name" "pkg-config-str"
108 # optional: set PROJECT_NAME to project name
109 rule -configure-pkg-config-necessary- {
112 _pn = $(PROJECT_NAME) ;
113 if ! $(_pn) { _pn = "this project" ; }
116 -configure-pkg-config- $(_dn) : $(_t) : : : "FATAL: you need" $(_t) "to build" $(_pn) ;
125 # $(1): library name to display
126 # $(2): arg to pkg-config
127 # $(3): fail with this message if not present
129 # $(5): USE var; if it is set to "0" -- skip this package
132 # -configure-pkg-config-get-flags- "PCRE" : "libpcre" : : "PCRE" : "MYPKG_USE_PCRE" ;
133 # this will write MYPKG_USE_PCRE flag, PCRE_CFLAGS and PCRE_LIBS
134 # if MYPKG_USE_PCRE is "0" at the time of call, library will be count as missing
135 rule -configure-pkg-config-get-flags- {
137 local displibname = $(1) ;
138 local pcargs = $(2) ;
139 local failmsg = $(3) ;
140 local flagspfx = $(4) ;
141 local usevar = $(5) ;
143 if $(_CONFIGURE_FATAL_) != "tan" {
144 if $(usevar) && $($(usevar)) == "0" {
145 Echo "checking for $(displibname) ... disabled" ;
146 -configure-add-line- "$(usevar)" "= ;" ;
152 Echo-n "checking for $(displibname) ..." ;
153 -configure-add-line- "#" $(displibname) ;
154 flg = [ lib-config-ex "pkg-config $(pcargs) --cflags" ] ;
155 lib = [ lib-config-ex "pkg-config $(pcargs) --libs" ] ;
156 if ! $(flg) && ! $(lib) {
163 if $(usevar) { -configure-add-line- "$(usevar)" "= ;" ; }
165 -configure-add-line- "$(flagspfx)_CFLAGS = ;" ;
166 -configure-add-line- "$(flagspfx)_LIBS = ;" ;
171 if $(usevar) { -configure-add-line- "$(usevar)" "= tan ;" ; }
173 -configure-add-line- "$(flagspfx)_CFLAGS =" "$(flg)" ";" ;
174 -configure-add-line- "$(flagspfx)_LIBS =" "$(lib)" ";" ;
182 # $(1): action display name for 'checking XXX ...'
185 # $(4): additional search pathes
186 # $(5): rule to call if found: $(1) will be returned prefix, $(2) -- libraries
187 # $(6): rule to call if not found
188 # $(7): 'allow-any-lib' 'allow-any-header'
189 rule -configure-detect-library- {
192 if $(_CONFIGURE_FATAL_) != "tan" {
193 Echo-n "checking for $(1) ..." ;
194 -configure-add-line- "#" $(1) ;
195 pfx = [ DetectLibrary $(2) : $(3) : $(4) : $(5) ] ;
198 if $(5) { [ $(5) $(pfx) : $(2) ] ; }
201 if $(6) { [ $(6) $(pfx) : $(2) ] ; }
207 rule -configure-show-enable-disable-help- {
208 if ! $(-configure-enable-disable-vars-) { return ; }
211 # calculate maximum option name length
213 while $(-configure-enable-disable-vars-[$(f)]) {
214 local oname val help ;
215 oname = $(-configure-enable-disable-vars-[$(f)]) ;
216 f = [ ExprI1 $(f) + 3 ] ;
217 help = $(-configure-enable-disable-vars-[$(f)]) ;
218 f = [ ExprI1 $(f) + 1 ] ;
220 # this option is not hidden
221 len = [ ExprI1 "#" $(oname) ] ;
222 if [ ExprI1 $(len) ">" $(maxlen) ] { maxlen = $(len) ; }
225 maxlen = [ ExprI1 $(maxlen) + 14 ] ;
227 while $(-configure-enable-disable-vars-[$(f)]) {
228 local oname vname val help ;
229 oname = $(-configure-enable-disable-vars-[$(f)]) ;
230 f = [ ExprI1 $(f) + 1 ] ;
231 vname = $(-configure-enable-disable-vars-[$(f)]) ;
232 f = [ ExprI1 $(f) + 1 ] ;
233 val = $(-configure-enable-disable-vars-[$(f)]) ;
234 f = [ ExprI1 $(f) + 1 ] ;
235 help = $(-configure-enable-disable-vars-[$(f)]) ;
236 f = [ ExprI1 $(f) + 1 ] ;
238 # this option is not hidden
239 if ($val) == "auto" {
240 help += "(default: autodetect)" ;
241 ostr = " --disable-$(oname)" ;
243 help += "(default: enabled)" ;
244 ostr = " --disable-$(oname)" ;
246 help += "(default: disabled)" ;
247 ostr = " --enable-$(oname)" ;
249 len = [ ExprI1 "#" $(ostr) ] ;
251 while [ ExprI1 $(len) "<" $(maxlen) ] {
253 len = [ ExprI1 $(len) + 1 ] ;
261 # $(1): option name without enable/disable
262 # $(2): "enable" or "disable"
263 rule -configure-do-enable-disable- {
264 if $(-configure-enable-disable-vars-) {
265 #Echo "option:" $(1) "flag:" $(2) ;
268 while $(-configure-enable-disable-vars-[$(f)]) {
269 local oname vname val ;
270 oname = $(-configure-enable-disable-vars-[$(f)]) ;
271 f = [ ExprI1 $(f) + 1 ] ;
272 vname = $(-configure-enable-disable-vars-[$(f)]) ;
273 f = [ ExprI1 $(f) + 1 ] ;
274 val = $(-configure-enable-disable-vars-[$(f)]) ;
275 f = [ ExprI1 $(f) + 2 ] ;
276 if $(oname) == $(1) {
277 if $(2) == "enable" { $(vname) = "tan" ; } else { $(vname) = "" ; }
282 Exit "ERROR: unknown option:" "$(ca)" ;
286 rule -configure-process-enable-disable- {
287 if ! $(-configure-enable-disable-vars-) { return ; }
289 while $(-configure-enable-disable-vars-[$(f)]) {
291 vname = $(-configure-enable-disable-vars-[$(f)]) ;
292 f = [ ExprI1 $(f) + 1 ] ;
293 val = $(-configure-enable-disable-vars-[$(f)]) ;
294 f = [ ExprI1 $(f) + 3 ] ;
296 #Echo "vname:" $(vname) "val:" $(val) "var:" $($(vname)) ;
301 rule -configure-fatal- {
302 _CONFIGURE_FATAL_ = tan ;
306 rule -configure-main- {
307 local ca nv rln rla rn have_val ;
309 Echo "configuring..." ;
311 -Action-Configure-Start- ___start___ ;
312 Depends config : ___start___ ;
314 CONFIGURE_DONT_PARSE_OPTIONS = ;
316 -configure-process-enable-disable- ;
317 -configure-preinit- ;
319 if ! $(CONFIGURE_DONT_PARSE_OPTIONS) {
320 for ca in $(JAMCONFIGARGS) {
321 nv = [ Match "^--([^=]+)=(.*)\$" : $(ca) : regexp ] ;
327 nv = [ Match "^--(.+)\$" : $(ca) : regexp ] ;
332 rln = -configure-options-$(rn)- ;
333 if [ HaveRule $(rln) ] {
334 $(rln) $(rn) : $(rla) ;
337 nv = [ Match "^--(enable|disable)-(.+)\$" : $(ca) : regexp ] ;
339 -configure-do-enable-disable- $(nv[2]) : $(nv[1]) ;
341 Exit "ERROR: unknown option:" "$(ca)" ;
344 Exit "ERROR: unknown option:" "$(ca)" ;
352 if $(_CONFIGURE_FATAL_) = "tan" {
353 Echo "FATAL: configure failed" ;
355 Echo "MESSAGE: Now you can run 'jam' to build software." ;
360 actions quietly -Action-Configure-Start- {
361 if [ "z$(_CONFIGURE_FATAL_)" = "ztan" ]; then
362 rm "$(K8JAM-CONFIGURE-FILE)" 2>/dev/null
365 echo "# autogenerated by 'jam configure'" >"$(K8JAM-CONFIGURE-FILE)"
366 echo "_CONFIGURE_COMPLETE_ = tan ;" >>"$(K8JAM-CONFIGURE-FILE)"
367 echo "" >>"$(K8JAM-CONFIGURE-FILE)"
371 actions quietly -Action-Configure-WriteLine- {
372 if [ "z$(_CONFIGURE_FATAL_)" = "zona" ]; then
373 echo '$(<)' >>"$(K8JAM-CONFIGURE-FILE)"
380 K8JAM-CONFIGURE-FILE ?= $(TOP)/Jamrules.auto.configure ;
381 _CONFIGURE_FATAL_ = ona ;
382 Clean distclean : $(K8JAM-CONFIGURE-FILE) ;
383 if "gen-boiler" in $(JAM_TARGETS) || "clean" in $(JAM_TARGETS) || "distclean" in $(JAM_TARGETS) || $(__DO_TARGET_CLEAN__) { _doit = ; }
385 if ! "config" in $(JAM_TARGETS) {
386 softinclude $(K8JAM-CONFIGURE-FILE) ;
389 if ! $(_CONFIGURE_COMPLETE_) { JAM_TARGETS = config ; }
390 if "configure" in $(JAM_TARGETS) { JAM_TARGETS = config ; }
391 if "config" in $(JAM_TARGETS) {
392 JAM_TARGETS = config ;
396 -configure-main- config ;
399 _CONFIGURE_COMPLETE_ = tan ;
400 #if $(__DO_CONFIG_CLEAN__) { Clean clean : $(K8JAM-CONFIGURE-FILE) ; }
401 softinclude $(K8JAM-CONFIGURE-FILE) ;