added "HOST_CPU", "HOST_32BIT", "HOST_64BIT" built-in variables
[k8jam.git] / defaults / Jambase.profile
blobe5a163b33d09b8d72e85f7ebf9405818de23b141
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, version 3 of the License ONLY.
5 # This program is distributed in the hope that it will be useful,
6 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8 # GNU General Public License for more details.
10 # You should have received a copy of the GNU General Public License
11 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
13 # nehalem is more-or-less ok
14 # westmere is the last without AVX
16 ###############################################################################
17 # special values
18 ###############################################################################
19 DIET_BIN ?= diet ;
21 GCC_NATIVE_ARCH ?= 'native' ;
23 GDC_INLINE_FLAGS ?= -finline-small-functions -finline-functions ;
25 # k8: moved to ~/.jam.rc
26 #  -mstackrealign
27 #  -fms-extensions
29 OPTIM_COMMON_FLAGS ?=
30   -fwrapv
31   -fno-aggressive-loop-optimizations
32   -fno-delete-null-pointer-checks
33   -fno-strict-aliasing
34   -fno-strict-overflow
35   $(OPTIM_USER_COMMON_FLAGS)
38 OPTIM_ARCH_TUNE ?= -march=$(GCC_NATIVE_ARCH) -mtune=$(GCC_NATIVE_ARCH) ;
40 OPTIM_SPEED ?= -O3 $(OPTIM_ARCH_TUNE) ;
41 LINKFLAGS_SPEED ?= -s ;
43 OPTIM_SIZE ?= -Os $(OPTIM_ARCH_TUNE)  ;
44 LINKFLAGS_SIZE ?= -s ;
46 OPTIM_STANDARD ?= -O2 $(OPTIM_ARCH_TUNE)  ;
47 LINKFLAGS_STANDARD ?= -s ;
49 OPTIM_NOOPT ?= -O0 ;
50 LINKFLAGS_NOOPT ?= -s ;
52 OPTIM_DEBUG ?= -O0 -g ;
53 LINKFLAGS_DEBUG ?= -g ;
55 OPTIM_NOALIAS ?= -fno-strict-aliasing ;
58 # current profile will be saved to OPT_PROFILE
59 # empty OPT_PROFILE means 'default'
62 ## K8JAM-KNOWN-PROFILES =
63 ##   none default  # don't change
64 ##   empty         # remove optimisation flags
65 ##   speed         # optimise for speed
66 ##   size          # optimise for size
67 ##   debug         # don't optimize, add debug info
68 ##   standard      # -O2
69 ## ;
72 rule --k8jam-set-standards-- {
73   if ! $(CC.standard) { CC.standard = -std=gnu11 ; }
74   if ! $(C++.standard) { C++.standard = -std=gnu++14 ; }
78 rule --k8jam-profile-default-- {
79   OPT_PROFILE = ;
83 rule --k8jam-profile-empty-- {
84   LINKFLAGS.all += -s ;
85   --k8jam-set-standards-- ;
89 rule --k8jam-profile-noopt-- {
90   CFLAGS.all += $(OPTIM_NOOPT) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_NOOPT) ;
91   GDCFLAGS.all += $(OPTIM_NOOPT) ;
92   LINKFLAGS.all += $(LINKFLAGS_NOOPT) ;
93   --k8jam-set-standards-- ;
97 rule --k8jam-profile-speed-- {
98   CFLAGS.all += $(OPTIM_SPEED) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_SPEED) ;
99   GDCFLAGS.all += $(OPTIM_SPEED) ;
100   LINKFLAGS.all += $(LINKFLAGS_SPEED) ;
101   --k8jam-set-standards-- ;
104 rule --k8jam-profile-size-- {
105   CFLAGS.all += $(OPTIM_SIZE) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_SIZE) ;
106   GDCFLAGS.all += $(OPTIM_SIZE) ;
107   LINKFLAGS.all += $(LINKFLAGS_SIZE) ;
108   --k8jam-set-standards-- ;
111 rule --k8jam-profile-debug-- {
112   CFLAGS.all += $(OPTIM_DEBUG) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_DEBUG) ;
113   GDCFLAGS.all += $(OPTIM_DEBUG) ;
114   LINKFLAGS.all += $(LINKFLAGS_DEBUG) ;
115   --k8jam-set-standards-- ;
118 rule --k8jam-profile-standard-- {
119   CFLAGS.all += $(OPTIM_STANDARD) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_STANDARD) ;
120   if $(OPTIM_NOALIAS) { CFLAGS.all += $(OPTIM_NOALIAS); }
121   GDCFLAGS.all += $(OPTIM_STANDARD) ;
122   if $(OPTIM_NOALIAS) { GDCFLAGS.all += $(OPTIM_NOALIAS); }
123   LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
124   --k8jam-set-standards-- ;
128 rule --k8jam-profile-standard-with-aliasing-- {
129   CFLAGS.all += $(OPTIM_STANDARD) $(OPTIM_COMMON_FLAGS) $(OPTIM_USER_STANDARD) ;
130   GDCFLAGS.all += $(OPTIM_STANDARD) ;
131   LINKFLAGS.all += $(LINKFLAGS_STANDARD) ;
132   --k8jam-set-standards-- ;
136 # profile 'name' ;
137 # set compile flags for profile; works only for gcc/g++
138 # available profiles:
139 #  none, default: don't change
140 #  empty: remove optimisation flags
141 #  speed: optimise for speed and pIII
142 #  size: optimise for size
143 #  debug: don't optimize, add debug info
144 #  standard: -O2
145 rule profile {
146   local pnn = $(1) ;
147   if ! $(pnn) { pnn = 'standard' ; }
148   if [ HasRule --k8jam-profile-$(pnn)-- ] {
149     # --fuck-idiotic-caret-- ;
150     remove-opt-flags-for-all-compilers ;
151     LINKFLAGS -= '-g' '-s' ;
152     C++LINKFLAGS -= '-g' '-s' ;
153     OBJCLINKFLAGS -= '-g' '-s' ;
154     LINKFLAGS.all -= '-g' '-s' ;
155     if ! $(JAM_OPTION_MAKE_UPDATES_SILENT) {
156       Echo "MSG: '$(pnn)' profile" ;
157     }
158     OPT_PROFILE = $(pnn) ;
159     --k8jam-profile-$(OPT_PROFILE)-- ;
160   } else {
161     Exit 'FATAL: invalid profile:' "$(pnn)" ;
162   }
166 # process various profile targets:
167 #   speed
168 #   size
169 #   debug
170 rule profile-targets {
171   local prf = ;
172   local rel = ;
173   local ut = ;
174   local ntarg = ;
175   for local targ in $(JAM_TARGETS) {
176     if $(targ) = 'speed' || $(targ) = 'size' || $(targ) = 'debug' {
177       if ! $(PROFILE) {
178         if $(prf) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
179         prf = $(targ) ;
180       }
181     } else if $(targ) = 'release' {
182       if $(rel) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
183       rel = tan ;
184     } else if $(targ) = 'unittest' {
185       if $(ut) { Exit "FATAL: duplicate profile target; " $(prf) "and" $(targ) ; }
186       ut = tan ;
187     } else {
188       ntarg += $(targ) ;
189     }
190   }
191   if $(prf) { PROFILE = $(prf) ; }
192   if $(rel) { RELEASE = tan ; }
193   if $(ut) { UNITTEST = tan ; }
194   if ! $(ntarg) { ntarg = 'all' ; }
195   JAM_TARGETS = $(ntarg) ;
199 # selects profile
200 # if $(flags) contains 'no-targets' -- disallow 'profile targets'
201 rule set-profile flags {
202   local profname ndb dbg ;
204   if ! 'no-targets' in $(flags) { profile-targets ; }
206   dbg = ;
207   profname = $(PROFILE) ;
208   if ! $(profname) {
209     if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
210   } else {
211     if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
212   }
214   if $(profname) = 'debug' && ! $(DEBUG) { DEBUG = tan ; }
216   if $(USE_CLANG) {
217     CC = clang ;
218     LINK = clang ;
219     C++ = clang++ ;
220     C++LINK = clang++ ;
221   }
223   if $(DIET) && $(DIET_BIN) {
224     CC = $(DIET_BIN) $(CC) ;
225     LINK = $(DIET_BIN) $(LINK) ;
226     C++ = $(DIET_BIN) $(C++) ;
227     C++LINK = $(DIET_BIN) $(C++LINK) ;
228   }
230   if $(DBG) || $(DEBUG) { ndb = ; } else { ndb = NDEBUG ; }
232   profile $(profname) ;
234   if $(VALGRIND) || $(dbg) || $(DEBUG) {
235     CFLAGS.all -= '-g' '-s' ;
236     GDCFLAGS.all -= '-g' '-s' ;
237     LINKFLAGS.all -= '-g' '-s' ;
238     if $(VALGRIND) {
239       CFLAGS.all += -g ;
240       GDCFLAGS.all += -g ;
241       LINKFLAGS.all += -g ;
242     } else {
243       CFLAGS.all += -g '-mfpmath=387' ;
244       GDCFLAGS.all += -g '-mfpmath=387' ;
245       LINKFLAGS.all += -g '-mfpmath=387' ;
246       NO_NATIVE = tan ;
247     }
248   }
250   if ! $(NO_WARNINGS) { CFLAGS.all += -Wall ; GDCFLAGS.all += -Wall ; }
251   if $(NO_NATIVE) { CFLAGS.all -= '-march=native' '-mtune=native' ; GDCFLAGS.all -= '-march=native' '-mtune=native' ; }
252   if $(NO_FWRAP) { CFLAGS.all -= '-fwrapv' ; GDCFLAGS.all -= '-fwrapv' ; }
254   if $(NO_STACK_REALIGN) { CFLAGS.all -= '-mstackrealign' ; }
256   if $(ndb) { DEFINES += $(ndb) ; }
258   if $(MAEMO47) { CFLAGS.all += -fgnu89-inline ; }
259   if $(MAEMO47) && $(USE_THUMB) { CFLAGS.all += -mthumb ; }
260   if $(MAEMO47) && $(THUMB_WRELOC) { CFLAGS.all += -mword-relocations ; }
261   #if $(MAEMO47) && $(Fpic) { CFLAGS.all += -fpic ; }
262   #if $(MAEMO47) && $(FPIC) { CFLAGS.all += -fPIC ; }
263   if $(Fpic) || $(fpic) { CFLAGS.all += -fpic ; }
264   if $(FPIC) || $(fPIC) { CFLAGS.all += -fPIC ; }
266   if ( ! [ IsGCC ] ) && ( ! [ IsG++ ] ) {
267     CFLAGS.all -= '-Wall'
268                   '-march=native'
269                   '-mtune=native'
270                   '-fno-aggressive-loop-optimizations'
271                   '-fno-delete-null-pointer-checks'
272                   '-fno-strict-aliasing'
273                   '-fno-strict-overflow'
274                   '-mstackrealign'
275                   '-fno-diagnostics-show-caret' ;
276   }
278   # d
279   if $(UNITTEST) {
280     GDCFLAGS.all += -funittest ;
281   }
282   if $(RELEASE) {
283     GDCFLAGS.all += -frelease ;
284     GDCFLAGS.all += -fno-assert ;
285     GDCFLAGS.all += -fno-debug ;
286     GDCFLAGS.all += -fno-in ;
287     GDCFLAGS.all += -fno-out ;
288     GDCFLAGS.all += -fno-invariants ;
289     if $(D_NO_BOUNDS) { GDCFLAGS.all += -fno-bounds-check ; }
290   } else {
291     if ! $(D_MAXSPEED) {
292       #if ! $(NODEBUG) && ! $(NO_DEBUG) && ! $(D_NO_DEBUG) { GDCFLAGS.all += -fdebug ; }
293       if ! $(D_NO_ASSERT) { GDCFLAGS.all += -fassert ; } else { GDCFLAGS.all += -fno-assert ; }
294       if ! $(D_NO_IN) { GDCFLAGS.all += -fin ; } else { GDCFLAGS.all += -fno-in ; }
295       if ! $(D_NO_OUT) { GDCFLAGS.all += -fout ; } else { GDCFLAGS.all += -fno-out ; }
296       if ! $(D_NO_INVARIANTS) { GDCFLAGS.all += -finvariants ; } else { GDCFLAGS.all += -fno-invariants ; }
297       if ! $(D_NO_BOUNDS) { GDCFLAGS.all += -fbounds-check ; } else { GDCFLAGS.all += -fno-bounds-check ; }
298     } else {
299       GDCFLAGS.all += -fno-assert ;
300       GDCFLAGS.all += -fno-debug ;
301       GDCFLAGS.all += -fno-in ;
302       GDCFLAGS.all += -fno-out ;
303       GDCFLAGS.all += -fno-invariants ;
304       GDCFLAGS.all += -fno-bounds-check ;
305     }
306   }
308   if ! $(USE_DMD) && $(PHOBOS_STATIC) {
309     #GDCFLAGS.all += -static-libphobos ;
310     GDCLINKFLAGS.all += -static-libphobos ;
311   } else {
312     GDCFLAGS.all += -fPIC ;
313     #LINKFLAGS.all += -fPIC ;
314   }
316   gcc-suggest-attrs ;