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 LINKFLAGS.all += $(LINKFLAGS_NOOPT) ;
67 --k8jam-set-standards-- ;
71 rule --k8jam-profile-speed-- {
72 CFLAGS.all += $(OPTIM_SPEED) ;
73 LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
74 --k8jam-set-standards-- ;
77 rule --k8jam-profile-size-- {
78 CFLAGS.all += $(OPTIM_SIZE) ;
79 LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
80 --k8jam-set-standards-- ;
83 rule --k8jam-profile-debug-- {
84 CFLAGS.all += $(OPTIM_DEBUG) ;
85 LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
86 --k8jam-set-standards-- ;
89 rule --k8jam-profile-standard-- {
90 CFLAGS.all += $(OPTIM_STANDARD) ;
91 LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
92 --k8jam-set-standards-- ;
97 # set compile flags for profile; works only for gcc/g++
99 # none, default: don't change
100 # empty: remove optimisation flags
101 # speed: optimise for speed and pIII
102 # size: optimise for size
103 # debug: don't optimize, add debug info
107 if ! $(pnn) { pnn = 'standard' ; }
108 if [ HaveRule --k8jam-profile-$(pnn)-- ] {
109 # --fuck-idiotic-caret-- ;
110 remove-opt-flags-for-all-compilers ;
111 LINKFLAGS -= '-g' '-s' ;
112 C++LINKFLAGS -= '-g' '-s' ;
113 OBJCLINKFLAGS -= '-g' '-s' ;
114 LINKFLAGS.all -= '-g' '-s' ;
115 if ! $(JAM_OPTION_MAKE_UPDATES_SILENT) {
116 Echo "MSG: '$(pnn)' profile" ;
118 OPT_PROFILE = $(pnn) ;
119 --k8jam-profile-$(OPT_PROFILE)-- ;
121 Exit 'FATAL: invalid profile:' "$(pnn)" ;
128 local profname ndb dbg ;
131 profname = $(PROFILE) ;
133 if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
135 if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
145 if $(DIET) && $(DIET_BIN) {
146 CC = $(DIET_BIN) $(CC) ;
147 LINK = $(DIET_BIN) $(LINK) ;
148 C++ = $(DIET_BIN) $(C++) ;
149 C++LINK = $(DIET_BIN) $(C++LINK) ;
152 if $(DBG) || $(DEBUG) { ndb = ; } else { ndb = NDEBUG ; }
154 profile $(profname) ;
156 if $(VALGRIND) || $(dbg) || $(DEBUG) {
157 CFLAGS.all -= '-g' '-s' ;
158 LINKFLAGS.all -= '-g' '-s' ;
160 LINKFLAGS.all += -g ;
162 if ! $(NO_WARNINGS) { CFLAGS.all += -Wall ; }
163 if $(NO_NATIVE) { CFLAGS.all -= '-march=native' '-mtune=native' ; }
164 if $(NO_FWRAP) { CFLAGS.all -= '-fwrapv' ; }
166 if $(ndb) { DEFINES += $(ndb) ; }
168 if $(MAEMO47) { CFLAGS.all += -fgnu89-inline ; }
169 if $(MAEMO47) && $(USE_THUMB) { CFLAGS.all += -mthumb ; }
170 if $(MAEMO47) && $(THUMB_WRELOC) { CFLAGS.all += -mword-relocations ; }
171 if $(MAEMO47) && $(Fpic) { CFLAGS.all += -fpic ; }
172 if $(MAEMO47) && $(FPIC) { CFLAGS.all += -fPIC ; }
175 if $(UNITTEST) || $(UNITTESTS) {
176 GDCFLAGS.all += -funittest ;
179 GDCFLAGS.all += -frelease ;
180 GDCFLAGS.all += -fno-debug ;
181 GDCFLAGS.all += -fno-in ;
182 GDCFLAGS.all += -fno-out ;
183 GDCFLAGS.all += -fno-invariants ;
185 if ! $(NODEBUG) && ! $(NO_DEBUG) { GDCFLAGS.all += -fdebug ; }
186 GDCFLAGS.all += -fin ;
187 GDCFLAGS.all += -fout ;
188 GDCFLAGS.all += -finvariants ;
189 GDCFLAGS.all += -fbounds-check ;