+ dnl NB this may be adjusted below.
+ netbsd | openbsd )
+ LIB_STANDARD='-lgcc -lc -lgcc $(CRT_DIR)/crtend.o'
+ START_FILES='pre-crt0.o $(CRT_DIR)/crt0.o $(CRT_DIR)/crtbegin.o'
+ ;;
+esac
+
+AC_SUBST(LIB_MATH)
+AC_SUBST(START_FILES)
+
+dnl Not all platforms use crtn.o files. Check if the current one does.
+crt_files=
+
+for file in x $LIB_STANDARD $START_FILES; do
+ case "$file" in
+ *CRT_DIR*) crt_files="$crt_files `echo $file | sed -e 's|.*/||'`" ;;
+ esac
+done
+
+if test "x$crt_files" != x; then
+
+ ## If user specified a crt-dir, use that unconditionally.
+ crt_gcc=no
+
+ if test "X$CRT_DIR" = "X"; then
+
+ CRT_DIR=/usr/lib # default
+
+ case "$canonical" in
+ x86_64-*-linux-gnu* | s390x-*-linux-gnu*)
+ ## On x86-64 and s390x GNU/Linux distributions, the standard library
+ ## can be in a variety of places. We only try /usr/lib64 and /usr/lib.
+ ## For anything else (eg /usr/lib32), it is up the user to specify
+ ## the location (bug#5655).
+ ## Test for crtn.o, not just the directory, because sometimes the
+ ## directory exists but does not have the relevant files (bug#1287).
+ ## FIXME better to test for binary compatibility somehow.
+ test -e /usr/lib64/crtn.o && CRT_DIR=/usr/lib64
+ ;;
+
+ powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*) CRT_DIR=/usr/lib64 ;;
+ esac
+
+ case "$opsys" in
+ hpux10-20) CRT_DIR=/lib ;;
+ esac
+
+ test "x${GCC}" = xyes && crt_gcc=yes
+
+ fi # CRT_DIR = ""
+
+ crt_missing=
+
+ for file in $crt_files; do
+
+ ## If we're using gcc, try to determine it automatically by asking
+ ## gcc. [If this doesn't work, CRT_DIR will remain at the
+ ## system-dependent default from above.]
+ if test $crt_gcc = yes && test ! -e $CRT_DIR/$file; then
+
+ crt_file=`$CC --print-file-name=$file 2>/dev/null`
+ case "$crt_file" in
+ */*)
+ CRT_DIR=`AS_DIRNAME(["$crt_file"])`
+ ;;
+ esac
+ fi
+
+ dnl We expect all the files to be in a single directory, so after the
+ dnl first there is no point asking gcc.
+ crt_gcc=no
+
+ test -e $CRT_DIR/$file || crt_missing="$crt_missing $file"
+ done # $crt_files
+
+ test "x$crt_missing" = x || \
+ AC_MSG_ERROR([Required file(s) not found:$crt_missing
+Try using the --with-crt-dir option.])
+
+fi # crt_files != ""
+
+AC_SUBST(CRT_DIR)
+
+case $opsys in