Update.
[nethome.git] / bin / errs1
1 #! /bin/sh
2 # $Id$
3
4 customss="--enable-static --disable-shared"
5 customm="-m64"
6 target=
7 targets=
8 configure="./configure"
9 debug="-ggdb2"
10
11 while true
12 do
13         if [ "$1" = "--origss" ];then
14                 customss=
15                 shift
16                 continue
17         fi
18         if [ "$1" = "-shared" ];then
19                 customss="--disable-static --enable-shared"
20                 shift
21                 continue
22         fi
23
24         if [ "$1" = "-m" ];then
25                 customm=
26                 shift
27                 continue
28         fi
29         if [ "$1" = "-m32" ];then
30                 customm=-m32
31                 target=i386-unknown-linux-gnu
32                 shift
33                 continue
34         fi
35
36         if [ "${1#*/configure}" != "$1" ];then
37                 configure="$1"
38                 shift
39                 continue
40         fi
41
42         if [ "$1" = "-s" ];then
43                 # -O0 is important to override GCC -O2.
44                 debug="-O0 -s"
45                 shift
46                 continue
47         fi
48
49         break
50 done
51
52 (
53         set -ex
54         find -name config.cache|xargs rm -f
55
56         # sourceware.org?
57         if test -f `dirname $configure`/bfd/elf64-x86-64.c \
58              -o -f `dirname $configure`/gcc/reload.c;then
59                 maintainer=""
60         else
61                 maintainer="--enable-maintainer-mode"
62         fi
63         if test -f `dirname $configure`/bfd/elf64-x86-64.c;then
64                 test -f g77 || (test -f /usr/bin/gfortran && ln -s /usr/bin/gfortran g77)
65                 targets="--enable-targets=all"
66         fi
67
68         if test -f `dirname $configure`/gcc/reload.c;then
69                 werror="--disable-werror"
70                 customm=""
71                 customss="--disable-static --enable-shared"
72         else
73                 werror=""
74         fi
75
76         test -z "$CC" && CC=gcc
77         : >errs1.c
78         for flags in                                                                                                    \
79                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
80                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
81                 ""                                                                                                      \
82                 ;do
83                 if [ -z "$flags" ];then
84                         rm -f errs1.c
85                         echo >&2 "flags error"
86                         exit 1
87                 fi
88                 "$CC" $flags -c errs1.c -o /dev/null && break
89         done
90         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
91                 flags="$customm $flags"
92         fi
93         rm -f errs1.c
94         export CFLAGS="$flags"
95         export CXXFLAGS="$flags"
96         export GCJFLAGS="$flags"
97         export CFLAGS_FOR_TARGET="$flags"
98         export CXXFLAGS_FOR_TARGET="$flags"
99
100         time nice "$configure" $target $targets $customss --enable-debug $maintainer $werror "$@"
101         ) 2>&1|tee errs1