2 # This file is part of the aMule Project.
4 # Copyright (c) 2015 aMule Team ( admin@amule.org / http://www.amule.org )
6 # Any parts of this program derived from the xMule, lMule or eMule project,
7 # or contributed by third-party developers are copyrighted by their
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 dnl ---------------------------------------------------------------------------
28 dnl Check if bfd.h is on the system and usable. Also checks whether we can link
29 dnl to the bdf functions and which libraries are needed for this. The result of
30 dnl the library test is saved in the mule_cv_lib_bfd cache variable, to ensure
31 dnl that further configurations can reuse this result. In the worst case it may
32 dnl take up to 32 link tests to find (or decide that it cannot be found) the
33 dnl right set of libraries.
35 dnl Compilation variables set by this function:
39 dnl Cache variables used/set:
40 dnl ac_cv_header_ansidecl_h
41 dnl ac_cv_header_bfd_h
43 dnl ---------------------------------------------------------------------------
44 AC_DEFUN([MULE_CHECK_BFD],
45 [AC_REQUIRE([MULE_CHECK_NLS])dnl
46 AC_REQUIRE([AC_PROG_AWK])dnl
48 AC_CHECK_HEADERS([ansidecl.h bfd.h])
49 AS_IF([test $ac_cv_header_ansidecl_h = yes -a $ac_cv_header_bfd_h = yes],
51 AC_MSG_CHECKING([for libraries required to link with bfd])
52 AC_CACHE_VAL([mule_cv_lib_bfd],
54 for bfd_ldadd in MULE_COMBINATE([-lbfd], [-liberty], [-ldl], [${LIBINTL}], [${ZLIB_LIBS}]); do
55 # Doing some black magic to prevent multiple tests for the same set of
56 # libraries when any of the shell variables above expand to nothing.
58 done | sed -e 's/^ *//;s/ *$//;s/ */ /g' | ${AWK} '!x@<:@$[]0@:>@++' >conftest.bfd_ldadd
59 while read bfd_ldadd; do
61 MULE_BACKUP([LDFLAGS])
62 MULE_PREPEND([LIBS], [${bfd_ldadd}])
63 MULE_APPEND([LDFLAGS], [${ZLIB_LDFLAGS}])
68 ]], [[const char *dummy = bfd_errmsg(bfd_get_error());]])
71 MULE_RESTORE([LDFLAGS])
72 mule_cv_lib_bfd="${bfd_ldadd}"
75 MULE_RESTORE([LDFLAGS])
76 AS_IF([${mule_cv_lib_bfd+:} false], [break])
77 done <conftest.bfd_ldadd
78 rm -f conftest.bfd_ldadd
81 AS_IF([${mule_cv_lib_bfd+:} false],
83 BFD_CPPFLAGS="-DHAVE_BFD"
84 BFD_LIBS="${mule_cv_lib_bfd}"
85 AC_MSG_RESULT([${BFD_LIBS:-none required}])
87 AC_MSG_RESULT([not found])
88 MULE_WARNING([Cannot link to the library containing the bfd functions.])
91 MULE_WARNING([bfd.h not found or unusable, please install binutils development package if you are a developer or want to help testing aMule])
94 AC_SUBST([BFD_CPPFLAGS])dnl
95 AC_SUBST([BFD_LIBS])dnl