+unset command_not_found_handle
[nethome.git] / bin / errs12
1 #! /bin/bash
2 # $Id$
3
4 renice +19 -p $$; ionice -c3 -p $$
5
6 # Do not use for ctags - it would override $PATH:
7 # PS1=x; . ~/.bashrc
8 function ctags {(unset ctags; PS1=x; . ~/.bashrc; ctags; );}
9
10 customss="--enable-static --disable-shared"
11 customm="-m64"
12 target=
13 targets=
14 configure="./configure"
15 # >=4.7 has small macros section.
16 if gcc --version|perl -ne 'exit(!(/(\d+)\.(\d+)/&&($1>4||($1==4&&$2>=7))));';then
17   debug="-g3"
18 else
19   debug="-g2"
20 fi
21 mcheck="-lmcheck"
22 fast=false
23 readline=""
24
25 while true
26 do
27         if [ "$1" = "--origss" ];then
28                 customss=
29                 shift
30                 continue
31         fi
32         if [ "$1" = "--fast" ];then
33                 fast=true
34                 shift
35                 continue
36         fi
37         if [ "$1" = "--shared" ];then
38                 customss="--disable-static --enable-shared"
39                 shift
40                 continue
41         fi
42
43         if [ "$1" = "-m" ];then
44                 customm=
45                 shift
46                 continue
47         fi
48         if [ "$1" = "-m32" ];then
49                 customm=-m32
50                 case `uname -m` in
51                   i?86|x86_64|ia64) target=i386-unknown-linux-gnu ;;
52                   ppc*)             target=powerpc64-unknown-linux-gnu ;;
53                   s390*)            target=s390-unknown-linux-gnu ;;
54                 esac
55                 shift
56                 continue
57         fi
58
59         if [ "${1#*/configure}" != "$1" ];then
60                 configure="$1"
61                 shift
62                 continue
63         fi
64
65         if [ "$1" = "-s" ];then
66                 # -O0 is important to override GCC -O2.
67                 debug="-O0 -s"
68                 shift
69                 continue
70         fi
71
72         if [ "$1" = "--nomcheck" ];then
73                 mcheck=""
74                 shift
75                 continue
76         fi
77
78         break
79 done
80
81 rm -f errs1.ok
82 (
83         set -ex
84         find -name config.cache|xargs rm -f
85
86         # sourceware.org?
87         if test -f `dirname $configure`/bfd/elf64-x86-64.c \
88              -o -f `dirname $configure`/gcc/reload.c;then
89                 maintainer=""
90         else
91                 :
92 #               maintainer="--enable-maintainer-mode"
93         fi
94         if test -f `dirname $configure`/bfd/elf64-x86-64.c;then
95                 test -f g77 || (test -f /usr/bin/gfortran && ln -s /usr/bin/gfortran g77)
96         fi
97         if ! $fast;then
98                 targets="$targets --enable-64-bit-bfd"
99         fi
100         if ! $fast && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then
101                 targets="$targets --enable-targets=all"
102         fi
103
104         if test -f `dirname $configure`/gcc/reload.c;then
105                 werror="--disable-werror"
106                 customm=""
107                 # --disable-static would fail on finding built libstdc++ due to -static-libstdc++.
108                 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49829
109                 #customss=""
110                 customss="--disable-static --enable-shared"
111         else
112                 werror=""
113         fi
114
115         if test -d readline/doc && ! test -e readline/readline.c;then
116                 # Fedora gdb.spec prep.
117                 readline="--with-system-readline"
118         fi
119
120         test -z "$CC" && CC=gcc
121         : >errs1.c
122         # -Wp,-D_FORTIFY_SOURCE=2: /usr/include/features.h:329:3: error: #warning _FORTIFY_SOURCE requested but disabled [-Werror=cpp]
123         for flags in                                                                                                    \
124                 "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
125                 "$debug -pipe -Wall -fexceptions"                                               \
126                 ""                                                                                                      \
127                 ;do
128                 if [ -z "$flags" ];then
129                         rm -f errs1.c
130                         echo >&2 "flags error"
131                         exit 1
132                 fi
133                 # Use -Werror:
134                 # cc1: warnings being treated as errors
135                 # archive.c:1: error: -fstack-protector not supported for this target
136                 "$CC" $flags -Werror -c errs1.c -o /dev/null && break
137         done
138         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
139                 flags="$customm $flags"
140         fi
141         rm -f errs1.c
142         export CFLAGS="$flags"
143         export CXXFLAGS="$flags"
144         export GCJFLAGS="$flags"
145         export CFLAGS_FOR_TARGET="$flags"
146         export CXXFLAGS_FOR_TARGET="$flags"
147         export LDFLAGS="$mcheck"
148
149         time nice "$configure" $target $targets $customss $readline --enable-debug --disable-sim --enable-gold --enable-plugins $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@"
150
151         (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &
152
153         errs2
154
155         touch errs1.ok
156         ) 2>&1|tee errs1
157 test -f errs1.ok
158 rc=$?
159 rm -f errs1.ok
160 exit $rc