From 4820f0dbb77cd6564d5fa0817218fe2a1fb99f32 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 3 Feb 2017 22:01:48 -0800 Subject: [PATCH] check for libz first If building statically, linking libz before libbfd results in unresolved symbols (compress/compressBound in libbfd.a). Signed-off-by: Alexey Neyman --- configure | 94 ++++++++++++++++++++++++++-------------------------- configure.ac | 13 ++++---- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/configure b/configure index d8d14be..3a4e8d6 100755 --- a/configure +++ b/configure @@ -3779,14 +3779,14 @@ if test "$ac_binutils_build_dir" != "NONE"; then test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include" fi -if test "$ac_libiberty" = "NONE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objalloc_create in -liberty" >&5 -$as_echo_n "checking for objalloc_create in -liberty... " >&6; } -if ${ac_cv_lib_iberty_objalloc_create+:} false; then : +if test "$ac_zlib_prefix" = "NONE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5 +$as_echo_n "checking for deflate in -lz... " >&6; } +if ${ac_cv_lib_z_deflate+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-liberty $LIBS" +LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -3796,47 +3796,46 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char objalloc_create (); +char deflate (); int main () { -return objalloc_create (); +return deflate (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_iberty_objalloc_create=yes + ac_cv_lib_z_deflate=yes else - ac_cv_lib_iberty_objalloc_create=no + ac_cv_lib_z_deflate=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iberty_objalloc_create" >&5 -$as_echo "$ac_cv_lib_iberty_objalloc_create" >&6; } -if test "x$ac_cv_lib_iberty_objalloc_create" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5 +$as_echo "$ac_cv_lib_z_deflate" >&6; } +if test "x$ac_cv_lib_z_deflate" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_LIBIBERTY 1 +#define HAVE_LIBZ 1 _ACEOF - LIBS="-liberty $LIBS" + LIBS="-lz $LIBS" fi - ac_libiberty=auto else - LIBS="$ac_libiberty $LIBS" + LIBS="-L$ac_zlib_prefix/lib -lz $LIBS" fi -if test "$ac_libbfd" = "NONE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5 -$as_echo_n "checking for bfd_openr in -lbfd... " >&6; } -if ${ac_cv_lib_bfd_bfd_openr+:} false; then : +if test "$ac_libiberty" = "NONE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objalloc_create in -liberty" >&5 +$as_echo_n "checking for objalloc_create in -liberty... " >&6; } +if ${ac_cv_lib_iberty_objalloc_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lbfd $LIBS" +LIBS="-liberty $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -3846,47 +3845,47 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char bfd_openr (); +char objalloc_create (); int main () { -return bfd_openr (); +return objalloc_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_bfd_bfd_openr=yes + ac_cv_lib_iberty_objalloc_create=yes else - ac_cv_lib_bfd_bfd_openr=no + ac_cv_lib_iberty_objalloc_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5 -$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; } -if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iberty_objalloc_create" >&5 +$as_echo "$ac_cv_lib_iberty_objalloc_create" >&6; } +if test "x$ac_cv_lib_iberty_objalloc_create" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_LIBBFD 1 +#define HAVE_LIBIBERTY 1 _ACEOF - LIBS="-lbfd $LIBS" + LIBS="-liberty $LIBS" fi - ac_libbfd=auto + ac_libiberty=auto else - LIBS="$ac_libbfd $LIBS" + LIBS="$ac_libiberty $LIBS" fi -if test "$ac_zlib_prefix" = "NONE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5 -$as_echo_n "checking for deflate in -lz... " >&6; } -if ${ac_cv_lib_z_deflate+:} false; then : +if test "$ac_libbfd" = "NONE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5 +$as_echo_n "checking for bfd_openr in -lbfd... " >&6; } +if ${ac_cv_lib_bfd_bfd_openr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-lbfd $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -3896,37 +3895,38 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char deflate (); +char bfd_openr (); int main () { -return deflate (); +return bfd_openr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_z_deflate=yes + ac_cv_lib_bfd_bfd_openr=yes else - ac_cv_lib_z_deflate=no + ac_cv_lib_bfd_bfd_openr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5 -$as_echo "$ac_cv_lib_z_deflate" >&6; } -if test "x$ac_cv_lib_z_deflate" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bfd_bfd_openr" >&5 +$as_echo "$ac_cv_lib_bfd_bfd_openr" >&6; } +if test "x$ac_cv_lib_bfd_bfd_openr" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 +#define HAVE_LIBBFD 1 _ACEOF - LIBS="-lz $LIBS" + LIBS="-lbfd $LIBS" fi + ac_libbfd=auto else - LIBS="-L$ac_zlib_prefix/lib -lz $LIBS" + LIBS="$ac_libbfd $LIBS" fi bfd_include_dir= diff --git a/configure.ac b/configure.ac index dcf0f92..6002894 100644 --- a/configure.ac +++ b/configure.ac @@ -113,7 +113,13 @@ if test "$ac_binutils_build_dir" != "NONE"; then test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include" fi -dnl Checks for libraries. +dnl Checks for libraries. Look for zlib before binutils libs in case they +dnl need zlib themselves. +if test "$ac_zlib_prefix" = "NONE"; then + AC_CHECK_LIB(z, deflate) +else + LIBS="-L$ac_zlib_prefix/lib -lz $LIBS" +fi if test "$ac_libiberty" = "NONE"; then AC_CHECK_LIB(iberty, objalloc_create) ac_libiberty=auto @@ -126,11 +132,6 @@ if test "$ac_libbfd" = "NONE"; then else LIBS="$ac_libbfd $LIBS" fi -if test "$ac_zlib_prefix" = "NONE"; then - AC_CHECK_LIB(z, deflate) -else - LIBS="-L$ac_zlib_prefix/lib -lz $LIBS" -fi bfd_include_dir= if test "$ac_bfd_include_dir" != "NONE"; then -- 2.39.5