Upstream tarball 20080512
[amule.git] / acinclude.m4
bloba5ac1dcd127f6903e869d0f59ff9cdfc6eeea5f5
1 dnl ---------------------------------------------------------------------------
2 dnl AM_WXCONFIG_LARGEFILE()
3 dnl
4 dnl Test that wxWidgets is built with support for large-files. If not
5 dnl configure is terminated.
6 dnl ---------------------------------------------------------------------------
7 AC_DEFUN([AM_WXCONFIG_LARGEFILE],
9         AC_LANG_PUSH(C++)
10         
11         dnl Backup current flags and setup flags for testing
12         __CPPFLAGS=${CPPFLAGS}
13         CPPFLAGS=${WX_CPPFLAGS}
14         
15         AC_MSG_CHECKING(that wxWidgets has support for large files)
16         AC_PREPROC_IFELSE([
17                 #include <wx/wx.h>
19                 int main() {
20                 #if !HAVE_LARGEFILE_SUPPORT && !defined(_LARGE_FILES) && !defined(__WXMSW__)
21                         #error No LargeFile support!;
22                 #endif
23                         exit(0);
24                 }
25         ], , NO_LF="true")
27         if test "x${NO_LF}" != "x";
28         then
29                 AC_MSG_RESULT(no)
30                 AC_MSG_ERROR([
31                 Support for large files in wxWidgets is required by aMule.
32                 To continue you must recompile wxWidgets with support for 
33                 large files enabled.
34                 ])
35         else
36                 AC_MSG_RESULT(yes)
37         fi
39         dnl Restore backup'd flags
40         CPPFLAGS=${__CPPFLAGS}  
42         AC_LANG_POP(C++)
46 dnl --------------------------------------------------------------------------
47 dnl CCache support
48 dnl --------------------------------------------------------------------------
50 AC_DEFUN([CHECK_CCACHE],
51         [
52         if test x$ccache_prefix == x ; then
53                 ccache_full=$(which ccache)
54                 ccache_prefix=$(dirname ${ccache_full})
55         fi
56         $ccache_prefix/ccache -V > /dev/null 2>&1
57         CCACHE=$?
58         if test "$CCACHE" != 0; then
59                 result="no"
60         else
61                 result="yes"
62         fi
63      AC_MSG_CHECKING([for ccache presence])
64         AC_MSG_RESULT($result)
65         AC_SUBST(CCACHE)
66         AC_SUBST(ccache_prefix)
67         ])
70 AC_DEFUN([AM_OPTIONS_CCACHE_PFX],
72         AC_ARG_WITH(
73                 [ccache-prefix],
74                 [AS_HELP_STRING(
75                         [--with-ccache-prefix=PREFIX],
76                         [prefix where ccache is installed])],
77                 [ccache_prefix="$withval"],
78                 [ccache_prefix=""])
82 dnl ----------------------------------------------------
83 dnl CHECK_BFD
84 dnl check if bfd.h is on the system and usable
85 dnl ----------------------------------------------------
86 AC_DEFUN([CHECK_BFD],
88 AC_MSG_CHECKING([for bfd])
89 __LIBS=$LIBS
90 LIBS="-lbfd -liberty $LIBS"
91 AC_LINK_IFELSE([
92                 AC_LANG_PROGRAM([[
93                         #include <ansidecl.h>
94                         #include <bfd.h>
95                 ]], [[
96                         char *dummy = bfd_errmsg(bfd_get_error());
97                 ]])
98         ], [
99                 AC_MSG_RESULT([yes])
100                 BFD_FLAGS="-DHAVE_BFD"
101                 BFD_LIB="-lbfd -liberty"
102         ], [
103                 AC_MSG_RESULT([no])
104                 AC_MSG_WARN([
105         bfd.h not found or unusable, please install binutils development
106         package if you are a developer or want to help testing aMule])
107         ])
108 LIBS=${__LIBS}
109 AC_SUBST(BFD_FLAGS)
110 AC_SUBST(BFD_LIB)
114 dnl ----------------------------------------------------
115 dnl CHECK_AUTOPOINT
116 dnl check if autopoint is installed and fail if not
117 dnl ----------------------------------------------------
118 AC_DEFUN([CHECK_AUTOPOINT],
121 AC_MSG_CHECKING([for autopoint])
123 autopoint_version=`autopoint --version | head -n 1 | sed -e 's/.*[[^0-9.]]\([[0-9]]\{1,\}\(\.[[0-9]]\{1,\}\)\{1,2\}\)[[^0-9.]]*/\1/'`
124 if test x$autopoint_version != x; then
125         result="yes"
126 else
127         result="no"
130 HAVE_GETTEXT=$result
132 AC_MSG_RESULT($result ($autopoint_version))
133 if test x$result = xno; then
134         AC_MSG_NOTICE([You need to install GNU gettext/gettext-tools to compile aMule with i18n support])
136 AC_SUBST(HAVE_GETTEXT)
140 dnl ----------------------------------------------------
141 dnl CHECK_FLEX_EXTENDED
142 dnl check if flex can produce header files
143 dnl ----------------------------------------------------
144 AC_DEFUN([CHECK_FLEX_EXTENDED],
147 AC_MSG_CHECKING([for extended flex capabilities])
149 extended_flex=`flex --help | grep header-file`
150 if test x"$extended_flex" != x""; then
151         result="yes"
152 else
153         result="no"
156 HAVE_FLEX_EXTENDED=$result
158 AC_MSG_RESULT($result)
160 if test x$result = xno; then
161         AC_MSG_NOTICE([Your flex version doesn't support --header-file flag. This is not critical, but an upgrade is recommended ])
164 AC_SUBST(HAVE_FLEX_EXTENDED)
169 dnl ----------------------------------------------------
170 dnl CHECK_EXCEPTIONS
171 dnl Checks for broken exception-handling. This is needed
172 dnl because exception handling is broken for some archs/
173 dnl compilers.
174 dnl ----------------------------------------------------
175 AC_DEFUN([CHECK_EXCEPTIONS],
177         AC_MSG_CHECKING([for exception-handling])
179         AC_LANG_PUSH(C++)
180         AC_RUN_IFELSE([
181                 AC_LANG_PROGRAM([],
182                 [[
183                         try {
184                                 throw 1;
185                         } catch (int) {
186                                 return 0;
187                         }
188                         return 1;
189                 ]])
190         ], [
191                 AC_MSG_RESULT([yes])
192         ], [
193                 AC_MSG_RESULT([no])
194                 AC_MSG_ERROR([Exception handling does not work. Broken compiler?])
195         ], [
196                 AC_MSG_RESULT([undeterminable])
197                 AC_MSG_WARN([
198         Cross-compilation detected, so exception handling cannot be tested.
199         Note that broken exception handling in your compiler may lead to
200         unexpected crashes.])
201         ])
202         AC_LANG_POP(C++)
206 dnl ---------------------------------------------------------------------------
207 dnl GENERATE_MANS_TO_INSTALL(TESTNAME, BASENAMEPATH)
209 dnl This function will generate the list of manpages to be installed.
211 dnl TESTNAME is the name of a variable that'll evaluate to yes if this
212 dnl set of manpages need installing. The list of files will be returned in
213 dnl the TESTNAME_MANPAGES variable.
215 dnl BASENAMEPATH is the path and basename of the manpages we test for, relative
216 dnl to the package root (top_srcdir)
217 dnl ---------------------------------------------------------------------------
218 AC_DEFUN([GENERATE_MANS_TO_INSTALL],
220         if test "$[]$1" == "yes"; then
221                 if test "$LINGUAS" = ""; then
222                         $1_MANPAGES=`ls -1 ${srcdir}/$2.* | sed -e 's:.*/::g'`
223                 else
224                         $1_MANPAGES=`ls -1 ${srcdir}/$2.* | sed -e 's:.*/::g' | grep $Generate_Langs `
225                         $1_MANPAGES="`basename $2.1` $[]$1_MANPAGES"
226                 fi
227                 $1_MANPAGES=`echo $[]$1_MANPAGES | tr -d '\n'`
228         else
229                 $1_MANPAGES=
230         fi
231         AC_SUBST($1_MANPAGES)
235 dnl ---------------------------------------------------------------------------
236 dnl AC_CHECK_REGEX([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
238 dnl This function will test the existance of a POSIX compliant regex library.
239 dnl ---------------------------------------------------------------------------
240 AC_DEFUN([AC_CHECK_REGEX],
242         AC_MSG_CHECKING([for a POSIX compliant regex library])
243         regex_found=no
244         for lib in '' -lgnurx -lregex; do
245                 saved_LIBS="$LIBS"
246                 LIBS="$lib $LIBS"
247                 AC_LINK_IFELSE([
248                         AC_LANG_PROGRAM([[
249                                 #include <regex.h>
250                         ]], [[
251                                 regex_t preg;
252                                 regcomp(&preg, "", REG_EXTENDED);
253                                 regmatch_t *pmatch;
254                                 regexec(&preg, "", 0, pmatch, 0);
255                                 regfree(&preg);
256                         ]])
257                 ], [
258                         LIBS="$saved_LIBS"
259                         regex_found=yes
260                         break;
261                 ], [
262                         LIBS="$saved_LIBS"
263                 ])
264         done
265         AC_MSG_RESULT([$regex_found])
266         AS_IF([test $regex_found = yes],
267         [
268                 REGEX_LIB=$lib
269                 $1
270         ], [$2])
271         AC_SUBST([REGEX_LIB])
275 dnl ---------------------------------------------------------------------------
276 dnl CHECK_CXXABI
278 dnl This function will test the header <cxxabi.h> and __cxxabiv1::__cxa_demangle()
279 dnl ---------------------------------------------------------------------------
280 AC_DEFUN([CHECK_CXXABI],
282         AC_LANG_PUSH([C++])
283         AC_MSG_CHECKING([for <cxxabi.h> and __cxa_demangle()])
284         AC_LINK_IFELSE([
285                 AC_LANG_PROGRAM([[
286                         #include <cxxabi.h>
287                 ]], [[
288                         int status;
289                         char * demangled = abi::__cxa_demangle("", 0, 0, &status);
290                         std::type_info *ti = abi::__cxa_current_exception_type();
291                 ]])
292         ], [
293                 AH_TEMPLATE([HAVE_CXXABI], [Define to 1 if you have the <cxxabi.h> header which declares abi::__cxa_demangle()])
294                 AC_DEFINE([HAVE_CXXABI])
295                 AC_MSG_RESULT([yes])
296         ], [
297                 AC_MSG_RESULT([no])
298         ])
299         AC_LANG_POP()
303 dnl ---------------------------------------------------------------------------
304 dnl CHECK_EXECINFO
306 dnl This function will test the header <execinfo.h> and backtrace()
307 dnl ---------------------------------------------------------------------------
308 AC_DEFUN([CHECK_EXECINFO],
310         AC_MSG_CHECKING([for <execinfo.h> and backtrace()])
311         AC_LINK_IFELSE([
312                 AC_LANG_PROGRAM([[
313                         #include <execinfo.h>
314                 ]], [[
315                         void *bt[1];
316                         int n = backtrace(&bt, 1);
317                         const char **bt_syms = backtrace_symbols(bt, n);
318                 ]])
319         ], [
320                 AH_TEMPLATE([HAVE_EXECINFO], [Define to 1 if you have the <execinfo.h> header which declares backtrace()])
321                 AC_DEFINE([HAVE_EXECINFO])
322                 AC_MSG_RESULT([yes])
323         ], [
324                 AC_MSG_RESULT([no])
325         ])