/[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.36 Revision 1.40
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
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.36 2004/02/21 07:07:56 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v 1.40 2004/03/12 11:21:15 vapier Exp $
4# 4#
5# Author Bart Verwilst <verwilst@gentoo.org> 5# Author Bart Verwilst <verwilst@gentoo.org>
6 6
7ECLASS=flag-o-matic 7ECLASS=flag-o-matic
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
15#### append-flags <flags> #### 15#### append-flags <flags> ####
16# Add extra flags to your current C[XX]FLAGS 16# Add extra flags to your current C[XX]FLAGS
17# 17#
18#### replace-flags <orig.flag> <new.flag> ### 18#### replace-flags <orig.flag> <new.flag> ###
19# Replace a flag by another one 19# Replace a flag by another one
20#
21#### replace-cpu-flags <new.cpu> <old.cpus> ###
22# Replace march/mcpu flags that specify <old.cpus>
23# with flags that specify <new.cpu>
20# 24#
21#### is-flag <flag> #### 25#### is-flag <flag> ####
22# Returns "true" if flag is set in C[XX]FLAGS 26# Returns "true" if flag is set in C[XX]FLAGS
23# Matches only complete a flag 27# Matches only complete a flag
24# 28#
73} 77}
74 78
75filter-flags() { 79filter-flags() {
76 for x in "$@" ; do 80 for x in "$@" ; do
77 case "${x}" in 81 case "${x}" in
78 -fPIC|-fpic|-fPIE|-fpie) etexec-flags;; 82 -fPIC|-fpic|-fPIE|-fpie|-pie) etexec-flags;;
79 -fstack-protector|-fstack-protector-all) fstack-flags;; 83 -fstack-protector|-fstack-protector-all) fstack-flags;;
80 *) ;; 84 *) ;;
81 esac 85 esac
82 done 86 done
83 87
84 # we do this fancy spacing stuff so as to not filter 88 # we do this fancy spacing stuff so as to not filter
85 # out part of a flag ... we want flag atoms ! :D 89 # out part of a flag ... we want flag atoms ! :D
86 CFLAGS=" ${CFLAGS} " 90 CFLAGS=" ${CFLAGS} "
87 CXXFLAGS=" ${CXXFLAGS} " 91 CXXFLAGS=" ${CXXFLAGS} "
88 for x in "$@" ; do 92 for x in "$@" ; do
89 CFLAGS="${CFLAGS/ ${x} / }" 93 CFLAGS="${CFLAGS// ${x} / }"
90 CXXFLAGS="${CXXFLAGS/ ${x} / }" 94 CXXFLAGS="${CXXFLAGS// ${x} / }"
91 done 95 done
92 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" 96 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
93 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" 97 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
94 return 0 98 return 0
99}
100
101filter-lfs-flags() {
102 filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
95} 103}
96 104
97append-flags() { 105append-flags() {
98 export CFLAGS="${CFLAGS} $@" 106 export CFLAGS="${CFLAGS} $@"
99 export CXXFLAGS="${CXXFLAGS} $@" 107 export CXXFLAGS="${CXXFLAGS} $@"
104replace-flags() { 112replace-flags() {
105 # we do this fancy spacing stuff so as to not filter 113 # we do this fancy spacing stuff so as to not filter
106 # out part of a flag ... we want flag atoms ! :D 114 # out part of a flag ... we want flag atoms ! :D
107 CFLAGS=" ${CFLAGS} " 115 CFLAGS=" ${CFLAGS} "
108 CXXFLAGS=" ${CXXFLAGS} " 116 CXXFLAGS=" ${CXXFLAGS} "
109 CFLAGS="${CFLAGS/ ${1} / ${2} }" 117 CFLAGS="${CFLAGS// ${1} / ${2} }"
110 CXXFLAGS="${CXXFLAGS/ ${1} / ${2} }" 118 CXXFLAGS="${CXXFLAGS// ${1} / ${2} }"
111 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" 119 CFLAGS="${CFLAGS:1:${#CFLAGS}-2}"
112 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}" 120 CXXFLAGS="${CXXFLAGS:1:${#CXXFLAGS}-2}"
121 return 0
122}
123
124replace-cpu-flags() {
125 local newcpu="$1" ; shift
126 local oldcpu=""
127 for oldcpu in "$@" ; do
128 replace-flags -march=${oldcpu} -march=${newcpu}
129 replace-flags -mcpu=${oldcpu} -mcpu=${newcpu}
130 replace-flags -mtune=${oldcpu} -mtune=${newcpu}
131 done
113 return 0 132 return 0
114} 133}
115 134
116is-flag() { 135is-flag() {
117 for x in ${CFLAGS} ${CXXFLAGS} ; do 136 for x in ${CFLAGS} ${CXXFLAGS} ; do

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.20