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 GDCFLAGS.all += $(OPTIM_STANDARD) ;
102 LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
103 --k8jam-set-standards-- ;
108 # set compile flags for profile; works only for gcc/g++
109 # available profiles:
110 # none, default: don't change
111 # empty: remove optimisation flags
112 # speed: optimise for speed and pIII
113 # size: optimise for size
114 # debug: don't optimize, add debug info
118 if ! $(pnn) { pnn = 'standard' ; }
119 if [ HaveRule --k8jam-profile-$(pnn)-- ] {
120 # --fuck-idiotic-caret-- ;
121 remove-opt-flags-for-all-compilers ;
122 LINKFLAGS -= '-g' '-s' ;
123 C++LINKFLAGS -= '-g' '-s' ;
124 OBJCLINKFLAGS -= '-g' '-s' ;
125 LINKFLAGS.all -= '-g' '-s' ;
126 if ! $(JAM_OPTION_MAKE_UPDATES_SILENT) {
127 Echo "MSG: '$(pnn)' profile" ;
129 OPT_PROFILE = $(pnn) ;
130 --k8jam-profile-$(OPT_PROFILE)-- ;
132 Exit 'FATAL: invalid profile:' "$(pnn)" ;
137 # process various profile targets:
141 rule profile-targets {
146 for local targ in $(JAM_TARGETS) {
147 if $(targ) = 'speed' || $(targ) = 'size' || $(targ) = 'debug' {
149 if $(prf) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
152 } else if $(targ) = 'release' {
153 if $(rel) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
155 } else if $(targ) = 'unittest' {
156 if $(ut) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
162 if $(prf) { PROFILE = $(prf) ; }
163 if $(rel) { RELEASE = tan ; }
164 if $(ut) { UNITTEST = tan ; }
165 if ! $(ntarg) { ntarg = 'all' ; }
166 JAM_TARGETS = $(ntarg) ;
171 # if $(flags) contains 'no-targets' -- disallow 'profile targets'
172 rule set-profile flags {
173 local profname ndb dbg ;
175 if ! 'no-targets' in $(flags) { profile-targets ; }
178 profname = $(PROFILE) ;
180 if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
182 if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
185 if $(profname) = 'debug' && ! $(DEBUG) { DEBUG = tan ; }
194 if $(DIET) && $(DIET_BIN) {
195 CC = $(DIET_BIN) $(CC) ;
196 LINK = $(DIET_BIN) $(LINK) ;
197 C++ = $(DIET_BIN) $(C++) ;
198 C++LINK = $(DIET_BIN) $(C++LINK) ;
201 if $(DBG) || $(DEBUG) { ndb = ; } else { ndb = NDEBUG ; }
203 profile $(profname) ;
205 if $(VALGRIND) || $(dbg) || $(DEBUG) {
206 CFLAGS.all -= '-g' '-s' ;
207 GDCFLAGS.all -= '-g' '-s' ;
208 LINKFLAGS.all -= '-g' '-s' ;
211 LINKFLAGS.all += -g ;
213 if ! $(NO_WARNINGS) { CFLAGS.all += -Wall ; GDCFLAGS.all += -Wall ; }
214 if $(NO_NATIVE) { CFLAGS.all -= '-march=native' '-mtune=native' ; GDCFLAGS.all -= '-march=native' '-mtune=native' ; }
215 if $(NO_FWRAP) { CFLAGS.all -= '-fwrapv' ; GDCFLAGS.all -= '-fwrapv' ; }
217 if $(ndb) { DEFINES += $(ndb) ; }
219 if $(MAEMO47) { CFLAGS.all += -fgnu89-inline ; }
220 if $(MAEMO47) && $(USE_THUMB) { CFLAGS.all += -mthumb ; }
221 if $(MAEMO47) && $(THUMB_WRELOC) { CFLAGS.all += -mword-relocations ; }
222 if $(MAEMO47) && $(Fpic) { CFLAGS.all += -fpic ; }
223 if $(MAEMO47) && $(FPIC) { CFLAGS.all += -fPIC ; }
227 GDCFLAGS.all += -funittest ;
230 GDCFLAGS.all += -frelease ;
231 GDCFLAGS.all += -fno-assert ;
232 GDCFLAGS.all += -fno-debug ;
233 GDCFLAGS.all += -fno-in ;
234 GDCFLAGS.all += -fno-out ;
235 GDCFLAGS.all += -fno-invariants ;
236 GDCFLAGS.all += -fno-bounds-check ;
239 if ! $(NODEBUG) && ! $(NO_DEBUG) && ! $(D_NO_DEBUG) { GDCFLAGS.all += -fdebug ; }
240 if ! $(D_NO_ASSERT) { GDCFLAGS.all += -fassert ; } else { GDCFLAGS.all += -fno-assert ; }
241 if ! $(D_NO_IN) { GDCFLAGS.all += -fin ; } else { GDCFLAGS.all += -fno-in ; }
242 if ! $(D_NO_OUT) { GDCFLAGS.all += -fout ; } else { GDCFLAGS.all += -fno-out ; }
243 if ! $(D_NO_INVARIANTS) { GDCFLAGS.all += -finvariants ; } else { GDCFLAGS.all += -fno-invariants ; }
244 if ! $(D_NO_BOUNDS) { GDCFLAGS.all += -fbounds-check ; } else { GDCFLAGS.all += -fno-bounds-check ; }
246 GDCFLAGS.all += -fno-assert ;
247 GDCFLAGS.all += -fno-debug ;
248 GDCFLAGS.all += -fno-in ;
249 GDCFLAGS.all += -fno-out ;
250 GDCFLAGS.all += -fno-invariants ;
251 GDCFLAGS.all += -fno-bounds-check ;