| 1 |
dnl If needed, define the m4_ifblank and m4_ifnblank macros from autoconf 2.64 |
| 2 |
dnl This allows us to run with earlier Autoconfs as well. |
| 3 |
dnl |
| 4 |
dnl m4_ifblank(COND, [IF-BLANK], [IF-TEXT]) |
| 5 |
dnl m4_ifnblank(COND, [IF-TEXT], [IF-BLANK]) |
| 6 |
dnl ---------------------------------------- |
| 7 |
dnl If COND is empty, or consists only of blanks (space, tab, newline), |
| 8 |
dnl then expand IF-BLANK, otherwise expand IF-TEXT. This differs from |
| 9 |
dnl m4_ifval only if COND has just whitespace, but it helps optimize in |
| 10 |
dnl spite of users who mistakenly leave trailing space after what they |
| 11 |
dnl thought was an empty argument: |
| 12 |
dnl macro( |
| 13 |
dnl [] |
| 14 |
dnl ) |
| 15 |
dnl |
| 16 |
dnl Writing one macro in terms of the other causes extra overhead, so |
| 17 |
dnl we inline both definitions. |
| 18 |
ifdef([m4_ifblank],[],[ |
| 19 |
m4_define([m4_ifblank], |
| 20 |
[m4_if(m4_translit([[$1]], [ ][ ][ |
| 21 |
]), [], [$2], [$3])])]) |
| 22 |
|
| 23 |
ifdef([m4_ifnblank],[],[ |
| 24 |
m4_define([m4_ifnblank], |
| 25 |
[m4_if(m4_translit([[$1]], [ ][ ][ |
| 26 |
]), [], [$3], [$2])])]) |
| 27 |
|
| 28 |
dnl UL_PKG_STATIC(VARIABLE, MODULES) |
| 29 |
dnl |
| 30 |
dnl Calls pkg-config --static |
| 31 |
dnl |
| 32 |
AC_DEFUN([UL_PKG_STATIC], [ |
| 33 |
if test "$enable_static" != xno; then |
| 34 |
if AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$2"]); then |
| 35 |
$1=`$PKG_CONFIG --libs --static "$2"` |
| 36 |
else |
| 37 |
AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available]) |
| 38 |
fi |
| 39 |
fi |
| 40 |
]) |
| 41 |
|
| 42 |
dnl UL_CHECK_LIB(LIBRARY, FUNCTION, [VARSUFFIX = $1])) |
| 43 |
dnl |
| 44 |
dnl The VARSUFFIX is optional and overrides the default behavior. For example: |
| 45 |
dnl UL_CHECK_LIB(yyy, func, xxx) generates have_xxx and HAVE_LIBXXX |
| 46 |
dnl UL_CHECK_LIB(yyy, func) generates have_yyy and HAVE_LIBYYY |
| 47 |
dnl |
| 48 |
AC_DEFUN([UL_CHECK_LIB], [ |
| 49 |
m4_define([suffix], m4_default([$3],$1)) |
| 50 |
[have_]suffix=yes |
| 51 |
m4_ifdef([$3], |
| 52 |
[AC_CHECK_LIB([$1], [$2], [AC_DEFINE(AS_TR_CPP([HAVE_LIB]suffix), 1)], [[have_]suffix=no])], |
| 53 |
[AC_CHECK_LIB([$1], [$2], [], [[have_]suffix=no])]) |
| 54 |
AM_CONDITIONAL(AS_TR_CPP([HAVE_]suffix), [test [$have_]suffix = yes]) |
| 55 |
]) |
| 56 |
|
| 57 |
|
| 58 |
dnl UL_SET_ARCH(ARCHNAME, PATTERN) |
| 59 |
dnl |
| 60 |
dnl Define ARCH_<archname> condition if the pattern match with the current |
| 61 |
dnl architecture |
| 62 |
dnl |
| 63 |
AC_DEFUN([UL_SET_ARCH], [ |
| 64 |
cpu_$1=false |
| 65 |
case "$host" in |
| 66 |
$2) cpu_$1=true ;; |
| 67 |
esac |
| 68 |
AM_CONDITIONAL(AS_TR_CPP(ARCH_$1), [test "x$cpu_$1" = xtrue]) |
| 69 |
]) |
| 70 |
|
| 71 |
|
| 72 |
dnl UL_SET_LIBS(LIBS) |
| 73 |
dnl |
| 74 |
dnl Sets new global LIBS, the original setting could be restored by UL_RESTORE_LIBS() |
| 75 |
dnl |
| 76 |
AC_DEFUN([UL_SET_LIBS], [ |
| 77 |
old_LIBS="$LIBS" |
| 78 |
LIBS="$LIBS $1" |
| 79 |
]) |
| 80 |
|
| 81 |
dnl UL_RESTORE_LIBS() |
| 82 |
dnl |
| 83 |
dnl Restores LIBS previously saved by UL_SET_LIBS() |
| 84 |
dnl |
| 85 |
AC_DEFUN([UL_RESTORE_LIBS], [ |
| 86 |
LIBS="$old_LIBS" |
| 87 |
]) |
| 88 |
|
| 89 |
|
| 90 |
dnl UL_CHECK_SYSCALL(SYSCALL, FALLBACK, ...) |
| 91 |
dnl |
| 92 |
dnl Only specify FALLBACK if the SYSCALL you're checking for is a "newish" one |
| 93 |
dnl |
| 94 |
AC_DEFUN([UL_CHECK_SYSCALL], [ |
| 95 |
dnl This macro uses host_cpu. |
| 96 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 97 |
AC_CACHE_CHECK([for syscall $1], |
| 98 |
[ul_cv_syscall_$1], |
| 99 |
[_UL_SYSCALL_CHECK_DECL([SYS_$1], |
| 100 |
[syscall=SYS_$1], |
| 101 |
[dnl Our libc failed use, so see if we can get the kernel |
| 102 |
dnl headers to play ball ... |
| 103 |
_UL_SYSCALL_CHECK_DECL([__NR_$1], |
| 104 |
[syscall=__NR_$1], |
| 105 |
[ |
| 106 |
syscall=no |
| 107 |
if test "x$linux_os" = xyes; then |
| 108 |
case $host_cpu in |
| 109 |
_UL_CHECK_SYSCALL_FALLBACK(m4_shift($@)) |
| 110 |
esac |
| 111 |
fi |
| 112 |
]) |
| 113 |
]) |
| 114 |
ul_cv_syscall_$1=$syscall |
| 115 |
]) |
| 116 |
case $ul_cv_syscall_$1 in #( |
| 117 |
no) AC_MSG_WARN([Unable to detect syscall $1.]) ;; |
| 118 |
SYS_*) ;; |
| 119 |
*) AC_DEFINE_UNQUOTED([SYS_$1], [$ul_cv_syscall_$1], |
| 120 |
[Fallback syscall number for $1]) ;; |
| 121 |
esac |
| 122 |
]) |
| 123 |
|
| 124 |
|
| 125 |
dnl _UL_SYSCALL_CHECK_DECL(SYMBOL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND) |
| 126 |
dnl |
| 127 |
dnl Check if SYMBOL is declared, using the headers needed for syscall checks. |
| 128 |
dnl |
| 129 |
m4_define([_UL_SYSCALL_CHECK_DECL], |
| 130 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
| 131 |
#include <sys/syscall.h> |
| 132 |
#include <unistd.h> |
| 133 |
]], [[int test = $1;]])], |
| 134 |
[$2], [$3]) |
| 135 |
]) |
| 136 |
|
| 137 |
dnl _UL_CHECK_SYSCALL_FALLBACK(PATTERN, VALUE, ...) |
| 138 |
dnl |
| 139 |
dnl Helper macro to create the body for the above `case'. |
| 140 |
dnl |
| 141 |
m4_define([_UL_CHECK_SYSCALL_FALLBACK], |
| 142 |
[m4_ifval([$1], |
| 143 |
[#( |
| 144 |
$1) syscall="$2" ;;dnl |
| 145 |
_UL_CHECK_SYSCALL_FALLBACK(m4_shiftn(2, $@))])dnl |
| 146 |
]) |
| 147 |
|
| 148 |
|
| 149 |
dnl UL_REQUIRES_LINUX(NAME, [VARSUFFIX = $1]) |
| 150 |
dnl |
| 151 |
dnl Modifies $build_<name> variable according to $enable_<name> and OS type. The |
| 152 |
dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then |
| 153 |
dnl all checks are skipped. |
| 154 |
dnl |
| 155 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $2. |
| 156 |
dnl |
| 157 |
AC_DEFUN([UL_REQUIRES_LINUX], [ |
| 158 |
m4_define([suffix], m4_default([$2],$1)) |
| 159 |
if test "x$[build_]suffix" != xno; then |
| 160 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 161 |
case $[enable_]suffix:$linux_os in #( |
| 162 |
no:*) |
| 163 |
[build_]suffix=no ;; |
| 164 |
yes:yes) |
| 165 |
[build_]suffix=yes ;; |
| 166 |
yes:*) |
| 167 |
AC_MSG_ERROR([$1 selected for non-linux system]);; |
| 168 |
check:yes) |
| 169 |
[build_]suffix=yes ;; |
| 170 |
check:*) |
| 171 |
AC_MSG_WARN([non-linux system; not building $1]) |
| 172 |
[build_]suffix=no ;; |
| 173 |
esac |
| 174 |
fi |
| 175 |
]) |
| 176 |
|
| 177 |
|
| 178 |
dnl UL_EXCLUDE_ARCH(NAME, ARCH, [VARSUFFIX = $1]) |
| 179 |
dnl |
| 180 |
dnl Modifies $build_<name> variable according to $enable_<name> and $host. The |
| 181 |
dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then |
| 182 |
dnl all checks are skipped. |
| 183 |
dnl |
| 184 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $3. |
| 185 |
dnl |
| 186 |
AC_DEFUN([UL_EXCLUDE_ARCH], [ |
| 187 |
m4_define([suffix], m4_default([$3],$1)) |
| 188 |
if test "x$[build_]suffix" != xno; then |
| 189 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 190 |
case $[enable_]suffix:"$host" in #( |
| 191 |
no:*) |
| 192 |
[build_]suffix=no ;; |
| 193 |
yes:$2) |
| 194 |
AC_MSG_ERROR([$1 selected for unsupported architecture]);; |
| 195 |
yes:*) |
| 196 |
[build_]suffix=yes ;; |
| 197 |
check:$2) |
| 198 |
AC_MSG_WARN([excluded for $host architecture; not building $1]) |
| 199 |
[build_]suffix=no ;; |
| 200 |
check:*) |
| 201 |
[build_]suffix=yes ;; |
| 202 |
esac |
| 203 |
fi |
| 204 |
]) |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
dnl UL_REQUIRES_ARCH(NAME, ARCH, [VARSUFFIX = $1]) |
| 209 |
dnl |
| 210 |
dnl Modifies $build_<name> variable according to $enable_<name> and $host. The |
| 211 |
dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then |
| 212 |
dnl all checks are skipped. |
| 213 |
dnl |
| 214 |
dnl The <arch> maybe a list, then at least one of the patterns in the list |
| 215 |
dnl have to match. |
| 216 |
dnl |
| 217 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $3. |
| 218 |
dnl |
| 219 |
AC_DEFUN([UL_REQUIRES_ARCH], [ |
| 220 |
m4_define([suffix], m4_default([$3],$1)) |
| 221 |
if test "x$[build_]suffix" != xno; then |
| 222 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 223 |
[ul_archone_]suffix=no |
| 224 |
m4_foreach([onearch], [$2], [ |
| 225 |
case "$host" in #( |
| 226 |
onearch) |
| 227 |
[ul_archone_]suffix=yes ;; |
| 228 |
esac |
| 229 |
])dnl |
| 230 |
case $[enable_]suffix:$[ul_archone_]suffix in #( |
| 231 |
no:*) |
| 232 |
[build_]suffix=no ;; |
| 233 |
yes:no) |
| 234 |
AC_MSG_ERROR([$1 selected for unsupported architecture]);; |
| 235 |
yes:*) |
| 236 |
[build_]suffix=yes ;; |
| 237 |
check:no) |
| 238 |
AC_MSG_WARN([excluded for $host architecture; not building $1]) |
| 239 |
[build_]suffix=no ;; |
| 240 |
check:*) |
| 241 |
[build_]suffix=yes ;; |
| 242 |
esac |
| 243 |
fi |
| 244 |
]) |
| 245 |
|
| 246 |
dnl UL_REQUIRES_HAVE(NAME, HAVENAME, HAVEDESC, [VARSUFFIX=$1]) |
| 247 |
dnl |
| 248 |
dnl Modifies $build_<name> variable according to $enable_<name> and |
| 249 |
dnl $have_<havename>. The <havedesc> is description used for warning/error |
| 250 |
dnl message (e.g. "function"). |
| 251 |
dnl |
| 252 |
dnl The <havename> maybe a list, then at least one of the items in the list |
| 253 |
dnl have to exist, for example: [ncurses, tinfo] means that have_ncurser=yes |
| 254 |
dnl *or* have_tinfo=yes must be defined. |
| 255 |
dnl |
| 256 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $4. |
| 257 |
dnl |
| 258 |
AC_DEFUN([UL_REQUIRES_HAVE], [ |
| 259 |
m4_define([suffix], m4_default([$4],$1)) |
| 260 |
|
| 261 |
if test "x$[build_]suffix" != xno; then |
| 262 |
|
| 263 |
[ul_haveone_]suffix=no |
| 264 |
m4_foreach([onehave], [$2], [ |
| 265 |
if test "x$[have_]onehave" = xyes; then |
| 266 |
[ul_haveone_]suffix=yes |
| 267 |
fi |
| 268 |
])dnl |
| 269 |
|
| 270 |
case $[enable_]suffix:$[ul_haveone_]suffix in #( |
| 271 |
no:*) |
| 272 |
[build_]suffix=no ;; |
| 273 |
yes:yes) |
| 274 |
[build_]suffix=yes ;; |
| 275 |
yes:*) |
| 276 |
AC_MSG_ERROR([$1 selected, but required $3 not available]);; |
| 277 |
check:yes) |
| 278 |
[build_]suffix=yes ;; |
| 279 |
check:*) |
| 280 |
AC_MSG_WARN([$3 not found; not building $1]) |
| 281 |
[build_]suffix=no ;; |
| 282 |
esac |
| 283 |
fi |
| 284 |
]) |
| 285 |
|
| 286 |
dnl UL_REQUIRES_COMPILE(NAME, PROGRAM_PROLOGUE, PROGRAM_BODY, DESC, [VARSUFFIX=$1]) |
| 287 |
dnl |
| 288 |
dnl Modifies $build_<name> variable according to $enable_<name> and |
| 289 |
dnl ability compile AC_LANG_PROGRAM(<program_prologue>, <program_body>). |
| 290 |
dnl |
| 291 |
dnl The <desc> is description used for warning/error dnl message (e.g. "foo support"). |
| 292 |
dnl |
| 293 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $5. |
| 294 |
|
| 295 |
AC_DEFUN([UL_REQUIRES_COMPILE], [ |
| 296 |
m4_define([suffix], m4_default([$5],$1)) |
| 297 |
|
| 298 |
if test "x$[build_]suffix" != xno; then |
| 299 |
|
| 300 |
AC_MSG_CHECKING([$4]) |
| 301 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$3])], |
| 302 |
[AC_MSG_RESULT([yes]) |
| 303 |
[ul_haveprogram_]suffix=yes], |
| 304 |
[AC_MSG_RESULT([no]) |
| 305 |
[ul_haveprogram_]suffix=no]) |
| 306 |
|
| 307 |
case $[enable_]suffix:$[ul_haveprogram_]suffix in #( |
| 308 |
no:*) |
| 309 |
[build_]suffix=no ;; |
| 310 |
yes:yes) |
| 311 |
[build_]suffix=yes ;; |
| 312 |
yes:*) |
| 313 |
AC_MSG_ERROR([$1 selected, but required $4 not available]);; |
| 314 |
check:yes) |
| 315 |
[build_]suffix=yes ;; |
| 316 |
check:*) |
| 317 |
AC_MSG_WARN([$4 not found; not building $1]) |
| 318 |
[build_]suffix=no ;; |
| 319 |
esac |
| 320 |
fi |
| 321 |
]) |
| 322 |
|
| 323 |
|
| 324 |
dnl UL_REQUIRES_PROGRAM(NAME, PROGVAR, PROGRAM, DESC, [VARSUFFIX=$1]) |
| 325 |
dnl |
| 326 |
dnl Modifies $build_<name> variable according to $enable_<name> and |
| 327 |
dnl ability compile AC_PATH_PROG(). |
| 328 |
dnl |
| 329 |
dnl The <desc> is description used for warning/error dnl message (e.g. "foo support"). |
| 330 |
dnl |
| 331 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $5. |
| 332 |
AC_DEFUN([UL_REQUIRES_PROGRAM], [ |
| 333 |
m4_define([suffix], m4_default([$5],$1)) |
| 334 |
|
| 335 |
if test "x$[build_]suffix" != xno; then |
| 336 |
|
| 337 |
AC_PATH_PROG([$2], [$3]) |
| 338 |
|
| 339 |
case $[enable_]suffix:x$$2 in #( |
| 340 |
no:*) |
| 341 |
[build_]suffix=no ;; |
| 342 |
yes:x) |
| 343 |
AC_MSG_ERROR([$1 selected, but required $3 not available]);; |
| 344 |
yes:x*) |
| 345 |
[build_]suffix=yes ;; |
| 346 |
check:x) |
| 347 |
AC_MSG_WARN([$3 not found; not building $4]) |
| 348 |
[build_]suffix=no ;; |
| 349 |
check:x*) |
| 350 |
[build_]suffix=yes ;; |
| 351 |
esac |
| 352 |
fi |
| 353 |
]) |
| 354 |
|
| 355 |
dnl |
| 356 |
dnl UL_CONFLICTS_BUILD(NAME, ANOTHER, ANOTHERDESC, [VARSUFFIX=$1]) |
| 357 |
dnl |
| 358 |
dnl - ends with error if $enable_<name> and $build_<another> |
| 359 |
dnl are both set to 'yes' |
| 360 |
dnl - sets $build_<name> to 'no' if $build_<another> is 'yes' and |
| 361 |
dnl $enable_<name> is 'check' or 'no' |
| 362 |
dnl |
| 363 |
dnl The <havedesc> is description used for warning/error |
| 364 |
dnl message (e.g. "function"). |
| 365 |
dnl |
| 366 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $4. |
| 367 |
dnl |
| 368 |
AC_DEFUN([UL_CONFLICTS_BUILD], [ |
| 369 |
m4_define([suffix], m4_default([$4],$1)) |
| 370 |
|
| 371 |
if test "x$[build_]suffix" != xno; then |
| 372 |
case $[enable_]suffix:$[build_]$2 in #( |
| 373 |
no:*) |
| 374 |
[build_]suffix=no ;; |
| 375 |
check:yes) |
| 376 |
[build_]suffix=no ;; |
| 377 |
check:no) |
| 378 |
[build_]suffix=yes ;; |
| 379 |
yes:yes) |
| 380 |
AC_MSG_ERROR([$1 selected, but it conflicts with $3]);; |
| 381 |
esac |
| 382 |
fi |
| 383 |
]) |
| 384 |
|
| 385 |
|
| 386 |
dnl UL_REQUIRES_BUILD(NAME, BUILDNAME, [VARSUFFIX=$1]) |
| 387 |
dnl |
| 388 |
dnl Modifies $build_<name> variable according to $enable_<name> and $have_funcname. |
| 389 |
dnl |
| 390 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $3. |
| 391 |
dnl |
| 392 |
AC_DEFUN([UL_REQUIRES_BUILD], [ |
| 393 |
m4_define([suffix], m4_default([$3],$1)) |
| 394 |
|
| 395 |
if test "x$[build_]suffix" != xno; then |
| 396 |
case $[enable_]suffix:$[build_]$2 in #( |
| 397 |
no:*) |
| 398 |
[build_]suffix=no ;; |
| 399 |
yes:yes) |
| 400 |
[build_]suffix=yes ;; |
| 401 |
yes:*) |
| 402 |
AC_MSG_ERROR([$2 is needed to build $1]);; |
| 403 |
check:yes) |
| 404 |
[build_]suffix=yes ;; |
| 405 |
check:*) |
| 406 |
AC_MSG_WARN([$2 disabled; not building $1]) |
| 407 |
[build_]suffix=no ;; |
| 408 |
esac |
| 409 |
fi |
| 410 |
]) |
| 411 |
|
| 412 |
dnl UL_REQUIRES_SYSCALL_CHECK(NAME, SYSCALL-TEST, [SYSCALLNAME=$1], [VARSUFFIX=$1]) |
| 413 |
dnl |
| 414 |
dnl Modifies $build_<name> variable according to $enable_<name> and SYSCALL-TEST |
| 415 |
dnl result. The $enable_<name> variable could be "yes", "no" and "check". If build_<name> |
| 416 |
dnl is "no" then all checks are skipped. |
| 417 |
dnl |
| 418 |
dnl Note that SYSCALL-TEST has to define $ul_cv_syscall_<name> variable, see |
| 419 |
dnl also UL_CHECK_SYSCALL(). |
| 420 |
dnl |
| 421 |
dnl The default <name> for $build_ and $enable_ count be overwritten by option $4 and |
| 422 |
dnl $ul_cv_syscall_ could be overwritten by $3. |
| 423 |
dnl |
| 424 |
AC_DEFUN([UL_REQUIRES_SYSCALL_CHECK], [ |
| 425 |
m4_define([suffix], m4_default([$4],$1)) |
| 426 |
m4_define([callname], m4_default([$3],$1)) |
| 427 |
|
| 428 |
if test "x$[build_]suffix" != xno; then |
| 429 |
if test "x$[enable_]suffix" = xno; then |
| 430 |
[build_]suffix=no |
| 431 |
else |
| 432 |
$2 |
| 433 |
case $[enable_]suffix:$[ul_cv_syscall_]callname in #( |
| 434 |
no:*) |
| 435 |
[build_]suffix=no ;; |
| 436 |
yes:no) |
| 437 |
AC_MSG_ERROR([$1 selected but callname syscall not found]) ;; |
| 438 |
check:no) |
| 439 |
AC_MSG_WARN([callname syscall not found; not building $1]) |
| 440 |
[build_]suffix=no ;; |
| 441 |
*) |
| 442 |
dnl default $ul_cv_syscall_ is SYS_ value |
| 443 |
[build_]suffix=yes ;; |
| 444 |
esac |
| 445 |
fi |
| 446 |
fi |
| 447 |
]) |
| 448 |
|
| 449 |
dnl UL_BUILD_INIT(NAME, [ENABLE_STATE], [VARSUFFIX = $1]) |
| 450 |
dnl |
| 451 |
dnl Initializes $build_<name> variable according to $enable_<name>. If |
| 452 |
dnl $enable_<name> is undefined then ENABLE_STATE is used and $enable_<name> is |
| 453 |
dnl set to ENABLE_STATE. |
| 454 |
dnl |
| 455 |
dnl The default <name> for $build_ and $enable_ could be overwritten by option $3. |
| 456 |
dnl |
| 457 |
AC_DEFUN([UL_BUILD_INIT], [ |
| 458 |
m4_define([suffix], m4_default([$3],$1)) |
| 459 |
m4_ifblank([$2], |
| 460 |
[if test "x$enable_[]suffix" = xno; then |
| 461 |
build_[]suffix=no |
| 462 |
else |
| 463 |
build_[]suffix=yes |
| 464 |
fi], |
| 465 |
[if test "x$ul_default_estate" != x; then |
| 466 |
enable_[]suffix=$ul_default_estate |
| 467 |
build_[]suffix=yes |
| 468 |
if test "x$ul_default_estate" = xno; then |
| 469 |
build_[]suffix=no |
| 470 |
fi |
| 471 |
else[] |
| 472 |
ifelse( |
| 473 |
[$2], [check],[ |
| 474 |
build_[]suffix=yes |
| 475 |
enable_[]suffix=check], |
| 476 |
[$2], [yes],[ |
| 477 |
build_[]suffix=yes |
| 478 |
enable_[]suffix=yes], |
| 479 |
[$2], [no], [ |
| 480 |
build_[]suffix=no |
| 481 |
enable_[]suffix=no]) |
| 482 |
fi]) |
| 483 |
]) |
| 484 |
|
| 485 |
dnl UL_DEFAULT_ENABLE(NAME, ENABLE_STATE) |
| 486 |
dnl |
| 487 |
dnl Initializes $enable_<name> variable according to ENABLE_STATE. The default |
| 488 |
dnl setting is possible to override by global $ul_default_estate. |
| 489 |
dnl |
| 490 |
AC_DEFUN([UL_DEFAULT_ENABLE], [ |
| 491 |
m4_define([suffix], $1) |
| 492 |
if test "x$ul_default_estate" != x; then |
| 493 |
enable_[]suffix=$ul_default_estate |
| 494 |
else |
| 495 |
enable_[]suffix=$2 |
| 496 |
fi |
| 497 |
]) |
| 498 |
|
| 499 |
|
| 500 |
dnl UL_ENABLE_ALIAS(NAME, MASTERNAME) |
| 501 |
dnl |
| 502 |
dnl Initializes $enable_<name> variable according to $enable_<mastername>. This |
| 503 |
dnl is useful for example if you want to use one --enable-mastername option |
| 504 |
dnl for group of programs. |
| 505 |
dnl |
| 506 |
AC_DEFUN([UL_ENABLE_ALIAS], [ |
| 507 |
m4_define([suffix], $1) |
| 508 |
m4_define([mastersuffix], $2) |
| 509 |
|
| 510 |
enable_[]suffix=$enable_[]mastersuffix |
| 511 |
]) |
| 512 |
|
| 513 |
|
| 514 |
dnl UL_NCURSES_CHECK(NAME) |
| 515 |
dnl |
| 516 |
dnl Initializes $have_<name>, NCURSES_LIBS and NCURSES_CFLAGS variables according to |
| 517 |
dnl <name>{6,5}_config output. |
| 518 |
dnl |
| 519 |
dnl The expected <name> is ncurses or ncursesw. |
| 520 |
dnl |
| 521 |
AC_DEFUN([UL_NCURSES_CHECK], [ |
| 522 |
m4_define([suffix], $1) |
| 523 |
m4_define([SUFFIX], m4_toupper($1)) |
| 524 |
|
| 525 |
# ncurses6-config |
| 526 |
# |
| 527 |
AS_IF([test "x$have_[]suffix" = xno], [ |
| 528 |
AC_CHECK_TOOL(SUFFIX[]6_CONFIG, suffix[]6-config) |
| 529 |
if AC_RUN_LOG([$SUFFIX[]6_CONFIG --version >/dev/null]); then |
| 530 |
have_[]suffix=yes |
| 531 |
NCURSES_LIBS=`$SUFFIX[]6_CONFIG --libs` |
| 532 |
NCURSES_CFLAGS=`$SUFFIX[]6_CONFIG --cflags` |
| 533 |
else |
| 534 |
have_[]suffix=no |
| 535 |
fi |
| 536 |
]) |
| 537 |
|
| 538 |
# ncurses5-config |
| 539 |
# |
| 540 |
AS_IF([test "x$have_[]suffix" = xno], [ |
| 541 |
AC_CHECK_TOOL(SUFFIX[]5_CONFIG, suffix[]5-config) |
| 542 |
if AC_RUN_LOG([$SUFFIX[]5_CONFIG --version >/dev/null]); then |
| 543 |
have_[]suffix=yes |
| 544 |
NCURSES_LIBS=`$SUFFIX[]5_CONFIG --libs` |
| 545 |
NCURSES_CFLAGS=`$SUFFIX[]5_CONFIG --cflags` |
| 546 |
else |
| 547 |
have_[]suffix=no |
| 548 |
fi |
| 549 |
]) |
| 550 |
|
| 551 |
# pkg-config (not supported by ncurses upstream by default) |
| 552 |
# |
| 553 |
AS_IF([test "x$have_[]suffix" = xno], [ |
| 554 |
PKG_CHECK_MODULES(SUFFIX, [$1], [ |
| 555 |
have_[]suffix=yes |
| 556 |
NCURSES_LIBS=${SUFFIX[]_LIBS} |
| 557 |
NCURSES_CFLAGS=${SUFFIX[]_CFLAGS} |
| 558 |
],[have_[]suffix=no]) |
| 559 |
]) |
| 560 |
|
| 561 |
# classic autoconf way |
| 562 |
# |
| 563 |
AS_IF([test "x$have_[]suffix" = xno], [ |
| 564 |
AC_CHECK_LIB([$1], [initscr], [have_[]suffix=yes], [have_[]suffix=no]) |
| 565 |
AS_IF([test "x$have_[]suffix" = xyes], [NCURSES_LIBS="-l[]suffix"]) |
| 566 |
]) |
| 567 |
]) |
| 568 |
|
| 569 |
dnl |
| 570 |
dnl UL_TINFO_CHECK(NAME) |
| 571 |
dnl |
| 572 |
dnl Initializes $have_<name>, TINFO_LIBS and TINFO_CFLAGS variables. |
| 573 |
dnl |
| 574 |
dnl The expected <name> is tinfow or tinfo. |
| 575 |
dnl |
| 576 |
AC_DEFUN([UL_TINFO_CHECK], [ |
| 577 |
m4_define([suffix], $1) |
| 578 |
m4_define([SUFFIX], m4_toupper($1)) |
| 579 |
|
| 580 |
PKG_CHECK_MODULES(SUFFIX, [$1], [ |
| 581 |
dnl pkg-config success |
| 582 |
have_[]suffix=yes |
| 583 |
TINFO_LIBS=${SUFFIX[]_LIBS} |
| 584 |
TINFO_CFLAGS=${SUFFIX[]_CFLAGS} |
| 585 |
UL_PKG_STATIC([TINFO_LIBS_STATIC], [$1]) |
| 586 |
],[ |
| 587 |
dnl If pkg-config failed, fall back to classic searching. |
| 588 |
AC_CHECK_LIB([$1], [tgetent], [ |
| 589 |
have_[]suffix=yes |
| 590 |
TINFO_LIBS="-l[]suffix" |
| 591 |
TINFO_LIBS_STATIC="-l[]suffix" |
| 592 |
TINFO_CFLAGS=""]) |
| 593 |
]) |
| 594 |
]) |