Fix the ctags execution.
[nethome.git] / bin / errs12
1 #! /bin/sh
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                 customss="--disable-static --enable-shared"
97         else
98                 werror=""
99         fi
100
101         test -z "$CC" && CC=gcc
102         : >errs1.c
103         for flags in                                                                                                    \
104                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
105                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
106                 ""                                                                                                      \
107                 ;do
108                 if [ -z "$flags" ];then
109                         rm -f errs1.c
110                         echo >&2 "flags error"
111                         exit 1
112                 fi
113                 "$CC" $flags -c errs1.c -o /dev/null && break
114         done
115         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
116                 flags="$customm $flags"
117         fi
118         rm -f errs1.c
119         export CFLAGS="$flags"
120         export CXXFLAGS="$flags"
121         export GCJFLAGS="$flags"
122         export CFLAGS_FOR_TARGET="$flags"
123         export CXXFLAGS_FOR_TARGET="$flags"
124         export LDFLAGS="$ldflags"
125
126         time nice "$configure" $target $targets $customss --enable-debug --disable-sim $maintainer $werror --with-separate-debug-dir=/usr/lib/debug "$@"
127
128         (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &
129
130         errs2
131
132         touch errs1.ok
133         ) 2>&1|tee errs1
134 test -f errs1.ok
135 rc=$?
136 rm -f errs1.ok
137 exit $rc