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