/[gentoo-x86]/eclass/flag-o-matic.eclass
Gentoo

Diff of /eclass/flag-o-matic.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.168 Revision 1.173
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.168 2012/01/16 20:03:32 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.173 2012/05/31 00:29:06 vapier Exp $
4 4
5# @ECLASS: flag-o-matic.eclass 5# @ECLASS: flag-o-matic.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# toolchain@gentoo.org 7# toolchain@gentoo.org
8# @BLURB: common functions to manipulate and query toolchain flags 8# @BLURB: common functions to manipulate and query toolchain flags
15 15
16inherit eutils toolchain-funcs multilib 16inherit eutils toolchain-funcs multilib
17 17
18# Return all the flag variables that our high level funcs operate on. 18# Return all the flag variables that our high level funcs operate on.
19all-flag-vars() { 19all-flag-vars() {
20 echo {C,CPP,CXX,F,FC,LD}FLAGS 20 echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
21} 21}
22 22
23# {C,CXX,F,FC}FLAGS that we allow in strip-flags 23# {C,CXX,F,FC}FLAGS that we allow in strip-flags
24# Note: shell globs and character lists are allowed 24# Note: shell globs and character lists are allowed
25setup-allowed-flags() { 25setup-allowed-flags() {
99} 99}
100 100
101# @FUNCTION: filter-flags 101# @FUNCTION: filter-flags
102# @USAGE: <flags> 102# @USAGE: <flags>
103# @DESCRIPTION: 103# @DESCRIPTION:
104# Remove particular <flags> from {C,CPP,CXX,F,FC,LD}FLAGS. Accepts shell globs. 104# Remove particular <flags> from {C,CPP,CXX,CCAS,F,FC,LD}FLAGS. Accepts shell globs.
105filter-flags() { 105filter-flags() {
106 _filter-hardened "$@" 106 _filter-hardened "$@"
107 local v 107 local v
108 for v in $(all-flag-vars) ; do 108 for v in $(all-flag-vars) ; do
109 _filter-var ${v} "$@" 109 _filter-var ${v} "$@"
121 # _LARGEFILE64_SOURCE: enable support for 64bit variants (off64_t/fseeko64/etc...) 121 # _LARGEFILE64_SOURCE: enable support for 64bit variants (off64_t/fseeko64/etc...)
122 # _FILE_OFFSET_BITS: default to 64bit variants (off_t is defined as off64_t) 122 # _FILE_OFFSET_BITS: default to 64bit variants (off_t is defined as off64_t)
123 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE 123 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
124} 124}
125 125
126# @FUNCTION: filter-ldflags
127# @USAGE: <flags>
128# @DESCRIPTION:
129# Remove particular <flags> from LDFLAGS. Accepts shell globs.
130filter-ldflags() {
131 _filter-var LDFLAGS "$@"
132 return 0
133}
134
126# @FUNCTION: append-cppflags 135# @FUNCTION: append-cppflags
127# @USAGE: <flags> 136# @USAGE: <flags>
128# @DESCRIPTION: 137# @DESCRIPTION:
129# Add extra <flags> to the current CPPFLAGS. 138# Add extra <flags> to the current CPPFLAGS.
130append-cppflags() { 139append-cppflags() {
171 [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments" 180 [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments"
172 # see comments in filter-lfs-flags func for meaning of these 181 # see comments in filter-lfs-flags func for meaning of these
173 append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE 182 append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
174} 183}
175 184
185# @FUNCTION: append-ldflags
186# @USAGE: <flags>
187# @DESCRIPTION:
188# Add extra <flags> to the current LDFLAGS.
189append-ldflags() {
190 [[ $# -eq 0 ]] && return 0
191 local flag
192 for flag in "$@"; do
193 [[ ${flag} == -l* ]] && \
194 ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS"
195 done
196
197 export LDFLAGS="${LDFLAGS} $*"
198 return 0
199}
200
176# @FUNCTION: append-flags 201# @FUNCTION: append-flags
177# @USAGE: <flags> 202# @USAGE: <flags>
178# @DESCRIPTION: 203# @DESCRIPTION:
179# Add extra <flags> to your current {C,CXX,F,FC}FLAGS. 204# Add extra <flags> to your current {C,CXX,F,FC}FLAGS.
180append-flags() { 205append-flags() {
181 [[ $# -eq 0 ]] && return 0 206 [[ $# -eq 0 ]] && return 0
207 case " $* " in
208 *' '-[DIU]*) eqawarn 'please use append-cppflags for preprocessor flags' ;;
209 *' '-L*|\
210 *' '-Wl,*) eqawarn 'please use append-ldflags for linker flags' ;;
211 esac
182 append-cflags "$@" 212 append-cflags "$@"
183 append-cxxflags "$@" 213 append-cxxflags "$@"
184 append-fflags "$@" 214 append-fflags "$@"
185 return 0 215 return 0
186} 216}
543 for flag in "$@"; do 573 for flag in "$@"; do
544 [[ ${flag} == -l* ]] && flag=${flag#-l} 574 [[ ${flag} == -l* ]] && flag=${flag#-l}
545 export LIBS="${LIBS} -l${flag}" 575 export LIBS="${LIBS} -l${flag}"
546 done 576 done
547 577
548 return 0
549}
550
551# @FUNCTION: append-ldflags
552# @USAGE: <flags>
553# @DESCRIPTION:
554# Add extra <flags> to the current LDFLAGS.
555append-ldflags() {
556 [[ $# -eq 0 ]] && return 0
557 local flag
558 for flag in "$@"; do
559 [[ ${flag} == -l* ]] && \
560 ewarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS"
561 done
562
563 export LDFLAGS="${LDFLAGS} $*"
564 return 0
565}
566
567# @FUNCTION: filter-ldflags
568# @USAGE: <flags>
569# @DESCRIPTION:
570# Remove particular <flags> from LDFLAGS. Accepts shell globs.
571filter-ldflags() {
572 _filter-var LDFLAGS "$@"
573 return 0 578 return 0
574} 579}
575 580
576# @FUNCTION: raw-ldflags 581# @FUNCTION: raw-ldflags
577# @USAGE: [flags] 582# @USAGE: [flags]

Legend:
Removed from v.1.168  
changed lines
  Added in v.1.173

  ViewVC Help
Powered by ViewVC 1.1.20