e7c7e07999550d0d0b059ce887ee7442593a2976
[nethome.git] / bin / errs12
1 #! /bin/bash
2 # $Id$
3
4 renice +19 -p $$; ionice -c3 -p $$
5
6 # For ctags
7 PS1=x
8 . ~/.bashrc
9
10 customss="--enable-static --disable-shared"
11 customm="-m64"
12 target=
13 targets=
14 configure="./configure"
15 debug="-ggdb2"
16 ldflags="-lmcheck"
17 fast=false
18
19 while true
20 do
21         if [ "$1" = "--origss" ];then
22                 customss=
23                 shift
24                 continue
25         fi
26         if [ "$1" = "--fast" ];then
27                 fast=true
28                 shift
29                 continue
30         fi
31         if [ "$1" = "--shared" ];then
32                 customss="--disable-static --enable-shared"
33                 shift
34                 continue
35         fi
36
37         if [ "$1" = "-m" ];then
38                 customm=
39                 shift
40                 continue
41         fi
42         if [ "$1" = "-m32" ];then
43                 customm=-m32
44                 case `uname -m` in
45                   i?86|x86_64|ia64) target=i386-unknown-linux-gnu ;;
46                   ppc*)             target=powerpc64-unknown-linux-gnu ;;
47                   s390*)            target=s390-unknown-linux-gnu ;;
48                 esac
49                 shift
50                 continue
51         fi
52
53         if [ "${1#*/configure}" != "$1" ];then
54                 configure="$1"
55                 shift
56                 continue
57         fi
58
59         if [ "$1" = "-s" ];then
60                 # -O0 is important to override GCC -O2.
61                 debug="-O0 -s"
62                 #ldflags=""
63                 shift
64                 continue
65         fi
66
67         break
68 done
69
70 rm -f errs1.ok
71 (
72         set -ex
73         find -name config.cache|xargs rm -f
74
75         # sourceware.org?
76         if test -f `dirname $configure`/bfd/elf64-x86-64.c \
77              -o -f `dirname $configure`/gcc/reload.c;then
78                 maintainer=""
79         else
80                 :
81 #               maintainer="--enable-maintainer-mode"
82         fi
83         if test -f `dirname $configure`/bfd/elf64-x86-64.c;then
84                 test -f g77 || (test -f /usr/bin/gfortran && ln -s /usr/bin/gfortran g77)
85         fi
86         if ! $fast;then
87                 targets="$targets --enable-64-bit-bfd"
88         fi
89         if ! $fast && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then
90                 targets="$targets --enable-targets=all"
91         fi
92
93         if test -f `dirname $configure`/gcc/reload.c;then
94                 werror="--disable-werror"
95                 customm=""
96                 # --disable-static would fail on finding built libstdc++ due to -static-libstdc++.
97                 customss=""
98         else
99                 werror=""
100         fi
101
102         test -z "$CC" && CC=gcc
103         : >errs1.c
104         for flags in                                                                                                    \
105                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
106                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
107                 ""                                                                                                      \
108                 ;do
109                 if [ -z "$flags" ];then
110                         rm -f errs1.c
111                         echo >&2 "flags error"
112                         exit 1
113                 fi
114                 "$CC" $flags -c errs1.c -o /dev/null && break
115         done
116         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
117                 flags="$customm $flags"
118         fi
119         rm -f errs1.c
120         export CFLAGS="$flags"
121         export CXXFLAGS="$flags"
122         export GCJFLAGS="$flags"
123         export CFLAGS_FOR_TARGET="$flags"
124         export CXXFLAGS_FOR_TARGET="$flags"
125         export LDFLAGS="$ldflags"
126
127         time nice "$configure" $target $targets $customss --enable-debug --disable-sim --enable-gold --enable-plugins $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@"
128
129         (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &
130
131         errs2
132
133         touch errs1.ok
134         ) 2>&1|tee errs1
135 test -f errs1.ok
136 rc=$?
137 rm -f errs1.ok
138 exit $rc