"clang++" binary matches "(..|g\+\+|..)$" regex which was not intended for this:
this allows to pass gcc-speciefic options to clang driver resulting in build
errors due to unknown flags.
Fix pattern matching and refactor a bit.
Change-Id: I3fe0cb335f118e61e08399f6bed41232a0c84e17
Signed-off-by: Mikhail Kashkarov <m.kashkarov@partner.samsung.com>
EOF
chmod +x $TMP
-find -L $(dirname $0) -type f -a -perm -a=x | grep -E '(gcc|g\+\+|c\+\+)$' | while read tool; do
+# Match gcc|g++|c++ with optional cross- preffix and -version ([0-9] and .) # suffix
+GCC_REG='\b(gcc|g\+\+|c\+\+)([-\d\.]?)+'
+
+find -L $(dirname $0) -type f -a -perm -a=x | grep -E "($GCC_REG)$" | while read tool; do
mv $tool $tool-real
cp $TMP $tool
done
EOF
chmod +x $LD_TMP
-find -L GCC_LIBSUBDIR -type f -a -perm -a=x -name 'collect2' | while read tool; do
+GCC_REG_EXTRA='collect2'
+
+find -L GCC_LIBSUBDIR -type f -a -perm -a=x -name "$GCC_REG_EXTRA" | while read tool; do
mv $tool $tool-real
cp $LD_TMP $tool
done
if [ -d /emul ]; then
- find -L /emul -type f -a -perm -a=x | grep -E '(gcc|g\+\+|c\+\+|collect2)$' | while read tool; do
+ find -L /emul -type f -a -perm -a=x | grep -E "($GCC_REG|$GCC_REG_EXTRA)$" | while read tool; do
ln -sf $(basename $tool) $tool-real
done
fi