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