Index: flag-o-matic.eclass =================================================================== RCS file: /home/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v retrieving revision 1.35 diff -u -b -B -w -p -r1.35 flag-o-matic.eclass --- flag-o-matic.eclass 20 Jan 2004 10:37:19 -0000 1.35 +++ flag-o-matic.eclass 4 Feb 2004 02:07:46 -0000 @@ -90,6 +90,15 @@ filter-mfpmath() { } filter-flags() { + for x in $@ ; do + case "${x}" in + -fPIC|-fpic|-fPIE|-fpie|-fstack-protector|-fstack-protector-all) + echo "${PN} ${PV} ${PR} filter-flags( $x )" + ;; + *) ;; + esac + + done # we do two loops to avoid the first and last char from being chomped. for x in $@ ; do case "${x}" in @@ -113,7 +122,6 @@ filter-flags() { append-flags() { CFLAGS="${CFLAGS} $@" CXXFLAGS="${CXXFLAGS} $@" - [ "`is-flag -fno-stack-protector`" -o "`is-flag -fno-stack-protector-all`" ] && fstack-flags return 0 } @@ -257,23 +265,45 @@ append-ldflags() { } etexec-flags() { - has_version sys-devel/hardened-gcc - if [ $? == 0 ]; then - if [ "`is-flag -yet_exec`" != "true" ]; then - debug-print ">>> appending flags -yet_exec" - append-flags -yet_exec - append-ldflags -yet_exec + if [ "$(has_gcc_extention pie)" == "pie" ]; then + has_nopie=0 + for x in ${CFLAGS} ; do + if [ "${x}" == "-nopie" ]; then + has_nopie=1 + break; + fi + done + if [ "$has_nopie" != 1 ]; then + debug-print ">>> appending flags -nopie" + CFLAGS="${CFLAGS} -nopie" + CXXFLAGS="${CXXFLAGS} -nopie" + LDFLAGS="${LDFLAGS} -nopie" fi fi } fstack-flags() { - has_version sys-devel/hardened-gcc - if [ $? == 0 ]; then - if [ "`is-flag -yno_propolice`" != "true" ]; then - debug-print ">>> appending flags -yno_propolice" - append-flags -yno_propolice - append-ldflags -yno_propolice + if [ "$(has_gcc_extention propolice)" == "propolice" ]; then + if [ "`is-flag -fno-stack-protector`" != "true" ]; then + debug-print ">>> appending flags -fno-stack-protector" + append-flags -fno-stack-protector + append-ldflags -fno-stack-protector fi fi } + +has_gcc_extention() { + e=$1 + [ "$e" == "" ] && return 1 + gcc --version| head -n 1 | cut -d ' ' -f 8- | sed s/')'// | \ + tr , ' '| tr ' ' '\n'| grep -v ^$ | while read p; do + echo ${p/-/ } | while read extention ver ; do + if [ "$extention" = "${e}" ]; then + debug-print "${extention}" + echo "${extention}" + return 0 + fi + done + done + return 1 +}