-lmcheck is now conditioned by -s, not by --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="-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 && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then
80                 targets="--enable-targets=all --enable-64-bit-bfd"
81         fi
82
83         if test -f `dirname $configure`/gcc/reload.c;then
84                 werror="--disable-werror"
85                 customm=""
86                 customss="--disable-static --enable-shared"
87         else
88                 werror=""
89         fi
90
91         test -z "$CC" && CC=gcc
92         : >errs1.c
93         for flags in                                                                                                    \
94                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
95                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
96                 ""                                                                                                      \
97                 ;do
98                 if [ -z "$flags" ];then
99                         rm -f errs1.c
100                         echo >&2 "flags error"
101                         exit 1
102                 fi
103                 "$CC" $flags -c errs1.c -o /dev/null && break
104         done
105         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
106                 flags="$customm $flags"
107         fi
108         rm -f errs1.c
109         export CFLAGS="$flags"
110         export CXXFLAGS="$flags"
111         export GCJFLAGS="$flags"
112         export CFLAGS_FOR_TARGET="$flags"
113         export CXXFLAGS_FOR_TARGET="$flags"
114         export LDFLAGS="$ldflags"
115
116         time nice "$configure" $target $targets $customss --enable-debug $maintainer $werror "$@"
117         ) 2>&1|tee errs1