1 dnl test whether dirent has a d_off member
2 AC_DEFUN(AC_DIRENT_D_OFF,
3 [AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
7 #include <dirent.h>], [struct dirent d; d.d_off;],
8 ac_cv_dirent_d_off=yes, ac_cv_dirent_d_off=no)])
9 if test $ac_cv_dirent_d_off = yes; then
10 AC_DEFINE(HAVE_DIRENT_D_OFF,1,[Whether dirent has a d_off member])
14 dnl AC_PROG_CC_FLAG(flag)
15 AC_DEFUN(AC_PROG_CC_FLAG,
16 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
17 [echo 'void f(){}' > conftest.c
18 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
26 dnl see if a declaration exists for a function or variable
27 dnl defines HAVE_function_DECL if it exists
28 dnl AC_HAVE_DECL(var, includes)
29 AC_DEFUN(AC_HAVE_DECL,
31 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
32 AC_TRY_COMPILE([$2],[int i = (int)$1],
33 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
34 if test x"$ac_cv_have_$1_decl" = x"yes"; then
35 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
40 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
41 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
42 # [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
43 # ------------------------------------------------------
45 # Use a cache variable name containing both the library and function name,
46 # because the test really is for library $1 defining function $3, not
47 # just for library $1. Separate tests with the same $1 and different $3s
48 # may have different results.
50 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
51 # is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
52 # ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
53 # the AS_LITERAL_IF indirection.
55 # FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
56 # whatever the FUNCTION, in addition to not being a *S macro. Note
57 # that the cache does depend upon the function we are looking for.
59 # It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
60 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
61 # changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
62 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
64 AC_DEFUN([AC_CHECK_LIB_EXT],
66 AH_CHECK_LIB_EXT([$1])
67 ac_check_lib_ext_save_LIBS=$LIBS
68 LIBS="-l$1 $$2 $7 $LIBS"
70 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
71 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
75 AH_CHECK_FUNC_EXT([$3])
77 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
78 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
79 AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
81 [AS_VAR_SET(ac_Lib_func, yes);
82 AS_VAR_SET(ac_Lib_ext, yes)],
83 [AS_VAR_SET(ac_Lib_func, no);
84 AS_VAR_SET(ac_Lib_ext, no)])
86 AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
87 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
88 AS_VAR_POPDEF([ac_Lib_func])dnl
90 AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
91 [AC_TRY_LINK_FUNC([main],
92 [AS_VAR_SET(ac_Lib_ext, yes)],
93 [AS_VAR_SET(ac_Lib_ext, no)])
96 LIBS=$ac_check_lib_ext_save_LIBS
98 AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
100 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
111 AS_VAR_POPDEF([ac_Lib_ext])dnl
114 # AH_CHECK_LIB_EXT(LIBNAME)
115 # ---------------------
116 m4_define([AH_CHECK_LIB_EXT],
117 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
118 [Define to 1 if you have the `]$1[' library (-l]$1[).])])
120 # AC_CHECK_FUNCS_EXT(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
121 # -----------------------------------------------------------------
122 dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
123 dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
124 AC_DEFUN([AC_CHECK_FUNC_EXT],
126 AH_CHECK_FUNC_EXT($1)
127 ac_check_func_ext_save_LIBS=$LIBS
129 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
130 AC_CACHE_CHECK([for $1], ac_var,
131 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
132 [AS_VAR_SET(ac_var, yes)],
133 [AS_VAR_SET(ac_var, no)])])
134 LIBS=$ac_check_func_ext_save_LIBS
135 AS_IF([test AS_VAR_GET(ac_var) = yes],
136 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3],
138 AS_VAR_POPDEF([ac_var])dnl
141 # AH_CHECK_FUNC_EXT(FUNCNAME)
142 # ---------------------
143 m4_define([AH_CHECK_FUNC_EXT],
144 [AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
145 [Define to 1 if you have the `]$1[' function.])])
147 dnl Define an AC_DEFINE with ifndef guard.
148 dnl AC_N_DEFINE(VARIABLE [, VALUE])
150 [cat >> confdefs.h <<\EOF
152 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
158 dnl AC_ADD_INCLUDE(VARIABLE)
159 define(AC_ADD_INCLUDE,
160 [cat >> confdefs.h <<\EOF
165 dnl Copied from libtool.m4
166 AC_DEFUN(AC_PROG_LD_GNU,
167 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
168 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
169 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
170 ac_cv_prog_gnu_ld=yes
176 dnl Removes -I/usr/include/? from given variable
177 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
181 -I/usr/include|-I/usr/include/) ;;
182 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
188 dnl Removes -L/usr/lib/? from given variable
189 AC_DEFUN(LIB_REMOVE_USR_LIB,[
193 -L/usr/lib|-L/usr/lib/) ;;
194 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
200 dnl From Bruno Haible.
204 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
205 dnl those with the standalone portable libiconv installed).
206 AC_MSG_CHECKING(for iconv in $1)
207 jm_cv_func_iconv="no"
210 AC_TRY_LINK([#include <stdlib.h>
211 #include <giconv.h>],
212 [iconv_t cd = iconv_open("","");
213 iconv(cd,NULL,NULL,NULL,NULL);
218 if test "$jm_cv_func_iconv" != yes; then
219 AC_TRY_LINK([#include <stdlib.h>
221 [iconv_t cd = iconv_open("","");
222 iconv(cd,NULL,NULL,NULL,NULL);
224 jm_cv_func_iconv=yes)
226 if test "$jm_cv_lib_iconv" != yes; then
228 LIBS="$LIBS -lgiconv"
229 AC_TRY_LINK([#include <stdlib.h>
230 #include <giconv.h>],
231 [iconv_t cd = iconv_open("","");
232 iconv(cd,NULL,NULL,NULL,NULL);
239 if test "$jm_cv_func_iconv" != yes; then
242 AC_TRY_LINK([#include <stdlib.h>
244 [iconv_t cd = iconv_open("","");
245 iconv(cd,NULL,NULL,NULL,NULL);
248 jm_cv_func_iconv=yes)
254 if test "$jm_cv_func_iconv" = yes; then
255 if test "$jm_cv_giconv" = yes; then
256 AC_DEFINE(HAVE_GICONV, 1, [What header to include for iconv() function: giconv.h])
260 AC_DEFINE(HAVE_ICONV, 1, [What header to include for iconv() function: iconv.h])
267 if test "$jm_cv_lib_iconv" = yes; then
268 if test "$jm_cv_giconv" = yes; then
269 LIBS="$LIBS -lgiconv"
276 dnl CFLAGS_ADD_DIR(CFLAGS, $INCDIR)
277 dnl This function doesn't add -I/usr/include into CFLAGS
278 AC_DEFUN(CFLAGS_ADD_DIR,[
279 if test "$2" != "/usr/include" ; then
284 dnl LIB_ADD_DIR(LDFLAGS, $LIBDIR)
285 dnl This function doesn't add -L/usr/lib into LDFLAGS
286 AC_DEFUN(LIB_ADD_DIR,[
287 if test "$2" != "/usr/lib" ; then
292 sinclude(build/m4/public.m4)
293 sinclude(build/m4/core.m4)