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 ###############################################################################
16 ###############################################################################
19 OPTIM_SPEED ?= -O3 -fwrapv -march=native -mtune=native -mfpmath=sse ;
20 LINKFLAGS_SPEED ?= -s ;
22 OPTIM_SIZE ?= -Os -fwrapv -march=native -mtune=native ;
23 LINKFLAGS_SIZE ?= -s ;
25 OPTIM_STANDARD ?= -O2 -fwrapv -march=native -mtune=native ;
26 LINKFLAGS_STANDARD ?= -s ;
29 LINKFLAGS_NOOPT ?= -s ;
31 OPTIM_DEBUG ?= -O0 -g ;
32 LINKFLAGS_DEBUG ?= -g ;
34 OPTIM_NOALIAS ?= -fno-strict-aliasing ;
37 ## K8JAM-KNOWN-PROFILES =
38 ## none default # don't change
39 ## empty # remove optimisation flags
40 ## speed # optimise for speed
41 ## size # optimise for size
42 ## debug # don't optimize, add debug info
47 rule --k8jam-set-standards-- {
48 if ! $(CC.standard) { CC.standard = -std=gnu11 ; }
49 if ! $(C++.standard) { C++.standard = -std=gnu++98 ; }
53 rule --k8jam-profile-default-- {
58 rule --k8jam-profile-empty-- {
60 --k8jam-set-standards-- ;
64 rule --k8jam-profile-noopt-- {
65 CFLAGS.all += $(OPTIM_NOOPT) ;
66 GDCFLAGS.all += $(OPTIM_NOOPT) ;
67 LINKFLAGS.all += $(LINKFLAGS_NOOPT) ;
68 --k8jam-set-standards-- ;
72 rule --k8jam-profile-speed-- {
73 CFLAGS.all += $(OPTIM_SPEED) ;
74 GDCFLAGS.all += $(OPTIM_SPEED) ;
75 LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
76 --k8jam-set-standards-- ;
79 rule --k8jam-profile-size-- {
80 CFLAGS.all += $(OPTIM_SIZE) ;
81 GDCFLAGS.all += $(OPTIM_SIZE) ;
82 LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
83 --k8jam-set-standards-- ;
86 rule --k8jam-profile-debug-- {
87 CFLAGS.all += $(OPTIM_DEBUG) ;
88 GDCFLAGS.all += $(OPTIM_DEBUG) ;
89 LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
90 --k8jam-set-standards-- ;
93 rule --k8jam-profile-standard-- {
94 CFLAGS.all += $(OPTIM_STANDARD) ;
95 GDCFLAGS.all += $(OPTIM_STANDARD) ;
96 LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
97 --k8jam-set-standards-- ;
102 # set compile flags for profile; works only for gcc/g++
103 # available profiles:
104 # none, default: don't change
105 # empty: remove optimisation flags
106 # speed: optimise for speed and pIII
107 # size: optimise for size
108 # debug: don't optimize, add debug info
112 if ! $(pnn) { pnn = 'standard' ; }
113 if [ HaveRule --k8jam-profile-$(pnn)-- ] {
114 # --fuck-idiotic-caret-- ;
115 remove-opt-flags-for-all-compilers ;
116 LINKFLAGS -= '-g' '-s' ;
117 C++LINKFLAGS -= '-g' '-s' ;
118 OBJCLINKFLAGS -= '-g' '-s' ;
119 LINKFLAGS.all -= '-g' '-s' ;
120 if ! $(JAM_OPTION_MAKE_UPDATES_SILENT) {
121 Echo "MSG: '$(pnn)' profile" ;
123 OPT_PROFILE = $(pnn) ;
124 --k8jam-profile-$(OPT_PROFILE)-- ;
126 Exit 'FATAL: invalid profile:' "$(pnn)" ;
131 # process various profile targets:
135 rule profile-targets {
138 for local targ in $(JAM_TARGETS) {
139 if $(targ) = 'speed' || $(targ) = 'size' || $(targ) = 'debug' {
141 if $(prf) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
144 } else if $(targ) = 'release' {
150 if $(prf) { PROFILE = $(prf) ; }
151 if ! $(ntarg) { ntarg = 'all' ; }
152 JAM_TARGETS = $(ntarg) ;
157 # if $(flags) contains 'no-targets' -- disallow 'profile targets'
158 rule set-profile flags {
159 local profname ndb dbg ;
161 if ! 'no-targets' in $(flags) { profile-targets ; }
164 profname = $(PROFILE) ;
166 if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
168 if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
178 if $(DIET) && $(DIET_BIN) {
179 CC = $(DIET_BIN) $(CC) ;
180 LINK = $(DIET_BIN) $(LINK) ;
181 C++ = $(DIET_BIN) $(C++) ;
182 C++LINK = $(DIET_BIN) $(C++LINK) ;
185 if $(DBG) || $(DEBUG) { ndb = ; } else { ndb = NDEBUG ; }
187 profile $(profname) ;
189 if $(VALGRIND) || $(dbg) || $(DEBUG) {
190 CFLAGS.all -= '-g' '-s' ;
191 GDCFLAGS.all -= '-g' '-s' ;
192 LINKFLAGS.all -= '-g' '-s' ;
195 LINKFLAGS.all += -g ;
197 if ! $(NO_WARNINGS) { CFLAGS.all += -Wall ; GDCFLAGS.all += -Wall ; }
198 if $(NO_NATIVE) { CFLAGS.all -= '-march=native' '-mtune=native' ; GDCFLAGS.all -= '-march=native' '-mtune=native' ; }
199 if $(NO_FWRAP) { CFLAGS.all -= '-fwrapv' ; GDCFLAGS.all -= '-fwrapv' ; }
201 if $(ndb) { DEFINES += $(ndb) ; }
203 if $(MAEMO47) { CFLAGS.all += -fgnu89-inline ; }
204 if $(MAEMO47) && $(USE_THUMB) { CFLAGS.all += -mthumb ; }
205 if $(MAEMO47) && $(THUMB_WRELOC) { CFLAGS.all += -mword-relocations ; }
206 if $(MAEMO47) && $(Fpic) { CFLAGS.all += -fpic ; }
207 if $(MAEMO47) && $(FPIC) { CFLAGS.all += -fPIC ; }
210 if $(UNITTEST) || $(UNITTESTS) {
211 GDCFLAGS.all += -funittest ;
214 GDCFLAGS.all += -frelease ;
215 GDCFLAGS.all += -fno-assert ;
216 GDCFLAGS.all += -fno-debug ;
217 GDCFLAGS.all += -fno-in ;
218 GDCFLAGS.all += -fno-out ;
219 GDCFLAGS.all += -fno-invariants ;
220 GDCFLAGS.all += -fno-bounds-check ;
223 if ! $(NODEBUG) && ! $(NO_DEBUG) && ! $(D_NO_DEBUG) { GDCFLAGS.all += -fdebug ; }
224 if ! $(D_NO_ASSERT) { GDCFLAGS.all += -fassert ; } else { GDCFLAGS.all += -fno-assert ; }
225 if ! $(D_NO_IN) { GDCFLAGS.all += -fin ; } else { GDCFLAGS.all += -fno-in ; }
226 if ! $(D_NO_OUT) { GDCFLAGS.all += -fout ; } else { GDCFLAGS.all += -fno-out ; }
227 if ! $(D_NO_INVARIANTS) { GDCFLAGS.all += -finvariants ; } else { GDCFLAGS.all += -fno-invariants ; }
228 if ! $(D_NO_BOUNDS) { GDCFLAGS.all += -fbounds-check ; } else { GDCFLAGS.all += -fno-bounds-check ; }
230 GDCFLAGS.all += -fno-assert ;
231 GDCFLAGS.all += -fno-debug ;
232 GDCFLAGS.all += -fno-in ;
233 GDCFLAGS.all += -fno-out ;
234 GDCFLAGS.all += -fno-invariants ;
235 GDCFLAGS.all += -fno-bounds-check ;