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 GDC_INLINE_FLAGS ?= -finline-small-functions -finline-functions ;
21 OPTIM_SPEED ?= -O3 -fwrapv -march=native -mtune=native -mfpmath=sse ;
22 LINKFLAGS_SPEED ?= -s ;
24 OPTIM_SIZE ?= -Os -fwrapv -march=native -mtune=native ;
25 LINKFLAGS_SIZE ?= -s ;
27 OPTIM_STANDARD ?= -O2 -fwrapv -march=native -mtune=native ;
28 LINKFLAGS_STANDARD ?= -s ;
31 LINKFLAGS_NOOPT ?= -s ;
33 OPTIM_DEBUG ?= -O0 -g ;
34 LINKFLAGS_DEBUG ?= -g ;
36 OPTIM_NOALIAS ?= -fno-strict-aliasing ;
39 # current profile will be saved to OPT_PROFILE
40 # empty OPT_PROFILE means 'default'
43 ## K8JAM-KNOWN-PROFILES =
44 ## none default # don't change
45 ## empty # remove optimisation flags
46 ## speed # optimise for speed
47 ## size # optimise for size
48 ## debug # don't optimize, add debug info
53 rule --k8jam-set-standards-- {
54 if ! $(CC.standard) { CC.standard = -std=gnu11 ; }
55 if ! $(C++.standard) { C++.standard = -std=gnu++98 ; }
59 rule --k8jam-profile-default-- {
64 rule --k8jam-profile-empty-- {
66 --k8jam-set-standards-- ;
70 rule --k8jam-profile-noopt-- {
71 CFLAGS.all += $(OPTIM_NOOPT) ;
72 GDCFLAGS.all += $(OPTIM_NOOPT) ;
73 LINKFLAGS.all += $(LINKFLAGS_NOOPT) ;
74 --k8jam-set-standards-- ;
78 rule --k8jam-profile-speed-- {
79 CFLAGS.all += $(OPTIM_SPEED) ;
80 GDCFLAGS.all += $(OPTIM_SPEED) ;
81 LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
82 --k8jam-set-standards-- ;
85 rule --k8jam-profile-size-- {
86 CFLAGS.all += $(OPTIM_SIZE) ;
87 GDCFLAGS.all += $(OPTIM_SIZE) ;
88 LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
89 --k8jam-set-standards-- ;
92 rule --k8jam-profile-debug-- {
93 CFLAGS.all += $(OPTIM_DEBUG) ;
94 GDCFLAGS.all += $(OPTIM_DEBUG) ;
95 LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
96 --k8jam-set-standards-- ;
99 rule --k8jam-profile-standard-- {
100 CFLAGS.all += $(OPTIM_STANDARD) ;
101 if $(OPTIM_NOALIAS) { CFLAGS.all += $(OPTIM_NOALIAS); }
102 GDCFLAGS.all += $(OPTIM_STANDARD) ;
103 if $(OPTIM_NOALIAS) { GDCFLAGS.all += $(OPTIM_NOALIAS); }
104 LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
105 --k8jam-set-standards-- ;
109 rule --k8jam-profile-standard-with-aliasing-- {
110 CFLAGS.all += $(OPTIM_STANDARD) ;
111 GDCFLAGS.all += $(OPTIM_STANDARD) ;
112 LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
113 --k8jam-set-standards-- ;
118 # set compile flags for profile; works only for gcc/g++
119 # available profiles:
120 # none, default: don't change
121 # empty: remove optimisation flags
122 # speed: optimise for speed and pIII
123 # size: optimise for size
124 # debug: don't optimize, add debug info
128 if ! $(pnn) { pnn = 'standard' ; }
129 if [ HasRule --k8jam-profile-$(pnn)-- ] {
130 # --fuck-idiotic-caret-- ;
131 remove-opt-flags-for-all-compilers ;
132 LINKFLAGS -= '-g' '-s' ;
133 C++LINKFLAGS -= '-g' '-s' ;
134 OBJCLINKFLAGS -= '-g' '-s' ;
135 LINKFLAGS.all -= '-g' '-s' ;
136 if ! $(JAM_OPTION_MAKE_UPDATES_SILENT) {
137 Echo "MSG: '$(pnn)' profile" ;
139 OPT_PROFILE = $(pnn) ;
140 --k8jam-profile-$(OPT_PROFILE)-- ;
142 Exit 'FATAL: invalid profile:' "$(pnn)" ;
147 # process various profile targets:
151 rule profile-targets {
156 for local targ in $(JAM_TARGETS) {
157 if $(targ) = 'speed' || $(targ) = 'size' || $(targ) = 'debug' {
159 if $(prf) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
162 } else if $(targ) = 'release' {
163 if $(rel) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
165 } else if $(targ) = 'unittest' {
166 if $(ut) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
172 if $(prf) { PROFILE = $(prf) ; }
173 if $(rel) { RELEASE = tan ; }
174 if $(ut) { UNITTEST = tan ; }
175 if ! $(ntarg) { ntarg = 'all' ; }
176 JAM_TARGETS = $(ntarg) ;
181 # if $(flags) contains 'no-targets' -- disallow 'profile targets'
182 rule set-profile flags {
183 local profname ndb dbg ;
185 if ! 'no-targets' in $(flags) { profile-targets ; }
188 profname = $(PROFILE) ;
190 if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
192 if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
195 if $(profname) = 'debug' && ! $(DEBUG) { DEBUG = tan ; }
204 if $(DIET) && $(DIET_BIN) {
205 CC = $(DIET_BIN) $(CC) ;
206 LINK = $(DIET_BIN) $(LINK) ;
207 C++ = $(DIET_BIN) $(C++) ;
208 C++LINK = $(DIET_BIN) $(C++LINK) ;
211 if $(DBG) || $(DEBUG) { ndb = ; } else { ndb = NDEBUG ; }
213 profile $(profname) ;
215 if $(VALGRIND) || $(dbg) || $(DEBUG) {
216 CFLAGS.all -= '-g' '-s' ;
217 GDCFLAGS.all -= '-g' '-s' ;
218 LINKFLAGS.all -= '-g' '-s' ;
221 LINKFLAGS.all += -g ;
223 if ! $(NO_WARNINGS) { CFLAGS.all += -Wall ; GDCFLAGS.all += -Wall ; }
224 if $(NO_NATIVE) { CFLAGS.all -= '-march=native' '-mtune=native' ; GDCFLAGS.all -= '-march=native' '-mtune=native' ; }
225 if $(NO_FWRAP) { CFLAGS.all -= '-fwrapv' ; GDCFLAGS.all -= '-fwrapv' ; }
227 if $(ndb) { DEFINES += $(ndb) ; }
229 if $(MAEMO47) { CFLAGS.all += -fgnu89-inline ; }
230 if $(MAEMO47) && $(USE_THUMB) { CFLAGS.all += -mthumb ; }
231 if $(MAEMO47) && $(THUMB_WRELOC) { CFLAGS.all += -mword-relocations ; }
232 if $(MAEMO47) && $(Fpic) { CFLAGS.all += -fpic ; }
233 if $(MAEMO47) && $(FPIC) { CFLAGS.all += -fPIC ; }
237 GDCFLAGS.all += -funittest ;
240 GDCFLAGS.all += -frelease ;
241 GDCFLAGS.all += -fno-assert ;
242 GDCFLAGS.all += -fno-debug ;
243 GDCFLAGS.all += -fno-in ;
244 GDCFLAGS.all += -fno-out ;
245 GDCFLAGS.all += -fno-invariants ;
246 if $(D_NO_BOUNDS) { GDCFLAGS.all += -fno-bounds-check ; }
249 #if ! $(NODEBUG) && ! $(NO_DEBUG) && ! $(D_NO_DEBUG) { GDCFLAGS.all += -fdebug ; }
250 if ! $(D_NO_ASSERT) { GDCFLAGS.all += -fassert ; } else { GDCFLAGS.all += -fno-assert ; }
251 if ! $(D_NO_IN) { GDCFLAGS.all += -fin ; } else { GDCFLAGS.all += -fno-in ; }
252 if ! $(D_NO_OUT) { GDCFLAGS.all += -fout ; } else { GDCFLAGS.all += -fno-out ; }
253 if ! $(D_NO_INVARIANTS) { GDCFLAGS.all += -finvariants ; } else { GDCFLAGS.all += -fno-invariants ; }
254 if ! $(D_NO_BOUNDS) { GDCFLAGS.all += -fbounds-check ; } else { GDCFLAGS.all += -fno-bounds-check ; }
256 GDCFLAGS.all += -fno-assert ;
257 GDCFLAGS.all += -fno-debug ;
258 GDCFLAGS.all += -fno-in ;
259 GDCFLAGS.all += -fno-out ;
260 GDCFLAGS.all += -fno-invariants ;
261 GDCFLAGS.all += -fno-bounds-check ;
265 if ! $(USE_DMD) && $(PHOBOS_STATIC) {
266 #GDCFLAGS.all += -static-libphobos ;
267 GDCLINKFLAGS.all += -static-libphobos ;
269 GDCFLAGS.all += -fPIC ;
270 #LINKFLAGS.all += -fPIC ;