Fix compilation with wxWidgets 2.8.12
[amule.git] / m4 / bfd.m4
blob8a27979b2340f76e99b3bd88698f1eeb2dc04464
1 #                                                       -*- Autoconf -*-
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
8 # respective authors.
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 ---------------------------------------------------------------------------
26 dnl MULE_CHECK_BFD
27 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.
34 dnl
35 dnl Compilation variables set by this function:
36 dnl     BFD_CPPFLAGS
37 dnl     BFD_LIBS
38 dnl
39 dnl Cache variables used/set:
40 dnl     ac_cv_header_ansidecl_h
41 dnl     ac_cv_header_bfd_h
42 dnl     mule_cv_lib_bfd
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],
50         [
51                 AC_MSG_CHECKING([for libraries required to link with bfd])
52                 AC_CACHE_VAL([mule_cv_lib_bfd],
53                 [
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.
57                                 echo $bfd_ldadd
58                         done | sed -e 's/^ *//;s/ *$//;s/  */ /g' | ${AWK} '!x@<:@$[]0@:>@++' >conftest.bfd_ldadd
59                         while read bfd_ldadd; do
60                                 MULE_BACKUP([LIBS])
61                                 MULE_BACKUP([LDFLAGS])
62                                 MULE_PREPEND([LIBS], [${bfd_ldadd}])
63                                 MULE_APPEND([LDFLAGS], [${ZLIB_LDFLAGS}])
64                                 AC_LINK_IFELSE([
65                                         AC_LANG_PROGRAM([[
66                                                 #include <ansidecl.h>
67                                                 #include <bfd.h>
68                                         ]], [[const char *dummy = bfd_errmsg(bfd_get_error());]])
69                                 ], [
70                                         MULE_RESTORE([LIBS])
71                                         MULE_RESTORE([LDFLAGS])
72                                         mule_cv_lib_bfd="${bfd_ldadd}"
73                                 ])
74                                 MULE_RESTORE([LIBS])
75                                 MULE_RESTORE([LDFLAGS])
76                                 AS_IF([${mule_cv_lib_bfd+:} false], [break])
77                         done <conftest.bfd_ldadd
78                         rm -f conftest.bfd_ldadd
79                 ])
81                 AS_IF([${mule_cv_lib_bfd+:} false],
82                 [
83                         BFD_CPPFLAGS="-DHAVE_BFD"
84                         BFD_LIBS="${mule_cv_lib_bfd}"
85                         AC_MSG_RESULT([${BFD_LIBS:-none required}])
86                 ], [
87                         AC_MSG_RESULT([not found])
88                         MULE_WARNING([Cannot link to the library containing the bfd functions.])
89                 ])
90         ], [
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])
92         ])
94 AC_SUBST([BFD_CPPFLAGS])dnl
95 AC_SUBST([BFD_LIBS])dnl