More reliable detection of libbfd.

This commit is contained in:
Jean-Paul Chaput 2017-04-13 17:04:35 +02:00
parent a2f1db27db
commit 4126a53406
2 changed files with 55 additions and 51 deletions

View File

@ -23,6 +23,7 @@
OUTPUT_VARIABLE LD_MESSAGE OUTPUT_VARIABLE LD_MESSAGE
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
if(RETURN_CODE EQUAL 0)
string(REGEX REPLACE "GNU ld version ([^ ]+) .*" "\\1" BINUTILS_VERSION ${LD_MESSAGE} ) string(REGEX REPLACE "GNU ld version ([^ ]+) .*" "\\1" BINUTILS_VERSION ${LD_MESSAGE} )
message("-- Using system specific BFD library: " ${BINUTILS_VERSION}) message("-- Using system specific BFD library: " ${BINUTILS_VERSION})
@ -34,7 +35,7 @@
/opt/include /opt/include
ENV CPATH) ENV CPATH)
# Ugly, yes ugly... # Ugly, yes ugly...
find_library(LIBBFD_BFD_LIBRARY NAMES bfd-${BINUTILS_VERSION} bfd find_library(LIBBFD_BFD_LIBRARY NAMES bfd-${BINUTILS_VERSION} bfd
PATHS /usr/lib PATHS /usr/lib
/usr/lib64 /usr/lib64
@ -46,35 +47,36 @@
ENV LIBRARY_PATH ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH) ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_IBERTY_LIBRARY NAMES iberty #find_library (LIBBFD_IBERTY_LIBRARY NAMES iberty
# PATHS /usr/lib # PATHS /usr/lib
# /usr/lib64 # /usr/lib64
# /usr/local/lib # /usr/local/lib
# /usr/local/lib64 # /usr/local/lib64
# /usr/include # /usr/include
# /opt/local/lib # /opt/local/lib
# /opt/usr/lib64 # /opt/usr/lib64
# ENV LIBRARY_PATH # ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH) # ENV LD_LIBRARY_PATH)
#find_library (LIBBFD_OPCODES_LIBRARY NAMES opcodes #find_library (LIBBFD_OPCODES_LIBRARY NAMES opcodes
# PATHS /usr/lib # PATHS /usr/lib
# /usr/lib64 # /usr/lib64
# /usr/local/lib # /usr/local/lib
# /usr/local/lib64 # /usr/local/lib64
# /usr/include # /usr/include
# /opt/local/lib # /opt/local/lib
# /opt/usr/lib64 # /opt/usr/lib64
# ENV LIBRARY_PATH # ENV LIBRARY_PATH
# ENV LD_LIBRARY_PATH) # ENV LD_LIBRARY_PATH)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBBFD DEFAULT_MSG find_package_handle_standard_args(LIBBFD DEFAULT_MSG
LIBBFD_BFD_LIBRARY LIBBFD_BFD_LIBRARY
# LIBBFD_IBERTY_LIBRARY # LIBBFD_IBERTY_LIBRARY
# LIBBFD_OPCODES_LIBRARY # LIBBFD_OPCODES_LIBRARY
LIBBFD_INCLUDE_DIRS) LIBBFD_INCLUDE_DIRS)
endif()
if(LIBBFD_FOUND) if(LIBBFD_FOUND)
add_definitions(-DHAVE_LIBBFD) add_definitions(-DHAVE_LIBBFD)

View File

@ -82,6 +82,8 @@
#if (defined __linux__ || defined __FreeBSD__ || defined __APPLE__) #if (defined __linux__ || defined __FreeBSD__ || defined __APPLE__)
#include <execinfo.h> #include <execinfo.h>
#ifdef HAVE_LIBBFD #ifdef HAVE_LIBBFD
#define PACKAGE "Hurricane"
#define PACKAGE_VERSION "no_version"
#include <bfd.h> #include <bfd.h>
#endif #endif
#endif #endif