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, version 3 of the License ONLY.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # miscelaneous helper rules
16 # Utility rules; no side effects on these
19 # /FGrist path to file ;
21 # Returns a single string that is used as grist
29 return $(<:G=$(SOURCE_GRIST:E)) ;
33 ## LOCAL CHANGE: OPT_HEADER_CACHE_EXT
34 # With header caching, there is no performance penalty to gristing
35 # header files. It is also not correct to assume that header
36 # files have global visibility.
38 # So FGristSourceFiles is the same as FGristFiles
39 #rule FGristSourceFiles
43 # If $(<) is the path to the current directory, compute the
44 # path (using ../../ etc) back to that root directory.
49 for local _i in $(<[2-]) { _d = $(_d:R='..') ; }
54 # /FStripCommon v1 : v2 ;
56 # Strip common initial elements of variables v1 and v2.
57 # Modifies the variable values themselves.
59 if $($(<)[1]) && $($(<)[1]) = $($(>)[1]) {
62 FStripCommon $(<) : $(>) ;
69 # first strip off common parts
72 FStripCommon _l : _r ;
73 # now make path to root and path down
74 _l = [ FSubDir $(_l) ] ;
75 _r = [ FDirName $(_r) ] ;
76 # Concatenate and save
77 # XXX This should be better
78 if $(_r) = '.' { return $(_l) ; } else { return $(_r:R=$(_l)) ; }
83 # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
84 # returns (yacc,lex,foo.bat) on Unix and
85 # (yacc.exe,lex.exe,foo.bat) on NT.
88 for local _i in $(<) {
89 if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
99 # Operating system specific utility rules
100 # First, the (generic) UNIX versions
103 rule FDefines { return -D$(<) ; }
104 rule FIncludes { return -I$(<) ; }
105 rule FDIncludes { return -J$(<) ; }
108 # Turn individual elements in $(<) into a usable path.
110 for local _i in $(<) { _s = $(_i:R=$(_s)) ; }
115 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
116 rule FDefines { return /D$(<) ; }
117 rule FIncludes { return /I$(<) ; }
121 rule sys-has-command {
122 if [ Command "which $(1:Q) 2>/dev/null 1>&2" ] {
131 UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
136 #if ( 'gcc' in $(CC) ) || ( $(JAM_TOOLSET) = MINGW ) { return 'tan'; }
137 if ( ( $(CC) ~= '\bgcc$' ) || ( $(JAM_TOOLSET) = MINGW ) ) { return 'tan'; }
143 #if ( 'g++' in $(C++) ) || ( $(JAM_TOOLSET) = MINGW ) { return 'tan'; }
144 if ( ( $(CC) ~= '\bg\+\+$' ) || ( $(JAM_TOOLSET) = MINGW ) ) { return 'tan'; }
149 rule JoinAndRemoveSpaces str {
152 local pn = [ Match '^(.*)\s+(.*)$' : $(str) ] ;
154 str = $(pn[1]) $(pn[2]) ;
163 # adds "all" if JAM_TARGETS becomes empty
165 rule RemoveJamTarget {
168 for _t in $(JAM_TARGETS) {
175 if $(newtgt) = "" { newtgt = "all" ; }
176 JAM_TARGETS = $(newtgt) ;
180 rule CompareVersions a : b {
181 local spa = [ Split $(a) : "." ] ;
182 local spb = [ Split $(b) : "." ] ;
183 local alen = [ ListLength $(spa) ] ;
184 local blen = [ ListLength $(spb) ] ;
190 if [ ExprI1 $(cnt) ">" $(alen) ] {
191 if [ ExprI1 $(cnt) ">" $(blen) ] {
195 # b is longer, so a is lesser
197 } else if [ ExprI1 $(cnt) ">" $(blen) ] {
198 # b is shorter, so a is greater
203 v0 = $(spa[$(cnt)]) ;
204 v1 = $(spb[$(cnt)]) ;
206 if [ ExprI1 $(v0) "<" $(v1) ] {
209 if [ ExprI1 $(v0) ">" $(v1) ] {
214 cnt = [ ExprI1 $(cnt) + 1 ] ;