gdb: LDFLAGS=-lmcheck
[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                 targets="--enable-targets=all"
67                 ldflags="-lmcheck"
68         fi
69
70         if test -f `dirname $configure`/gcc/reload.c;then
71                 werror="--disable-werror"
72                 customm=""
73                 customss="--disable-static --enable-shared"
74         else
75                 werror=""
76         fi
77
78         test -z "$CC" && CC=gcc
79         : >errs1.c
80         for flags in                                                                                                    \
81                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4"   \
82                 "$debug -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions"                                               \
83                 ""                                                                                                      \
84                 ;do
85                 if [ -z "$flags" ];then
86                         rm -f errs1.c
87                         echo >&2 "flags error"
88                         exit 1
89                 fi
90                 "$CC" $flags -c errs1.c -o /dev/null && break
91         done
92         if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
93                 flags="$customm $flags"
94         fi
95         rm -f errs1.c
96         export CFLAGS="$flags"
97         export CXXFLAGS="$flags"
98         export GCJFLAGS="$flags"
99         export CFLAGS_FOR_TARGET="$flags"
100         export CXXFLAGS_FOR_TARGET="$flags"
101         export LDFLAGS="$ldflags"
102
103         time nice "$configure" $target $targets $customss --enable-debug $maintainer $werror "$@"
104         ) 2>&1|tee errs1