# We expect warning options for gcc as arguments and return the ones which are
# accepted by the given gcc.
#
-# $Id: ld-warnings,v 1.1 2007/12/06 20:10:19 bernd67 Exp $
set -ue
#set -vx
done
testcompile() {
- $CC $OPTS -x c - 2>&1 <<- EOF
+ $CC $OPTS -x c -o /dev/null - 2>&1 <<- EOF
int main(void) {
return 0;
}
*ld:\ unrecognized\ *option\ \'*)
opt="${error#*\'}"
opt="${opt%\'*}"
- OPTS="${OPTS//-Wl,$opt}"
+ ;;
+ *) continue
;;
esac
+ # if we come here, we have in $opt the option to remove. and
+ # we remove all instances. And we save agoinst leading "-"
+ NEW_OPTS=""
+ for o in $OPTS; do
+ case "$o" in
+ -Wl,$opt) : echo "Removed $o" >&2;;
+ *) NEW_OPTS="$NEW_OPTS $o";;
+ esac
+ done
+ OPTS="$NEW_OPTS"
done
echo $OPTS
}