1 dnl AC_PROG_CC_FLAG(flag)
2 AC_DEFUN(AC_PROG_CC_FLAG,
3 [AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
4 [echo 'void f(){}' > conftest.c
5 if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
13 dnl see if a declaration exists for a function or variable
14 dnl defines HAVE_function_DECL if it exists
15 dnl AC_HAVE_DECL(var, includes)
16 AC_DEFUN(AC_HAVE_DECL,
18 AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
19 AC_TRY_COMPILE([$2],[int i = (int)$1],
20 ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
21 if test x"$ac_cv_have_$1_decl" = x"yes"; then
22 AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
27 # AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
28 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
29 # [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
30 # ------------------------------------------------------
32 # Use a cache variable name containing both the library and function name,
33 # because the test really is for library $1 defining function $3, not
34 # just for library $1. Separate tests with the same $1 and different $3s
35 # may have different results.
37 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
38 # is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
39 # ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
40 # the AS_LITERAL_IF indirection.
42 # FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
43 # whatever the FUNCTION, in addition to not being a *S macro. Note
44 # that the cache does depend upon the function we are looking for.
46 # It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
47 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
48 # changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
49 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
51 AC_DEFUN([AC_CHECK_LIB_EXT],
53 AH_CHECK_LIB_EXT([$1])
54 ac_check_lib_ext_save_LIBS=$LIBS
55 LIBS="-l$1 $$2 $7 $LIBS"
57 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
58 [AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
62 AH_CHECK_FUNC_EXT([$3])
64 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
65 [AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
66 AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
68 [AS_VAR_SET(ac_Lib_func, yes);
69 AS_VAR_SET(ac_Lib_ext, yes)],
70 [AS_VAR_SET(ac_Lib_func, no);
71 AS_VAR_SET(ac_Lib_ext, no)])
73 AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
74 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
75 AS_VAR_POPDEF([ac_Lib_func])dnl
77 AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
78 [AC_TRY_LINK_FUNC([main],
79 [AS_VAR_SET(ac_Lib_ext, yes)],
80 [AS_VAR_SET(ac_Lib_ext, no)])
83 LIBS=$ac_check_lib_ext_save_LIBS
85 AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
87 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
98 AS_VAR_POPDEF([ac_Lib_ext])dnl
101 # AH_CHECK_LIB_EXT(LIBNAME)
102 # ---------------------
103 m4_define([AH_CHECK_LIB_EXT],
104 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
105 [Define to 1 if you have the `]$1[' library (-l]$1[).])])
107 dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS,
108 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
109 dnl [OTHER-LIBRARIES])
110 dnl --------------------------------------------------------
111 dnl Search for a library defining FUNC, if it's not already available.
112 AC_DEFUN([AC_SEARCH_LIBS_EXT],
113 [AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1],
115 ac_func_search_ext_save_LIBS=$LIBS
116 ac_cv_search_ext_$1=no
117 AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
118 [ac_cv_search_ext_$1="none required"])
119 if test "$ac_cv_search_ext_$1" = no; then
121 LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS"
122 AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
123 [ac_cv_search_ext_$1="-l$ac_lib"
127 LIBS=$ac_func_search_ext_save_LIBS])
128 AS_IF([test "$ac_cv_search_ext_$1" != no],
129 [test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3"
134 dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
135 dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
136 AC_DEFUN([AC_CHECK_FUNC_EXT],
138 AH_CHECK_FUNC_EXT($1)
139 ac_check_func_ext_save_LIBS=$LIBS
141 AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
142 AC_CACHE_CHECK([for $1], ac_var,
143 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
144 [AS_VAR_SET(ac_var, yes)],
145 [AS_VAR_SET(ac_var, no)])])
146 LIBS=$ac_check_func_ext_save_LIBS
147 AS_IF([test AS_VAR_GET(ac_var) = yes],
148 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3],
150 AS_VAR_POPDEF([ac_var])dnl
153 # AH_CHECK_FUNC_EXT(FUNCNAME)
154 # ---------------------
155 m4_define([AH_CHECK_FUNC_EXT],
156 [AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
157 [Define to 1 if you have the `]$1[' function.])])
159 dnl Define an AC_DEFINE with ifndef guard.
160 dnl AC_N_DEFINE(VARIABLE [, VALUE])
162 [cat >> confdefs.h <<\EOF
164 [#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
170 dnl AC_ADD_INCLUDE(VARIABLE)
171 define(AC_ADD_INCLUDE,
172 [cat >> confdefs.h <<\EOF
177 dnl Copied from libtool.m4
178 AC_DEFUN(AC_PROG_LD_GNU,
179 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
180 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
181 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
182 ac_cv_prog_gnu_ld=yes
188 dnl Removes -I/usr/include/? from given variable
189 AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
193 -I/usr/include|-I/usr/include/) ;;
194 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
200 dnl Removes -L/usr/lib/? from given variable
201 AC_DEFUN(LIB_REMOVE_USR_LIB,[
205 -L/usr/lib|-L/usr/lib/) ;;
206 *) ac_new_flags="[$]ac_new_flags [$]i" ;;
212 sinclude(build/m4/public.m4)
213 sinclude(build/m4/core.m4)
214 sinclude(build/m4/ax_cflags_gcc_option.m4)
215 sinclude(build/m4/ax_cflags_irix_option.m4)
216 sinclude(build/m4/smb_cc_features.m4)