Switch to FSF GCC 4.7.
[nethome.git] / bin / errs12
index de5912d..4970709 100755 (executable)
@@ -1,16 +1,26 @@
-#! /bin/sh
+#! /bin/bash
 # $Id$
 
 renice +19 -p $$; ionice -c3 -p $$
 
+# Do not use for ctags - it would override $PATH:
+# PS1=x; . ~/.bashrc
+function ctags {(unset ctags; PS1=x; . ~/.bashrc; ctags; );}
+
 customss="--enable-static --disable-shared"
 customm="-m64"
 target=
 targets=
 configure="./configure"
-debug="-ggdb2"
+# >=4.7 has small macros section.
+if gcc --version|perl -ne 'exit(!(/(\d+)\.(\d+)/&&($1>4||($1==4&&$2>=7))));';then
+  debug="-g3"
+else
+  debug="-g2"
+fi
 ldflags="-lmcheck"
 fast=false
+readline=""
 
 while true
 do
@@ -55,7 +65,7 @@ do
        if [ "$1" = "-s" ];then
                # -O0 is important to override GCC -O2.
                debug="-O0 -s"
-               ldflags=""
+               #ldflags=""
                shift
                continue
        fi
@@ -89,11 +99,19 @@ rm -f errs1.ok
        if test -f `dirname $configure`/gcc/reload.c;then
                werror="--disable-werror"
                customm=""
+               # --disable-static would fail on finding built libstdc++ due to -static-libstdc++.
+               # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49829
+               #customss=""
                customss="--disable-static --enable-shared"
        else
                werror=""
        fi
 
+       if test -d readline/doc && ! test -e readline/readline.c;then
+               # Fedora gdb.spec prep.
+               readline="--with-system-readline"
+       fi
+
        test -z "$CC" && CC=gcc
        : >errs1.c
        for flags in                                                                                                    \
@@ -106,7 +124,10 @@ rm -f errs1.ok
                        echo >&2 "flags error"
                        exit 1
                fi
-               "$CC" $flags -c errs1.c -o /dev/null && break
+               # Use -Werror:
+               # cc1: warnings being treated as errors
+               # archive.c:1: error: -fstack-protector not supported for this target
+               "$CC" $flags -Werror -c errs1.c -o /dev/null && break
        done
        if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
                flags="$customm $flags"
@@ -119,10 +140,9 @@ rm -f errs1.ok
        export CXXFLAGS_FOR_TARGET="$flags"
        export LDFLAGS="$ldflags"
 
-       ctags
-       test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)
+       time nice "$configure" $target $targets $customss $readline --enable-debug --disable-sim --enable-gold --enable-plugins $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@"
 
-       time nice "$configure" $target $targets $customss --enable-debug --disable-sim $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@"
+       (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &
 
        errs2