nothing you want to know about
[k8jam.git] / defaults / Jambase.profile
blobcb9c5c82cae4754f409047948a2763f076570f30
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 ###############################################################################
15 # special values
16 ###############################################################################
17 DIET_BIN ?= diet ;
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 ;
28 OPTIM_NOOPT ?= -O0 ;
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
43 ##   standard      # -O2
44 ## ;
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-- {
54   OPT_PROFILE = ;
58 rule --k8jam-profile-empty-- {
59   LINKFLAGS.all += -s ;
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-- ;
96 # profile 'name' ;
97 # set compile flags for profile; works only for gcc/g++
98 # available profiles:
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
104 #  standard: -O2
105 rule profile {
106   local pnn = $(1) ;
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" ;
117     }
118     OPT_PROFILE = $(pnn) ;
119     --k8jam-profile-$(OPT_PROFILE)-- ;
120   } else {
121     Exit 'FATAL: invalid profile:' "$(pnn)" ;
122   }
126 # selects profile
127 rule set-profile {
128   local profname ndb dbg ;
130   dbg = ;
131   profname = $(PROFILE) ;
132   if ! $(profname) {
133     if $(DEBUG) { profname = 'debug' ; } else { profname = 'standard' ; }
134   } else {
135     if $(profname) != 'debug' && $(DEBUG) { dbg = 'tan' ; }
136   }
138   if $(USE_CLANG) {
139     CC = clang ;
140     LINK = clang ;
141     C++ = clang++ ;
142     C++LINK = clang++ ;
143   }
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) ;
150   }
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' ;
159     CFLAGS.all += -g ;
160     LINKFLAGS.all += -g ;
161   }
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 ; }
174   # d
175   if $(UNITTEST) || $(UNITTESTS) {
176     GDCFLAGS.all += -funittest ;
177   }
178   if $(RELEASE) {
179     GDCFLAGS.all += -frelease ;
180     GDCFLAGS.all += -fno-debug ;
181     GDCFLAGS.all += -fno-in ;
182     GDCFLAGS.all += -fno-out ;
183     GDCFLAGS.all += -fno-invariants ;
184   } else {
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 ;
190   }
192   gcc-suggest-attrs ;