changed 'clean', added 'distclean'
[k8jam.git] / defaults / configure / Jambase.configure
blob78f1195a1cdd40c6dbfe66d50327ce2bf4740da3
1 rule -configure-add-line- {
2   local str ;
4   if $(_CONFIGURE_FATAL_) != "tan" {
5     str = $(1:J=|space|) ;
6     Depends config : $(str) ;
7     -Action-Configure-WriteLine- $(str) ;
8   }
12 # $(1): library name to display
13 # $(2): arg to pkg-config
14 # $(3): string to write if present
15 # $(4): string to write if not present
16 # $(5): fail with this message if not present
17 rule -configure-pkg-config- {
18   local flg lib ;
20   if $(_CONFIGURE_FATAL_) != "tan" {
21     Echo-n "checking for $(1) ..." ;
22     -configure-add-line- "#" $(1) ;
23     flg = [ lib-config-ex "pkg-config $(2) --cflags" ] ;
24     lib = [ lib-config-ex "pkg-config $(2) --libs" ] ;
25     if ! $(flg) && ! $(lib) {
26       # no such package
27       Echo "not found" ;
28       if $(5) {
29         -configure-fatal- ;
30         Echo $(5) ;
31       } else {
32         if $(4) { -configure-add-line- $(4) ; }
33       }
34     } else {
35       Echo "found" ;
36       if $(flg) { -configure-add-line- "CFLAGS.all +=" $(flg) ";" ; }
37       if $(lib) { -configure-add-line- "LINKLIBS.all +=" $(lib) ";" ; }
38       if $(3) { -configure-add-line- $(3) ; }
39     }
40   }
44 # $(1): action display name for 'checking XXX ...'
45 # $(2): libraries
46 # $(3): headers
47 # $(4): additional search pathes
48 # $(5): rule to call if found: $(1) will be returned prefix, $(2) -- libraries
49 # $(6): rule to call if not found
50 rule -configure-detect-library- {
51   local pfx ;
53   if $(_CONFIGURE_FATAL_) != "tan" {
54     Echo-n "checking for $(1) ..." ;
55     -configure-add-line- "#" $(1) ;
56     pfx = [ DetectLibrary $(2) : $(3) : $(4) ] ;
57     if $(pfx) {
58       Echo "found" ;
59       if $(5) { [ $(5) $(pfx) : $(2) ] ; }
60     } else {
61       Echo "not found" ;
62       if $(6) { [ $(6) $(pfx) : $(2) ] ; }
63     }
64   }
68 rule -configure-fatal- {
69   _CONFIGURE_FATAL_ = tan ;
73 rule -configure-main- {
74   Echo "configuring..." ;
76   -Action-Configure-Start- ___start___ ;
77   Depends config : ___start___ ;
79   -configure- ;
81   if $(_CONFIGURE_FATAL_) = "tan" {
82     Echo "FATAL: configure failed" ;
83   } else {
84     Echo "MESSAGE: Now you can run 'jam' to build software." ;
85   }
89 actions quietly -Action-Configure-Start- {
90   if [ "z$(_CONFIGURE_FATAL_)" = "ztan" ]; then
91     rm "$(K8JAM-CONFIGURE-FILE)" 2>/dev/null
92     true
93   else
94     echo "# autogenerated by 'jam configure'" >"$(K8JAM-CONFIGURE-FILE)"
95     echo "_CONFIGURE_COMPLETE_ = tan ;" >>"$(K8JAM-CONFIGURE-FILE)"
96     echo "" >>"$(K8JAM-CONFIGURE-FILE)"
97   fi
100 actions quietly -Action-Configure-WriteLine- {
101   if [ "z$(_CONFIGURE_FATAL_)" = "zona" ]; then
102     echo '$(<)' >>"$(K8JAM-CONFIGURE-FILE)"
103   fi
107 rule configure {
108   local _doit = tan ;
109   K8JAM-CONFIGURE-FILE ?= $(TOP)/Jamrules.auto.configure ;
110   _CONFIGURE_FATAL_ = ona ;
111   if "gen-boiler" in $(JAM_TARGETS) || "clean" in $(JAM_TARGETS) || $(__DO_TARGET_CLEAN__) { _doit = ; }
112   if $(_doit) {
113     if $(__DO_CONFIG_CLEAN__) { Clean clean : $(K8JAM-CONFIGURE-FILE) ; }
114     softinclude $(K8JAM-CONFIGURE-FILE) ;
115     #
116     if ! $(_CONFIGURE_COMPLETE_) { JAM_TARGETS = config ; }
117     if "configure" in $(JAM_TARGETS) { JAM_TARGETS = config ; }
118     if "config" in $(JAM_TARGETS) {
119       JAM_TARGETS = config ;
120       K8JAM-JOBS = 1 ;
121       NotFile config ;
122       Always config ;
123       -configure-main- config ;
124     }
125   } else {
126     _CONFIGURE_COMPLETE_ = tan ;
127     if $(__DO_CONFIG_CLEAN__) { Clean clean : $(K8JAM-CONFIGURE-FILE) ; }
128     softinclude $(K8JAM-CONFIGURE-FILE) ;
129   }
133 # -Do-Configure- ;