Enable --enable-64-bit-bfd even for .tar.gz builds.
[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="-lmcheck"
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                 case `uname -m` in
39                   i?86|x86_64|ia64) target=i386-unknown-linux-gnu ;;
40                   ppc*)             target=powerpc64-unknown-linux-gnu ;;
41                   s390*)            target=s390-unknown-linux-gnu ;;
42                 esac
43                 shift
44                 continue
45         fi
46
47         if [ "${1#*/configure}" != "$1" ];then
48                 configure="$1"
49                 shift
50                 continue
51         fi
52
53         if [ "$1" = "-s" ];then
54                 # -O0 is important to override GCC -O2.
55                 debug="-O0 -s"
56                 ldflags=""
57                 shift
58                 continue
59         fi
60
61         break
62 done
63
64 (
65         set -ex
66         find -name config.cache|xargs rm -f
67
68         # sourceware.org?
69         if test -f `dirname $configure`/bfd/elf64-x86-64.c \
70              -o -f `dirname $configure`/gcc/reload.c;then
71                 maintainer=""
72         else
73                 :
74 #               maintainer="--enable-maintainer-mode"
75         fi
76         if test -f `dirname $configure`/bfd/elf64-x86-64.c;then
77                 test -f g77 || (test -f /usr/bin/gfortran && ln -s /usr/bin/gfortran g77)
78         fi
79         if ! $fast;then
80                 targets="$targets --enable-64-bit-bfd"
81         fi
82         if ! $fast && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then
83                 targets="$targets --enable-targets=all"
84         fi
85
86         if test -f `dirname $configure`/gcc/reload.c;then
87                 werror="--disable-werror"
88                 customm=""
89                 customss="--disable-static --enable-shared"
90         else
91                 werror=""
92         fi
93
94         test -z "$CC" && CC=gcc
95         : >errs1.c
96         for flags in                                                                                                    \
97                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
98                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
99                 ""                                                                                                      \
100                 ;do
101                 if [ -z "$flags" ];then
102                         rm -f errs1.c
103                         echo >&2 "flags error"
104                         exit 1
105                 fi
106                 "$CC" $flags -c errs1.c -o /dev/null && break
107         done
108         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
109                 flags="$customm $flags"
110         fi
111         rm -f errs1.c
112         export CFLAGS="$flags"
113         export CXXFLAGS="$flags"
114         export GCJFLAGS="$flags"
115         export CFLAGS_FOR_TARGET="$flags"
116         export CXXFLAGS_FOR_TARGET="$flags"
117         export LDFLAGS="$ldflags"
118
119         time nice "$configure" $target $targets $customss --enable-debug $maintainer $werror "$@"
120         ) 2>&1|tee errs1