Ron has been doing really good work over in v3. The problem is that the work got...
[coreboot.git] / targets / buildtarget
index 04ae5ebe325b6a7d99c6e7aeb7fd6df507feee8b..02694a2411f562cc3944da8a68231fdad6512cdf 100755 (executable)
@@ -61,7 +61,7 @@ if [ -z "$CC" ]; then
        CC=gcc
 fi
 
-$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp
+$CC -fno-stack-protector -S -xc /dev/null -o .$$.tmp 2>/dev/null
 
 if [ $? -eq 0 ]; then
        EXTRA_CFLAGS=-fno-stack-protector
@@ -69,10 +69,13 @@ fi
 
 rm -rf .$$.tmp
 
-ld --help | awk '{for (i=1;i<=NF;i++) if ($i ~ /build-id/){n++} }; END {exit n}' 
-build_id=$?
-if [ $build_id -ge 1 ] ; then
-       EXTRA_LFLAGS+=" -Wl,--build-id=none"
+# The linker output fd depends on the gcc version.
+#  1) 'ld-2.15 --help' and 'gcc-4.0 -Wl,--help' use STDOUT.
+#  2) 'gcc-3.3 --help' and 'gcc-3.4 -Wl,--help' use STDERR.
+# Thus older versions of GCC (presumably 3.x) implement a redirection of
+# output to stderr. Re-redirect stderr to stdout to work always.
+if $CC -Wl,--help 2>&1 | grep -q build-id; then
+       EXTRA_LFLAGS="$EXTRA_LFLAGS -Wl,--build-id=none"
 fi
 
 for i in $build_dir/Makefile.settings $build_dir/*/Makefile.settings