4 #renice +19 -p $$; ionice -c3 -p $$
5 renice +10 -p $$; ionice -c3 -p $$
7 # Do not use for ctags - it would override $PATH:
9 function ctags {(unset ctags; PS1=x; . ~/.bashrc; ctags; );}
11 customss="--enable-static --disable-shared"
15 configure="./configure"
16 # >=4.7 has small macros section.
17 if gcc --version|perl -ne 'exit(!(/(\d+)\.(\d+)/&&($1>4||($1==4&&$2>=7))));';then
24 #asan="-fsanitize=address -static-libasan"
29 disablebinutils="--disable-binutils --disable-gas --disable-gold --disable-gprof --disable-ld --disable-gprofng"
34 if [ "$1" = "--origss" ];then
39 if [ "$1" = "--fast" ];then
44 if [ "$1" = "--shared" ];then
45 customss="--disable-static --enable-shared"
50 if [ "$1" = "-m" ];then
55 if [ "$1" = "-m32" ];then
58 i?86|x86_64|ia64) target=i386-unknown-linux-gnu ;;
59 ppc*) target=powerpc64-unknown-linux-gnu ;;
60 s390*) target=s390-unknown-linux-gnu ;;
66 if [ "${1#*/configure}" != "$1" ];then
72 if [ "$1" = "-s" ];then
73 # -O0 is important to override GCC -O2.
79 if [ "$1" = "-fpermissive" ];then
80 permissive="-fpermissive"
85 if [ "$1" = "--asan" ];then
86 asan="-fsanitize=address -static-libasan"
91 if [ "$1" = "--noasan" ];then
97 if [ "$1" = "--nomcheck" ];then
103 if [ "$1" = "--binutils" ];then
104 disablebinutils="--enable-gold"
115 find -name config.cache|xargs rm -f
118 if test -f `dirname $configure`/bfd/elf64-x86-64.c \
119 -o -f `dirname $configure`/gcc/reload.c;then
123 # maintainer="--enable-maintainer-mode"
125 if test -f `dirname $configure`/bfd/elf64-x86-64.c;then
126 test -f g77 || (test -f /usr/bin/gfortran && ln -s /usr/bin/gfortran g77)
129 targets="$targets --enable-64-bit-bfd"
131 if ! $fast && test -f `dirname $configure`/bfd/elf64-x86-64.c -a '(' -d CVS -o -d .git ')';then
132 targets="$targets --enable-targets=all"
134 if test ! -e readline/readline/display.c;then # $fast ||
135 targets="$targets --with-system-readline"
138 if test -f `dirname $configure`/gcc/reload.c;then
139 werror="--disable-werror"
141 # --disable-static would fail on finding built libstdc++ due to -static-libstdc++.
142 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49829
144 customss="--disable-static --enable-shared"
149 if test -d readline/doc && ! test -e readline/readline.c;then
150 # Fedora gdb.spec prep.
151 readline="--with-system-readline"
154 if test -z "$python";then
155 if [ -x /usr/bin/python3 ];then
156 python="--with-python=/usr/bin/python3"
160 test -z "$CC" && CC=gcc
162 # -Wp,-D_FORTIFY_SOURCE=2: /usr/include/features.h:329:3: error: #warning _FORTIFY_SOURCE requested but disabled [-Werror=cpp]
163 # -ftrack-macro-expansion=0:
164 # hash.c:535:5: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
165 # hash.c:535:5: note: ...this ‘if’ clause, but it is not
167 "$debug -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagnostics-show-caret -Wno-error=cast-function-type -Wno-error=stringop-truncation -Wno-error=format-truncation $asan" \
168 "$debug -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -fno-diagnostics-show-caret $asan" \
169 "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fno-diagnostics-show-caret $asan" \
170 "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fno-diagnostics-show-caret" \
171 "$debug -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4" \
172 "$debug -pipe -Wall -fexceptions" \
175 if [ -z "$flags" ];then
177 echo >&2 "flags error"
181 # cc1: warnings being treated as errors
182 # archive.c:1: error: -fstack-protector not supported for this target
183 "$CC" $flags -Werror -c errs1.c -o /dev/null && break
185 if test -n "$customm" && "$CC" $customm -c errs1.c -o /dev/null;then
186 flags="$customm $flags"
188 echo 'int main (void) { return 0; }' >errs1.c
190 "-fuse-ld=gold -Wl,--gdb-index -ltcmalloc" \
191 "-fuse-ld=gold -Wl,--gdb-index" \
195 "$CC" $flags $ldflags errs1.c -o /dev/null && break
198 if ! echo "$flags"|grep -q 'fsanitize=address';then
201 flags="$flags -D_GLIBCXX_DEBUG"
202 export CFLAGS="$flags"
203 export CXXFLAGS="$flags $permissive"
204 export GCJFLAGS="$flags"
205 export CFLAGS_FOR_TARGET="$flags"
206 export CXXFLAGS_FOR_TARGET="$flags $permissive"
207 export LDFLAGS="$ldflags $mcheck $asan"
209 time nice "$configure" $target $targets $customss $readline $disablebinutils $python --enable-debug --disable-sim $maintainer $werror --with-separate-debug-dir=/usr/lib/debug --without-guile "$@"
210 # --enable-gold --enable-plugins
212 (ctags; test -d gdb && (cd gdb; ctags; cd testsuite; ctags; cd ../gdbserver; ctags)) &