| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.52 2004/05/30 02:55:58 lv Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.62 2004/07/15 04:59:44 lv Exp $ |
| 4 | # |
4 | # |
| 5 | # Author Bart Verwilst <verwilst@gentoo.org> |
5 | # Author Bart Verwilst <verwilst@gentoo.org> |
| 6 | |
6 | |
| 7 | ECLASS=flag-o-matic |
7 | ECLASS=flag-o-matic |
| 8 | INHERITED="$INHERITED $ECLASS" |
8 | INHERITED="$INHERITED $ECLASS" |
|
|
9 | IUSE="$IUSE debug" |
| 9 | |
10 | |
| 10 | # |
11 | # |
| 11 | #### filter-flags <flags> #### |
12 | #### filter-flags <flags> #### |
| 12 | # Remove particular flags from C[XX]FLAGS |
13 | # Remove particular flags from C[XX]FLAGS |
| 13 | # Matches only complete flags |
14 | # Matches only complete flags |
| … | |
… | |
| 84 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" |
85 | export UNSTABLE_FLAGS="-Os -O3 -freorder-blocks -fprefetch-loop-arrays" |
| 85 | return 0 |
86 | return 0 |
| 86 | } |
87 | } |
| 87 | |
88 | |
| 88 | filter-flags() { |
89 | filter-flags() { |
|
|
90 | local x f fset |
|
|
91 | declare -a new_CFLAGS new_CXXFLAGS |
|
|
92 | |
| 89 | for x in "$@" ; do |
93 | for x in "$@" ; do |
| 90 | case "${x}" in |
94 | case "${x}" in |
| 91 | -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;; |
95 | -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;; |
| 92 | -fstack-protector|-fstack-protector-all) fstack-flags;; |
96 | -fstack-protector|-fstack-protector-all) fstack-flags;; |
| 93 | *) ;; |
|
|
| 94 | esac |
97 | esac |
| 95 | done |
98 | done |
| 96 | |
99 | |
| 97 | # we do this fancy spacing stuff so as to not filter |
100 | for fset in CFLAGS CXXFLAGS; do |
| 98 | # out part of a flag ... we want flag atoms ! :D |
101 | for f in ${!fset}; do |
| 99 | CFLAGS=" ${CFLAGS} " |
|
|
| 100 | CXXFLAGS=" ${CXXFLAGS} " |
|
|
| 101 | for x in "$@" ; do |
102 | for x in "$@"; do |
| 102 | CFLAGS="${CFLAGS// ${x} / }" |
103 | # Note this should work with globs like -O* |
| 103 | CXXFLAGS="${CXXFLAGS// ${x} / }" |
104 | [[ ${f} == ${x} ]] && continue 2 |
|
|
105 | done |
|
|
106 | eval new_${fset}\[\${\#new_${fset}\[@]}]=\${f} |
| 104 | done |
107 | done |
| 105 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
108 | eval export ${fset}=\${new_${fset}\[*]} |
| 106 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
109 | done |
|
|
110 | |
| 107 | return 0 |
111 | return 0 |
| 108 | } |
112 | } |
| 109 | |
113 | |
| 110 | filter-lfs-flags() { |
114 | filter-lfs-flags() { |
| 111 | filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
115 | filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
| … | |
… | |
| 114 | append-lfs-flags() { |
118 | append-lfs-flags() { |
| 115 | append-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
119 | append-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
| 116 | } |
120 | } |
| 117 | |
121 | |
| 118 | append-flags() { |
122 | append-flags() { |
| 119 | export CFLAGS="${CFLAGS} $@" |
123 | export CFLAGS="${CFLAGS} $*" |
| 120 | export CXXFLAGS="${CXXFLAGS} $@" |
124 | export CXXFLAGS="${CXXFLAGS} $*" |
| 121 | [ "`is-flag -fno-stack-protector`" -o "`is-flag -fno-stack-protector-all`" ] && fstack-flags |
125 | [ -n "`is-flag -fno-stack-protector`" -o \ |
|
|
126 | -n "`is-flag -fno-stack-protector-all`" ] && fstack-flags |
| 122 | return 0 |
127 | return 0 |
| 123 | } |
128 | } |
| 124 | |
129 | |
| 125 | replace-flags() { |
130 | replace-flags() { |
| 126 | # we do this fancy spacing stuff so as to not filter |
131 | # we do this fancy spacing stuff so as to not filter |
| … | |
… | |
| 129 | CXXFLAGS=" ${CXXFLAGS} " |
134 | CXXFLAGS=" ${CXXFLAGS} " |
| 130 | CFLAGS="${CFLAGS// ${1} / ${2} }" |
135 | CFLAGS="${CFLAGS// ${1} / ${2} }" |
| 131 | CXXFLAGS="${CXXFLAGS// ${1} / ${2} }" |
136 | CXXFLAGS="${CXXFLAGS// ${1} / ${2} }" |
| 132 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
137 | CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" |
| 133 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
138 | CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" |
|
|
139 | export CFLAGS CXXFLAGS |
| 134 | return 0 |
140 | return 0 |
| 135 | } |
141 | } |
| 136 | |
142 | |
| 137 | replace-cpu-flags() { |
143 | replace-cpu-flags() { |
| 138 | local newcpu="$1" ; shift |
144 | local oldcpu newcpu="$1" ; shift |
| 139 | local oldcpu="" |
|
|
| 140 | for oldcpu in "$@" ; do |
145 | for oldcpu in "$@" ; do |
| 141 | replace-flags -march=${oldcpu} -march=${newcpu} |
146 | replace-flags -march=${oldcpu} -march=${newcpu} |
| 142 | replace-flags -mcpu=${oldcpu} -mcpu=${newcpu} |
147 | replace-flags -mcpu=${oldcpu} -mcpu=${newcpu} |
| 143 | replace-flags -mtune=${oldcpu} -mtune=${newcpu} |
148 | replace-flags -mtune=${oldcpu} -mtune=${newcpu} |
| 144 | done |
149 | done |
| 145 | return 0 |
150 | return 0 |
| 146 | } |
151 | } |
| 147 | |
152 | |
| 148 | is-flag() { |
153 | is-flag() { |
|
|
154 | local x |
|
|
155 | |
| 149 | for x in ${CFLAGS} ${CXXFLAGS} ; do |
156 | for x in ${CFLAGS} ${CXXFLAGS} ; do |
| 150 | if [ "${x}" == "$1" ] ; then |
157 | if [ "${x}" == "$1" ] ; then |
| 151 | echo true |
158 | echo true |
| 152 | return 0 |
159 | return 0 |
| 153 | fi |
160 | fi |
| 154 | done |
161 | done |
| 155 | return 1 |
162 | return 1 |
| 156 | } |
163 | } |
| 157 | |
164 | |
| 158 | filter-mfpmath() { |
165 | filter-mfpmath() { |
|
|
166 | local orig_mfpmath new_math prune_math |
|
|
167 | |
| 159 | # save the original -mfpmath flag |
168 | # save the original -mfpmath flag |
| 160 | local orig_mfpmath="`get-flag -mfpmath`" |
169 | orig_mfpmath="`get-flag -mfpmath`" |
| 161 | # get the value of the current -mfpmath flag |
170 | # get the value of the current -mfpmath flag |
| 162 | local new_math=" `get-flag mfpmath | tr , ' '` " |
171 | new_math=" `get-flag mfpmath | tr , ' '` " |
| 163 | # figure out which math values are to be removed |
172 | # figure out which math values are to be removed |
| 164 | local prune_math="" |
173 | prune_math="" |
| 165 | for prune_math in "$@" ; do |
174 | for prune_math in "$@" ; do |
| 166 | new_math="${new_math/ ${prune_math} / }" |
175 | new_math="${new_math/ ${prune_math} / }" |
| 167 | done |
176 | done |
| 168 | new_math="`echo ${new_math:1:${#new_math}-2} | tr ' ' ,`" |
177 | new_math="`echo ${new_math:1:${#new_math}-2} | tr ' ' ,`" |
| 169 | |
178 | |
| … | |
… | |
| 178 | fi |
187 | fi |
| 179 | return 0 |
188 | return 0 |
| 180 | } |
189 | } |
| 181 | |
190 | |
| 182 | strip-flags() { |
191 | strip-flags() { |
|
|
192 | local x y flag NEW_CFLAGS NEW_CXXFLAGS |
|
|
193 | |
| 183 | setup-allowed-flags |
194 | setup-allowed-flags |
| 184 | |
195 | |
| 185 | local NEW_CFLAGS="" |
196 | local NEW_CFLAGS="" |
| 186 | local NEW_CXXFLAGS="" |
197 | local NEW_CXXFLAGS="" |
| 187 | |
198 | |
| … | |
… | |
| 189 | if has ~${ARCH} ${ACCEPT_KEYWORDS} ; then |
200 | if has ~${ARCH} ${ACCEPT_KEYWORDS} ; then |
| 190 | use debug && einfo "Enabling the use of some unstable flags" |
201 | use debug && einfo "Enabling the use of some unstable flags" |
| 191 | ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}" |
202 | ALLOWED_FLAGS="${ALLOWED_FLAGS} ${UNSTABLE_FLAGS}" |
| 192 | fi |
203 | fi |
| 193 | |
204 | |
| 194 | set -f |
205 | set -f # disable pathname expansion |
| 195 | |
206 | |
| 196 | for x in ${CFLAGS} |
207 | for x in ${CFLAGS}; do |
| 197 | do |
|
|
| 198 | for y in ${ALLOWED_FLAGS} |
208 | for y in ${ALLOWED_FLAGS}; do |
| 199 | do |
|
|
| 200 | flag=${x%%=*} |
209 | flag=${x%%=*} |
| 201 | if [ "${flag%%${y}}" = "" ] |
210 | if [ "${flag%%${y}}" = "" ]; then |
| 202 | then |
|
|
| 203 | NEW_CFLAGS="${NEW_CFLAGS} ${x}" |
211 | NEW_CFLAGS="${NEW_CFLAGS} ${x}" |
| 204 | break |
212 | break |
| 205 | fi |
213 | fi |
| 206 | done |
214 | done |
| 207 | done |
215 | done |
| 208 | |
216 | |
| 209 | for x in ${CXXFLAGS} |
217 | for x in ${CXXFLAGS}; do |
| 210 | do |
|
|
| 211 | for y in ${ALLOWED_FLAGS} |
218 | for y in ${ALLOWED_FLAGS}; do |
| 212 | do |
|
|
| 213 | flag=${x%%=*} |
219 | flag=${x%%=*} |
| 214 | if [ "${flag%%${y}}" = "" ] |
220 | if [ "${flag%%${y}}" = "" ]; then |
| 215 | then |
|
|
| 216 | NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" |
221 | NEW_CXXFLAGS="${NEW_CXXFLAGS} ${x}" |
| 217 | break |
222 | break |
| 218 | fi |
223 | fi |
| 219 | done |
224 | done |
| 220 | done |
225 | done |
| … | |
… | |
| 225 | fi |
230 | fi |
| 226 | if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then |
231 | if [ "${CXXFLAGS/-O}" != "${CXXFLAGS}" -a "${NEW_CXXFLAGS/-O}" = "${NEW_CXXFLAGS}" ]; then |
| 227 | NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2" |
232 | NEW_CXXFLAGS="${NEW_CXXFLAGS} -O2" |
| 228 | fi |
233 | fi |
| 229 | |
234 | |
| 230 | set +f |
235 | set +f # re-enable pathname expansion |
| 231 | |
|
|
| 232 | use debug \ |
|
|
| 233 | && einfo "CFLAGS=\"${NEW_CFLAGS}\"" \ |
|
|
| 234 | && einfo "CXXFLAGS=\"${NEW_CXXFLAGS}\"" |
|
|
| 235 | |
236 | |
| 236 | export CFLAGS="${NEW_CFLAGS}" |
237 | export CFLAGS="${NEW_CFLAGS}" |
| 237 | export CXXFLAGS="${NEW_CXXFLAGS}" |
238 | export CXXFLAGS="${NEW_CXXFLAGS}" |
| 238 | return 0 |
239 | return 0 |
| 239 | } |
240 | } |
| 240 | |
241 | |
| 241 | test_flag() { |
242 | test_flag() { |
|
|
243 | local cc=${CC:-gcc} ; cc=${cc%% *} |
| 242 | if [ -z "`gcc -S -xc "$@" -o /dev/null /dev/null 2>&1`" ]; then |
244 | if ${cc} -S -xc "$@" -o /dev/null /dev/null &>/dev/null; then |
| 243 | echo "$@" |
245 | printf "%s\n" "$*" |
| 244 | return 0 |
246 | return 0 |
| 245 | fi |
247 | fi |
| 246 | return 1 |
248 | return 1 |
| 247 | } |
249 | } |
| 248 | |
250 | |
|
|
251 | test_version_info() { |
|
|
252 | local cc=${CC:-gcc} ; cc=${cc%% *} |
|
|
253 | if [[ $(${cc} --version 2>&1) == *$1* ]]; then |
|
|
254 | return 0 |
|
|
255 | else |
|
|
256 | return 1 |
|
|
257 | fi |
|
|
258 | } |
|
|
259 | |
| 249 | strip-unsupported-flags() { |
260 | strip-unsupported-flags() { |
|
|
261 | local NEW_CFLAGS NEW_CXXFLAGS |
|
|
262 | |
| 250 | for x in ${CFLAGS} ; do |
263 | for x in ${CFLAGS} ; do |
| 251 | NEW_CFLAGS=${NEW_CFLAGS}" ""`test_flag ${x}`" |
264 | NEW_CFLAGS="${NEW_CFLAGS} `test_flag ${x}`" |
| 252 | done |
265 | done |
| 253 | for x in ${CXXFLAGS} ; do |
266 | for x in ${CXXFLAGS} ; do |
| 254 | NEW_CXXFLAGS=${NEW_CXXFLAGS}" ""`test_flag ${x}`" |
267 | NEW_CXXFLAGS="${NEW_CXXFLAGS} `test_flag ${x}`" |
| 255 | done |
268 | done |
| 256 | |
269 | |
| 257 | export CFLAGS="${NEW_CFLAGS}" |
270 | export CFLAGS="${NEW_CFLAGS}" |
| 258 | export CXXFLAGS="${NEW_CXXFLAGS}" |
271 | export CXXFLAGS="${NEW_CXXFLAGS}" |
| 259 | } |
272 | } |
| 260 | |
273 | |
| 261 | get-flag() { |
274 | get-flag() { |
|
|
275 | local f findflag="$1" |
|
|
276 | |
| 262 | # this code looks a little flaky but seems to work for |
277 | # this code looks a little flaky but seems to work for |
| 263 | # everything we want ... |
278 | # everything we want ... |
| 264 | # for example, if CFLAGS="-march=i686": |
279 | # for example, if CFLAGS="-march=i686": |
| 265 | # `get-flags -march` == "-march=i686" |
280 | # `get-flag -march` == "-march=i686" |
| 266 | # `get-flags march` == "i686" |
281 | # `get-flag march` == "i686" |
| 267 | local findflag="$1" |
|
|
| 268 | for f in ${CFLAGS} ${CXXFLAGS} ; do |
282 | for f in ${CFLAGS} ${CXXFLAGS} ; do |
| 269 | if [ "${f/${findflag}}" != "${f}" ] ; then |
283 | if [ "${f/${findflag}}" != "${f}" ] ; then |
| 270 | echo "${f/-${findflag}=}" |
284 | printf "%s\n" "${f/-${findflag}=}" |
| 271 | return 0 |
285 | return 0 |
| 272 | fi |
286 | fi |
| 273 | done |
287 | done |
| 274 | return 1 |
288 | return 1 |
|
|
289 | } |
|
|
290 | |
|
|
291 | has_hardened() { |
|
|
292 | test_version_info Hardened |
|
|
293 | return $? |
| 275 | } |
294 | } |
| 276 | |
295 | |
| 277 | has_pic() { |
296 | has_pic() { |
| 278 | [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 |
297 | [ "${CFLAGS/-fPIC}" != "${CFLAGS}" ] && return 0 |
| 279 | [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 |
298 | [ "${CFLAGS/-fpic}" != "${CFLAGS}" ] && return 0 |
| 280 | [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0 |
299 | test_version_info pie && return 0 |
| 281 | return 1 |
300 | return 1 |
| 282 | } |
301 | } |
| 283 | |
302 | |
| 284 | has_pie() { |
303 | has_pie() { |
| 285 | [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 |
304 | [ "${CFLAGS/-fPIE}" != "${CFLAGS}" ] && return 0 |
| 286 | [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 |
305 | [ "${CFLAGS/-fpie}" != "${CFLAGS}" ] && return 0 |
| 287 | [ ! -z "`${CC/ .*/} --version| grep pie`" ] && return 0 |
306 | test_version_info pie && return 0 |
| 288 | return 1 |
307 | return 1 |
| 289 | } |
308 | } |
| 290 | |
309 | |
| 291 | has_ssp() { |
310 | has_ssp() { |
| 292 | [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 |
311 | [ "${CFLAGS/-fstack-protector}" != "${CFLAGS}" ] && return 0 |
| 293 | [ ! -z "`${CC/ .*/} --version| grep ssp`" ] && return 0 |
312 | test_version_info ssp && return 0 |
|
|
313 | return 1 |
|
|
314 | } |
|
|
315 | |
|
|
316 | has_m64() { |
|
|
317 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
318 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
319 | # please dont replace this function with test_flag in some future |
|
|
320 | # clean-up! |
|
|
321 | temp=`mktemp` |
|
|
322 | echo "int main() { return(0); }" > ${temp}.c |
|
|
323 | ${CC/ .*/} -m64 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
324 | ret=$? |
|
|
325 | rm -f ${temp}.c |
|
|
326 | [ "$ret" != "1" ] && return 0 |
|
|
327 | return 1 |
|
|
328 | } |
|
|
329 | |
|
|
330 | has_m32() { |
|
|
331 | # this doesnt test if the flag is accepted, it tests if the flag |
|
|
332 | # actually -WORKS-. non-multilib gcc will take both -m32 and -m64! |
|
|
333 | # please dont replace this function with test_flag in some future |
|
|
334 | # clean-up! |
|
|
335 | temp=`mktemp` |
|
|
336 | echo "int main() { return(0); }" > ${temp}.c |
|
|
337 | ${CC/ .*/} -m32 -o /dev/null ${temp}.c > /dev/null 2>&1 |
|
|
338 | ret=$? |
|
|
339 | rm -f ${temp}.c |
|
|
340 | [ "$ret" != "1" ] && return 0 |
| 294 | return 1 |
341 | return 1 |
| 295 | } |
342 | } |
| 296 | |
343 | |
| 297 | replace-sparc64-flags() { |
344 | replace-sparc64-flags() { |
| 298 | local SPARC64_CPUS="ultrasparc v9" |
345 | local SPARC64_CPUS="ultrasparc v9" |
| 299 | |
346 | |
| 300 | if [ "${CFLAGS/mtune}" != "${CFLAGS}" ] |
347 | if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then |
| 301 | then |
|
|
| 302 | for x in ${SPARC64_CPUS} |
348 | for x in ${SPARC64_CPUS}; do |
| 303 | do |
|
|
| 304 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}" |
349 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}" |
| 305 | done |
350 | done |
| 306 | else |
351 | else |
| 307 | for x in ${SPARC64_CPUS} |
352 | for x in ${SPARC64_CPUS}; do |
| 308 | do |
|
|
| 309 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
353 | CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
| 310 | done |
354 | done |
| 311 | fi |
355 | fi |
| 312 | |
356 | |
| 313 | if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ] |
357 | if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then |
| 314 | then |
|
|
| 315 | for x in ${SPARC64_CPUS} |
358 | for x in ${SPARC64_CPUS}; do |
| 316 | do |
|
|
| 317 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}" |
359 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}" |
| 318 | done |
360 | done |
| 319 | else |
361 | else |
| 320 | for x in ${SPARC64_CPUS} |
362 | for x in ${SPARC64_CPUS}; do |
| 321 | do |
|
|
| 322 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
363 | CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}" |
| 323 | done |
364 | done |
| 324 | fi |
365 | fi |
|
|
366 | |
|
|
367 | export CFLAGS CXXFLAGS |
| 325 | } |
368 | } |
| 326 | |
369 | |
| 327 | append-ldflags() { |
370 | append-ldflags() { |
| 328 | LDFLAGS="${LDFLAGS} $@" |
371 | export LDFLAGS="${LDFLAGS} $*" |
| 329 | return 0 |
372 | return 0 |
| 330 | } |
373 | } |
| 331 | |
374 | |
| 332 | filter-ldflags() { |
375 | filter-ldflags() { |
|
|
376 | local x |
|
|
377 | |
| 333 | # we do this fancy spacing stuff so as to not filter |
378 | # we do this fancy spacing stuff so as to not filter |
| 334 | # out part of a flag ... we want flag atoms ! :D |
379 | # out part of a flag ... we want flag atoms ! :D |
| 335 | LDFLAGS=" ${LDFLAGS} " |
380 | LDFLAGS=" ${LDFLAGS} " |
| 336 | for x in "$@" ; do |
381 | for x in "$@" ; do |
| 337 | LDFLAGS="${LDFLAGS// ${x} / }" |
382 | LDFLAGS="${LDFLAGS// ${x} / }" |
| 338 | done |
383 | done |
| 339 | LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}" |
384 | LDFLAGS="${LDFLAGS:1:${#LDFLAGS}-2}" |
|
|
385 | export LDFLAGS |
| 340 | return 0 |
386 | return 0 |
| 341 | } |
387 | } |
| 342 | |
388 | |
| 343 | etexec-flags() { |
389 | etexec-flags() { |
|
|
390 | # if you're not using a hardened compiler you wont need this |
|
|
391 | # PIC/no-pic kludge in the first place. |
|
|
392 | has_hardened || return 0 |
|
|
393 | |
| 344 | has_pie || has_pic |
394 | if has_pie || has_pic; then |
| 345 | if [ $? == 0 ] ; then |
|
|
| 346 | [ -z "`is-flag -fno-pic`" ] && |
395 | [ -z "`is-flag -fno-pic`" ] && |
| 347 | export CFLAGS="${CFLAGS} `test_flag -fno-pic`" |
396 | export CFLAGS="${CFLAGS} `test_flag -fno-pic`" |
| 348 | |
|
|
| 349 | [ -z "`is-flag -nopie`" ] && |
397 | [ -z "`is-flag -nopie`" ] && |
| 350 | export CFLAGS="${CFLAGS} `test_flag -nopie`" |
398 | export CFLAGS="${CFLAGS} `test_flag -nopie`" |
| 351 | fi |
399 | fi |
|
|
400 | return 0 |
| 352 | } |
401 | } |
| 353 | |
402 | |
| 354 | fstack-flags() { |
403 | fstack-flags() { |
| 355 | has_ssp |
404 | if has_ssp; then |
| 356 | if [ $? == 0 ] ; then |
|
|
| 357 | [ -z "`is-flag -fno-stack-protector`" ] && |
405 | [ -z "`is-flag -fno-stack-protector`" ] && |
| 358 | export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`" |
406 | export CFLAGS="${CFLAGS} `test_flag -fno-stack-protector`" |
| 359 | fi |
407 | fi |
|
|
408 | return 0 |
| 360 | } |
409 | } |