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