Change to config libbfd detection.

Include all used functions in test script, this is to catch
unsatisfied dependency link errors.
Try to compile with libiberty and then also with libintl if the
initial test fails.
Log the executed commands at level 2, for consistency with other
config test compiles.
This commit is contained in:
Jonathan G Rennison
2015-09-14 23:00:45 +01:00
parent 1ee1c6201a
commit ede4bd3662

View File

@@ -1442,6 +1442,34 @@ make_compiler_cflags() {
eval "$5=\"$features\"" eval "$5=\"$features\""
} }
test_compile_libbfd() {
log 2 "executing $cc_host $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - $1"
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - $1 2> /dev/null << EOL
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <bfd.h>
#include <unistd.h>
int main() {
bfd_init();
bfd *abfd = bfd_openr("test", "test");
bfd_check_format(abfd, bfd_object);
bfd_get_file_flags(abfd);
bfd_map_over_sections(abfd, (void (*)(bfd*, asection*, void*)) 0, (void *) 0);
asymbol *syms = 0;
long symcount = bfd_read_minisymbols(abfd, false, (void**) &syms, (unsigned int *) 0);
bfd_get_section_flags(abfd, (asection*) 0);
bfd_get_section_vma(abfd, (asection*) 0);
bfd_section_size(abfd, (asection*) 0);
bfd_find_nearest_line(abfd, (asection*) 0, (asymbol **) 0, (bfd_vma) 0, (const char **) 0, (const char **) 0, (unsigned int *) 0);
return (int) symcount;
}
EOL
ret=$?
rm -f tmp.config.bfd
log 2 " exit code $ret"
return $ret
}
make_cflags_and_ldflags() { make_cflags_and_ldflags() {
# General CFlags for BUILD # General CFlags for BUILD
CFLAGS_BUILD="$CFLAGS_BUILD" CFLAGS_BUILD="$CFLAGS_BUILD"
@@ -1567,6 +1595,7 @@ make_cflags_and_ldflags() {
LIBS="$LIBS -lpthread" LIBS="$LIBS -lpthread"
fi fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
log 2 "executing $cc_host $CFLAGS $LDFLAGS -o tmp.config.libdl -x c++ - -ldl"
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.libdl -x c++ - -ldl 2> /dev/null << EOL "$cc_host" $CFLAGS $LDFLAGS -o tmp.config.libdl -x c++ - -ldl 2> /dev/null << EOL
#include <dlfcn.h> #include <dlfcn.h>
int main() { int main() {
@@ -1574,43 +1603,42 @@ make_cflags_and_ldflags() {
return dladdr(0, &info); return dladdr(0, &info);
} }
EOL EOL
if [ $? -ne 0 ]; then ret=$?
rm -f tmp.config.libdl
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking libdl... no" log 1 "checking libdl... no"
else else
log 1 "checking libdl... found" log 1 "checking libdl... found"
LIBS="$LIBS -ldl" LIBS="$LIBS -ldl"
CFLAGS="$CFLAGS -DWITH_DL" CFLAGS="$CFLAGS -DWITH_DL"
fi fi
rm -f tmp.config.libdl
if [ "$with_libbfd" = "1" ]; then if [ "$with_libbfd" = "1" ]; then
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - -lbfd 2> /dev/null << EOL if test_compile_libbfd "-lbfd -lz"; then
#define PACKAGE 1 LIBBFD_LIBS="-lbfd -lz"
#define PACKAGE_VERSION 1 elif test_compile_libbfd "-lbfd -liberty -lz"; then
#include <bfd.h> LIBBFD_LIBS="-lbfd -liberty -lz"
int main() { elif test_compile_libbfd "-lbfd -liberty -lintl -lz"; then
bfd_init(); LIBBFD_LIBS="-lbfd -liberty -lintl -lz"
unsigned int size;
asymbol *syms = 0;
long symcount = bfd_read_minisymbols((bfd *) 0, false, (void**) &syms, &size);
return 0;
}
EOL
if [ $? -ne 0 ]; then
log 1 "checking libbfd... no"
else else
LIBBFD_LIBS=
fi
if [ -n "$LIBBFD_LIBS" ]; then
log 1 "checking libbfd... found" log 1 "checking libbfd... found"
LIBS="$LIBS -lbfd" LIBS="$LIBS $LIBBFD_LIBS"
CFLAGS="$CFLAGS -DWITH_BFD" CFLAGS="$CFLAGS -DWITH_BFD"
if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then
CFLAGS="$CFLAGS -g1" CFLAGS="$CFLAGS -g1"
fi fi
else
log 1 "checking libbfd... no"
fi fi
rm -f tmp.config.bfd
fi fi
fi fi
if [ "$os" = "MINGW" ]; then if [ "$os" = "MINGW" ]; then
log 2 "executing $cc_host $CFLAGS $LDFLAGS -o tmp.config.dbghelp -x c++ -"
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.dbghelp -x c++ - 2> /dev/null << EOL "$cc_host" $CFLAGS $LDFLAGS -o tmp.config.dbghelp -x c++ - 2> /dev/null << EOL
#include <windows.h> #include <windows.h>
#include <dbghelp.h> #include <dbghelp.h>
@@ -1622,43 +1650,34 @@ EOL
return 0; return 0;
} }
EOL EOL
if [ $? -ne 0 ]; then ret=$?
rm -f tmp.config.dbghelp
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking dbghelp... no" log 1 "checking dbghelp... no"
else else
log 1 "checking dbghelp... found" log 1 "checking dbghelp... found"
CFLAGS="$CFLAGS -DWITH_DBGHELP" CFLAGS="$CFLAGS -DWITH_DBGHELP"
if [ "$with_libbfd" = "1" ]; then if [ "$with_libbfd" = "1" ]; then
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.bfd -x c++ - -lbfd -liberty -lintl 2> /dev/null << EOL test_compile_libbfd "-lbfd -liberty -lintl -lz"
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <bfd.h>
int main() {
bfd_init();
unsigned int size;
asymbol *syms = 0;
long symcount = bfd_read_minisymbols((bfd *) 0, false, (void**) &syms, &size);
return 0;
}
EOL
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
log 1 "checking libbfd... no" log 1 "checking libbfd... no"
else else
log 1 "checking libbfd... found" log 1 "checking libbfd... found"
LIBS="$LIBS -lbfd -liberty -lintl" LIBS="$LIBS -lbfd -liberty -lintl -lz"
CFLAGS="$CFLAGS -DWITH_BFD" CFLAGS="$CFLAGS -DWITH_BFD"
if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then
CFLAGS="$CFLAGS -g1" CFLAGS="$CFLAGS -g1"
fi fi
fi fi
rm -f tmp.config.bfd
fi fi
fi fi
rm -f tmp.config.dbghelp
fi fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
log 2 "executing $cc_host $CFLAGS $LDFLAGS -o tmp.config.demangle -x c++ - -lstdc++"
"$cc_host" $CFLAGS $LDFLAGS -o tmp.config.demangle -x c++ - -lstdc++ 2> /dev/null << EOL "$cc_host" $CFLAGS $LDFLAGS -o tmp.config.demangle -x c++ - -lstdc++ 2> /dev/null << EOL
#include <cxxabi.h> #include <cxxabi.h>
int main() { int main() {
@@ -1667,13 +1686,15 @@ EOL
return 0; return 0;
} }
EOL EOL
if [ $? -ne 0 ]; then ret=$?
rm -f tmp.config.demangle
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking abi::__cxa_demangle... no" log 1 "checking abi::__cxa_demangle... no"
else else
log 1 "checking abi::__cxa_demangle... found" log 1 "checking abi::__cxa_demangle... found"
CFLAGS="$CFLAGS -DWITH_DEMANGLE" CFLAGS="$CFLAGS -DWITH_DEMANGLE"
fi fi
rm -f tmp.config.demangle
fi fi
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then