1 # miscelaneous helper rules
4 # Utility rules; no side effects on these
7 # /FGrist path to file ;
9 # Returns a single string that is used as grist
17 return $(<:G=$(SOURCE_GRIST:E)) ;
21 rule FGristSourceFiles {
22 ## LOCAL CHANGE: OPT_HEADER_CACHE_EXT
23 # With header caching, there is no performance penalty to gristing
24 # header files. It is also not correct to assume that header
25 # files have global visibility.
27 # Here we comment out the old version and replace it with the new.
28 # # Produce source file name name with grist in it,
29 # # if SOURCE_GRIST is set.
31 # # Leave header files alone, because they have a global
33 # if ! $(SOURCE_GRIST) {
40 # case *.h : _o += $(_i) ;
41 # case * : _o += $(_i:G=$(SOURCE_GRIST)) ;
46 return [ FGristFiles $(<) ] ;
51 if $(1) { return [ FReverse $(1[2-]) ] $(1[1]) ; }
56 # If $(>) is the path to the current directory, compute the
57 # path (using ../../ etc) back to that root directory.
65 for _i in $(<[2-]) { _d = $(_d:R=$(DOTDOT)) ; }
72 # FStripCommon v1 : v2 ;
74 # Strip common initial elements of variables v1 and v2.
75 # Modifies the variable values themselves.
76 if $($(<)[1]) && $($(<)[1]) = $($(>)[1]) {
79 FStripCommon $(<) : $(>) ;
87 # first strip off common parts
90 FStripCommon _l : _r ;
92 # now make path to root and path down
93 _l = [ FSubDir $(_l) ] ;
94 _r = [ FDirName $(_r) ] ;
96 # Concatenate and save
97 # XXX This should be better
98 if $(_r) = $(DOT) { return $(_l) ; } else { return $(_r:R=$(_l)) ; }
103 # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
104 # returns (yacc,lex,foo.bat) on Unix and
105 # (yacc.exe,lex.exe,foo.bat) on NT.
110 if $(_i:S) { _o += $(_i) ; } else { _o += $(_i:S=$(>)) ; }
120 # Operating system specific utility rules
121 # First, the (generic) UNIX versions
124 rule FQuote { return "\\\"$(<)\\\"" ; }
125 rule FDefines { return -D$(<) ; }
126 rule FIncludes { return -I$(<) ; }
129 # Turn individual elements in $(<) into a usable path.
133 for _i in $(<) { _s = $(_i:R=$(_s)) ; }
138 if $(NT) && $(JAM_TOOLSET) != MINGW && $(JAM_TOOLSET) != LCC {
139 rule FDefines { return /D$(<) ; }
140 rule FIncludes { return /I$(<) ; }
144 rule remove-std99-flags {
145 local orm = "^(\\-std=c99)" "^(\\-std=gnu99)" ;
146 local res = [ RemoveOptWild $(orm) : $(<) ] ;
151 # VAR = [ RemoveOptWild regexp-options-to-remove : options-list ] ;
152 # remove options from list with egrep-like regexps
159 #Echo "removing " $(oname) " from " $(str) ;
161 t = [ Match $(oname) : $(f) ] ;
162 #Echo $(f) ": " $(t) ;
164 #Echo "include: " $(f) ;
172 # remove-opt-flags $(var)
173 # remove optimization flags from compiler options
174 rule remove-opt-flags {
175 local orm = "^(\\-march\\=)" "^(\\-mtune\\=)" "^(\\-mfpmath\\=)" "^(\\-O.$)" ;
176 local ormff = "^(\\-f[^n][^o])" ;
177 local res = [ RemoveOptWild $(orm) $(ormff) : $(<) ] ;
182 rule remove-opt-flags-for-all-compilers {
183 OPTIM = [ remove-opt-flags $(OPTIM) ] ;
184 C++OPTIM = [ remove-opt-flags $(C++OPTIM) ] ;
185 OBJCOPTIM = [ remove-opt-flags $(OBJCOPTIM) ] ;
186 OPTIM.all = [ remove-opt-flags $(OPTIM.all) ] ;
188 OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM) ] ;
189 C++OPTIM = [ RemoveOptWild $(orm) $(ormff) : $(C++OPTIM) ] ;
190 OBJCOPTIM = [ RemoveOptWild $(orm) $(ormff) : $(OBJCOPTIM) ] ;
191 OPTIM.all = [ RemoveOptWild $(orm) $(ormff) : $(OPTIM.all) ] ;
195 rule sys-has-command {
198 cf = [ Command "which \"$(1)\" 2>/dev/null 1>&2" : exit-code code-first ] ;
208 rule gcc-suggest-attrs {
210 CFLAGS.all += -Wsuggest-attribute=const ;
211 CFLAGS.all += -Wsuggest-attribute=pure ;
212 CFLAGS.all += -Wsuggest-attribute=noreturn ;
218 UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
222 . fsys/Jambase.misc.fsys