From adbc4ef4b5b969044cdb37cd9a18ed32d766e860 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 28 Jun 2011 22:50:32 -0400 Subject: [PATCH] * configure.in: Try to test for the required crt*.o files. --- ChangeLog | 4 ++ configure.in | 118 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 74 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fb10e14974..4c761ba2e39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-06-29 Glenn Morris + + * configure.in: Try to test for the required crt*.o files. + 2011-06-27 Bill Wohler * .bzrignore: Add lisp/mh-e/mh-autoloads.el and lisp/mh-e/mh-cus-load.el. diff --git a/configure.in b/configure.in index 0e9f031c164..5374dfe47dd 100644 --- a/configure.in +++ b/configure.in @@ -988,54 +988,6 @@ dnl Do this early because it can frob feature test macros for Unix-98 &c. AC_SYS_LARGEFILE -## If user specified a crt-dir, use that unconditionally. -if test "X$CRT_DIR" = "X"; then - - 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 - - ## Default is /usr/lib. - test "X$CRT_DIR" = "X" && CRT_DIR=/usr/lib - - ## 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 "x${GCC}" = xyes; then - crt_file=`$CC --print-file-name=crt1.o 2>/dev/null` - case "$crt_file" in - */*) - CRT_DIR=`AS_DIRNAME(["$crt_file"])` - ;; - esac - fi - -else - - ## Some platforms don't use any of these files, so it is not - ## appropriate to put this test outside the if block. - test -e $CRT_DIR/crtn.o || test -e $CRT_DIR/crt0.o || \ - AC_MSG_ERROR([crt*.o not found in specified location.]) - -fi - -AC_SUBST(CRT_DIR) - LIB_MATH=-lm LIB_STANDARD= START_FILES= @@ -1076,6 +1028,76 @@ 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. + 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 + + fi # CRT_DIR = "" + + crt_missing= + crt_gcc=no + test "x${GCC}" = xyes && crt_gcc=yes + + 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.] + ## Note that this overrides a faulty with-crt-dir. + if test $crt_gcc = yes && test ! -e $CRT_DIR/$file; then + crt_gcc=no dnl only try once + + crt_file=`$CC --print-file-name=$file 2>/dev/null` + case "$crt_file" in + */*) + CRT_DIR=`AS_DIRNAME(["$crt_file"])` + ;; + esac + fi + + 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) + + dnl This function definition taken from Gnome 2.0 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page