blob: a0285dd62415c5748713b1e9656a38e4a77d8b84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
getPROG() {
local var=$1
local prog=$2
if [[ -n ${!var} ]] ; then
echo "${!var}"
return 0
fi
local search=
[[ -n $3 ]] && search=$(type -p "$3-${prog}")
[[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}")
[[ -n ${search} ]] && prog=${search##*/}
export ${var}=${prog}
echo "${!var}"
}
hasme() {
local x
local me=$1
shift
for x in "$@"; do
if [ "${x}" == "${me}" ]; then
return 0
fi
done
return 1
}
test_broken_flags() {
local mygcc=${1}
shift
echo 'main(){}' | ${mygcc} ${@} -E - 2>&1 | egrep "unrecognized .*option" \
| egrep -o -- '('\''|\"|`)-.*' | sed -r 's/('\''|`|")//g'
}
if [[ ${EBUILD_PHASE} == "setup" ]]; then
trigger=0
for flag in ${CFLAGS} ; do
broken_flag=$(test_broken_flags $(getPROG CC gcc) ${flag})
if [[ -n ${broken_flag} ]]; then
ewarn "Filtering out the non-existing CFLAG \"${broken_flag}\""
CFLAGS=${CFLAGS//${broken_flag}}
fi
done
for flag in ${CXXFLAGS} ; do
broken_flag=$(test_broken_flags $(getPROG CXX g++) ${flag})
if [[ -n ${broken_flag} ]]; then
ewarn "Filtering out the non-existing CXXFLAG \"${broken_flag}\""
CXXFLAGS=${CXXFLAGS//${broken_flag}}
fi
done
for flag in "-fvisibility=hidden" "-fvisibility-hidden" "-fvisibility-inline-hidden" "-fPIC" "-m32" "-m64" "-g3" "-ggdb3" ; do
hasme ${flag} ${CFLAGS} ${CXXFLAGS} && trigger=1 && \
ewarn "Your C(XX)FLAGS contain(s) \"${flag}\" which can break packages."
done
if [[ ${trigger} -ge 1 ]]; then
ewarn ""
ewarn "Before you file a bug please remove these flags and "
ewarn "re-compile the package in question as well as all its dependencies"
fi
fi
unset trigger broken_flag
|