2 dnl UL_PKG_STATIC(VARIABLE, MODULES)
4 dnl Calls pkg-config --static
6 AC_DEFUN([UL_PKG_STATIC], [
7 if AC_RUN_LOG([pkg-config --exists --print-errors "$2"]); then
8 $1=`pkg-config --libs --static "$2"`
10 AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
14 dnl UL_CHECK_LIB(LIBRARY, FUNCTION, [VARSUFFIX = $1]))
16 dnl The VARSUFFIX is optional and overrides the default behaviour. For example:
17 dnl UL_CHECK_LIB(yyy, func, xxx) generates have_xxx and HAVE_LIBXXX
18 dnl UL_CHECK_LIB(yyy, func) generates have_yyy and HAVE_LIBYYY
20 AC_DEFUN([UL_CHECK_LIB], [
21 m4_define([suffix], m4_default([$3],$1))
24 [AC_CHECK_LIB([$1], [$2], [AC_DEFINE(AS_TR_CPP([HAVE_LIB]suffix), 1)], [[have_]suffix=no])],
25 [AC_CHECK_LIB([$1], [$2], [], [[have_]suffix=no])])
26 AM_CONDITIONAL(AS_TR_CPP([HAVE_]suffix), [test [$have_]suffix = yes])
30 dnl UL_SET_ARCH(ARCHNAME, PATTERN)
32 dnl Define ARCH_<archname> condition if the pattern match with the current
35 AC_DEFUN([UL_SET_ARCH], [
40 AM_CONDITIONAL(AS_TR_CPP(ARCH_$1), [test "x$cpu_$1" = xtrue])
44 dnl UL_SET_FLAGS(CFLAGS, CPPFLAGS, LDFLAGS)
46 dnl Sets new global CFLAGS, CPPFLAGS and LDFLAG, the original
47 dnl setting could be restored by UL_RESTORE_FLAGS()
49 AC_DEFUN([UL_SET_FLAGS], [
51 old_CPPFLAGS="$CPPFLAGS"
52 old_LDFLAGS="$LDFLAGS"
54 CPPFLAGS="$CPPFLAGS $2"
58 dnl UL_RESTORE_FLAGS()
60 dnl Restores CFLAGS, CPPFLAGS and LDFLAG previously saved by UL_SET_FLAGS()
62 AC_DEFUN([UL_RESTORE_FLAGS], [
64 CPPFLAGS="$old_CPPFLAGS"
65 LDFLAGS="$old_LDFLAGS"
69 dnl UL_CHECK_SYSCALL(SYSCALL, FALLBACK, ...)
71 dnl Only specify FALLBACK if the SYSCALL you're checking for is a "newish" one
73 AC_DEFUN([UL_CHECK_SYSCALL], [
74 dnl This macro uses host_cpu.
75 AC_REQUIRE([AC_CANONICAL_HOST])
76 AC_CACHE_CHECK([for syscall $1],
78 [_UL_SYSCALL_CHECK_DECL([SYS_$1],
80 [dnl Our libc failed use, so see if we can get the kernel
81 dnl headers to play ball ...
82 _UL_SYSCALL_CHECK_DECL([_NR_$1],
86 if test "x$linux_os" = xyes; then
88 _UL_CHECK_SYSCALL_FALLBACK(m4_shift($@))
93 ul_cv_syscall_$1=$syscall
95 AM_CONDITIONAL([HAVE_]m4_toupper($1), [test "x$ul_cv_syscall_$1" != xno])
96 case $ul_cv_syscall_$1 in #(
97 no) AC_MSG_WARN([Unable to detect syscall $1.]) ;;
99 *) AC_DEFINE_UNQUOTED([SYS_$1], [$ul_cv_syscall_$1],
100 [Fallback syscall number for $1]) ;;
105 dnl _UL_SYSCALL_CHECK_DECL(SYMBOL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
107 dnl Check if SYMBOL is declared, using the headers needed for syscall checks.
109 m4_define([_UL_SYSCALL_CHECK_DECL],
110 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
111 #include <sys/syscall.h>
113 ]], [[int test = $1;]])],
117 dnl _UL_CHECK_SYSCALL_FALLBACK(PATTERN, VALUE, ...)
119 dnl Helper macro to create the body for the above `case'.
121 m4_define([_UL_CHECK_SYSCALL_FALLBACK],
124 $1) syscall="$2" ;;dnl
125 _UL_CHECK_SYSCALL_FALLBACK(m4_shiftn(2, $@))])dnl
129 dnl UL_REQUIRES_LINUX(NAME, [VARSUFFIX = $1])
131 dnl Modifies $build_<name> variable according to $enable_<name> and OS type. The
132 dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then
133 dnl all checks are skiped.
135 dnl The default <name> for $build_ and $enable_ could be overwrited by option $2.
137 AC_DEFUN([UL_REQUIRES_LINUX], [
138 m4_define([suffix], m4_default([$2],$1))
139 if test "x$[build_]suffix" != xno; then
140 AC_REQUIRE([AC_CANONICAL_HOST])
141 case $[enable_]suffix:$linux_os in #(
145 [build_]suffix=yes ;;
147 AC_MSG_ERROR([$1 selected for non-linux system]);;
149 [build_]suffix=yes ;;
151 AC_MSG_WARN([non-linux system; do not build $1])
157 dnl UL_REQUIRES_HAVE(NAME, HAVENAME, HAVEDESC [VARSUFFIX=$1])
159 dnl Modifies $build_<name> variable according to $enable_<name> and
160 dnl $have_<havename>. The <havedesc> is description used ifor warning/error
161 dnl message (e.g. "function").
163 dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
165 AC_DEFUN([UL_REQUIRES_HAVE], [
166 m4_define([suffix], m4_default([$4],$1))
168 if test "x$[build_]suffix" != xno; then
169 case $[enable_]suffix:$[have_]$2 in #(
173 [build_]suffix=yes ;;
175 AC_MSG_ERROR([$1 selected, but required $3 not available]);;
177 [build_]suffix=yes ;;
179 AC_MSG_WARN([$3 not found; do not build $1])
185 dnl UL_REQUIRES_BUILD(NAME, BUILDNAME, [VARSUFFIX=$1])
187 dnl Modifies $build_<name> variable according to $enable_<name> and $have_funcname.
189 dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
191 AC_DEFUN([UL_REQUIRES_BUILD], [
192 m4_define([suffix], m4_default([$3],$1))
194 if test "x$[build_]suffix" != xno; then
195 case $[enable_]suffix:$[build_]$2 in #(
199 [build_]suffix=yes ;;
201 AC_MSG_ERROR([$2 is needed to build $1]);;
203 [build_]suffix=yes ;;
205 AC_MSG_WARN([$2 disabled; do not build $1])
211 dnl UL_REQUIRES_SYSCALL_CHECK(NAME, SYSCALL-TEST, [SYSCALLNAME=$1], [VARSUFFIX=$1])
213 dnl Modifies $build_<name> variable according to $enable_<name> and SYSCALL-TEST
214 dnl result. The $enable_<name> variable could be "yes", "no" and "check". If build_<name>
215 dnl is "no" then all checks are skiped.
217 dnl Note that SYSCALL-TEST has to define $ul_cv_syscall_<name> variable, see
218 dnl also UL_CHECK_SYSCALL().
220 dnl The default <name> for $build_ and $enable_ count be overwrited by option $4 and
221 dnl $ul_cv_syscall_ could be overwrited by $3.
223 AC_DEFUN([UL_REQUIRES_SYSCALL_CHECK], [
224 m4_define([suffix], m4_default([$4],$1))
225 m4_define([callname], m4_default([$3],$1))
227 dnl This is default, $3 will redefine the condition
229 dnl TODO: remove this junk, AM_CONDITIONAL should not be used for any HAVE_*
230 dnl variables, all we need is BUILD_* only.
232 AM_CONDITIONAL([HAVE_]m4_toupper(callname), [false])
234 if test "x$[build_]suffix" != xno; then
235 if test "x$[enable_]suffix" = xno; then
239 case $[enable_]suffix:$[ul_cv_syscall_]callname in #(
243 AC_MSG_ERROR([$1 selected but callname syscall not found]) ;;
245 AC_MSG_WARN([callname syscall not found; do not build $1])
248 dnl default $ul_cv_syscall_ is SYS_ value
249 [build_]suffix=yes ;;
255 dnl UL_INIT_BUILD(NAME, [ENABLE_STATE], [VARSUFFIX = $1])
257 dnl Initializes $build_<name> variable according to $enable_<name>. If
258 dnl $enable_<name> is undefined then ENABLE_STATE is used and $enable_<name> is
259 dnl set to ENABLE_STATE.
261 dnl The default <name> for $build_ and $enable_ could be overwrited by option $2.
263 AC_DEFUN([UL_BUILD_INIT], [
264 m4_define([suffix], m4_default([$3],$1))
265 m4_define([estate], m4_default([$2],$enable_[]suffix))
267 ifelse(estate, [check], [build_[]suffix='yes' enable_[]suffix='check'],
268 estate, [yes], [build_[]suffix='yes' enable_[]suffix='yes'],
269 estate, [no], [build_[]suffix='no' enable_[]suffix='no'],
270 [build_[]suffix=$enable_[]suffix])