]> git.ipfire.org Git - thirdparty/util-linux.git/blame - m4/ul.m4
Merge branch 'PR/libsmartcols-reduce-fix' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / m4 / ul.m4
CommitLineData
a8afc8c6
KK
1dnl If needed, define the m4_ifblank and m4_ifnblank macros from autoconf 2.64
2dnl This allows us to run with earlier Autoconfs as well.
3dnl
4dnl m4_ifblank(COND, [IF-BLANK], [IF-TEXT])
5dnl m4_ifnblank(COND, [IF-TEXT], [IF-BLANK])
6dnl ----------------------------------------
7dnl If COND is empty, or consists only of blanks (space, tab, newline),
8dnl then expand IF-BLANK, otherwise expand IF-TEXT. This differs from
9dnl m4_ifval only if COND has just whitespace, but it helps optimize in
10dnl spite of users who mistakenly leave trailing space after what they
11dnl thought was an empty argument:
12dnl macro(
13dnl []
14dnl )
15dnl
16dnl Writing one macro in terms of the other causes extra overhead, so
17dnl we inline both definitions.
18ifdef([m4_ifblank],[],[
19m4_define([m4_ifblank],
20[m4_if(m4_translit([[$1]], [ ][ ][
21]), [], [$2], [$3])])])
22
23ifdef([m4_ifnblank],[],[
24m4_define([m4_ifnblank],
25[m4_if(m4_translit([[$1]], [ ][ ][
26]), [], [$3], [$2])])])
132ea941
KZ
27
28dnl UL_PKG_STATIC(VARIABLE, MODULES)
29dnl
30dnl Calls pkg-config --static
31dnl
32AC_DEFUN([UL_PKG_STATIC], [
08b35072
KZ
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
132ea941
KZ
39 fi
40])
41
42dnl UL_CHECK_LIB(LIBRARY, FUNCTION, [VARSUFFIX = $1]))
43dnl
ee312c65 44dnl The VARSUFFIX is optional and overrides the default behavior. For example:
132ea941
KZ
45dnl UL_CHECK_LIB(yyy, func, xxx) generates have_xxx and HAVE_LIBXXX
46dnl UL_CHECK_LIB(yyy, func) generates have_yyy and HAVE_LIBYYY
47dnl
48AC_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
58dnl UL_SET_ARCH(ARCHNAME, PATTERN)
59dnl
60dnl Define ARCH_<archname> condition if the pattern match with the current
61dnl architecture
62dnl
63AC_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
75cba8d5 72dnl UL_SET_LIBS(LIBS)
132ea941 73dnl
75cba8d5 74dnl Sets new global LIBS, the original setting could be restored by UL_RESTORE_LIBS()
132ea941 75dnl
75cba8d5
KZ
76AC_DEFUN([UL_SET_LIBS], [
77 old_LIBS="$LIBS"
78 LIBS="$LIBS $1"
132ea941
KZ
79])
80
75cba8d5 81dnl UL_RESTORE_LIBS()
132ea941 82dnl
75cba8d5 83dnl Restores LIBS previously saved by UL_SET_LIBS()
132ea941 84dnl
75cba8d5
KZ
85AC_DEFUN([UL_RESTORE_LIBS], [
86 LIBS="$old_LIBS"
132ea941
KZ
87])
88
89
90dnl UL_CHECK_SYSCALL(SYSCALL, FALLBACK, ...)
91dnl
92dnl Only specify FALLBACK if the SYSCALL you're checking for is a "newish" one
93dnl
94AC_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 ...
ca27517a
SK
103 _UL_SYSCALL_CHECK_DECL([__NR_$1],
104 [syscall=__NR_$1],
132ea941
KZ
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 ])
132ea941
KZ
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
125dnl _UL_SYSCALL_CHECK_DECL(SYMBOL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
126dnl
127dnl Check if SYMBOL is declared, using the headers needed for syscall checks.
128dnl
129m4_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
137dnl _UL_CHECK_SYSCALL_FALLBACK(PATTERN, VALUE, ...)
138dnl
139dnl Helper macro to create the body for the above `case'.
140dnl
141m4_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])
b17e8206
KZ
147
148
149dnl UL_REQUIRES_LINUX(NAME, [VARSUFFIX = $1])
150dnl
151dnl Modifies $build_<name> variable according to $enable_<name> and OS type. The
152dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then
218b1dd6 153dnl all checks are skipped.
b17e8206
KZ
154dnl
155dnl The default <name> for $build_ and $enable_ could be overwrited by option $2.
156dnl
157AC_DEFUN([UL_REQUIRES_LINUX], [
b17e8206 158 m4_define([suffix], m4_default([$2],$1))
61a074f7
KZ
159 if test "x$[build_]suffix" != xno; then
160 AC_REQUIRE([AC_CANONICAL_HOST])
b17e8206
KZ
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:*)
bdef457d 171 AC_MSG_WARN([non-linux system; not building $1])
b17e8206
KZ
172 [build_]suffix=no ;;
173 esac
174 fi
175])
176
62b2c024 177
cce05a2a 178dnl UL_EXCLUDE_ARCH(NAME, ARCH, [VARSUFFIX = $1])
62b2c024
KZ
179dnl
180dnl Modifies $build_<name> variable according to $enable_<name> and $host. The
181dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then
218b1dd6 182dnl all checks are skipped.
62b2c024
KZ
183dnl
184dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
185dnl
186AC_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)
bdef457d 198 AC_MSG_WARN([excluded for $host architecture; not building $1])
62b2c024
KZ
199 [build_]suffix=no ;;
200 check:*)
201 [build_]suffix=yes ;;
202 esac
203 fi
204])
205
c7eca69d
KZ
206
207
208dnl UL_REQUIRES_ARCH(NAME, ARCH, [VARSUFFIX = $1])
209dnl
210dnl Modifies $build_<name> variable according to $enable_<name> and $host. The
211dnl $enable_<name> could be "yes", "no" and "check". If build_<name> is "no" then
218b1dd6 212dnl all checks are skipped.
c7eca69d
KZ
213dnl
214dnl The <arch> maybe a list, then at least one of the patterns in the list
215dnl have to match.
216dnl
217dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
218dnl
219AC_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
cce05a2a 246dnl UL_REQUIRES_HAVE(NAME, HAVENAME, HAVEDESC, [VARSUFFIX=$1])
b17e8206
KZ
247dnl
248dnl Modifies $build_<name> variable according to $enable_<name> and
cce05a2a 249dnl $have_<havename>. The <havedesc> is description used for warning/error
b17e8206
KZ
250dnl message (e.g. "function").
251dnl
91626822
KZ
252dnl The <havename> maybe a list, then at least one of the items in the list
253dnl have to exist, for example: [ncurses, tinfo] means that have_ncurser=yes
254dnl *or* have_tinfo=yes must be defined.
255dnl
cce05a2a 256dnl The default <name> for $build_ and $enable_ could be overwrited by option $4.
b17e8206
KZ
257dnl
258AC_DEFUN([UL_REQUIRES_HAVE], [
259 m4_define([suffix], m4_default([$4],$1))
260
61a074f7 261 if test "x$[build_]suffix" != xno; then
91626822 262
e1b8ba20 263 [ul_haveone_]suffix=no
91626822
KZ
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 #(
b17e8206
KZ
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:*)
bdef457d 280 AC_MSG_WARN([$3 not found; not building $1])
b17e8206
KZ
281 [build_]suffix=no ;;
282 esac
283 fi
284])
285
c7eca69d 286dnl UL_REQUIRES_COMPILE(NAME, PROGRAM_PROLOGUE, PROGRAM_BODY, DESC, [VARSUFFIX=$1])
2bd0b84f
KZ
287dnl
288dnl Modifies $build_<name> variable according to $enable_<name> and
2bb3aa36 289dnl ability compile AC_LANG_PROGRAM(<program_prologue>, <program_body>).
2bd0b84f
KZ
290dnl
291dnl The <desc> is description used for warning/error dnl message (e.g. "foo support").
292dnl
293dnl The default <name> for $build_ and $enable_ could be overwrited by option $5.
294
295AC_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
22a900a9
KZ
323
324dnl UL_REQUIRES_PROGRAM(NAME, PROGVAR, PROGRAM, DESC, [VARSUFFIX=$1])
325dnl
326dnl Modifies $build_<name> variable according to $enable_<name> and
327dnl ability compile AC_PATH_PROG().
328dnl
329dnl The <desc> is description used for warning/error dnl message (e.g. "foo support").
330dnl
331dnl The default <name> for $build_ and $enable_ could be overwrited by option $5.
332AC_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
a9e48470 355dnl
cce05a2a 356dnl UL_CONFLICTS_BUILD(NAME, ANOTHER, ANOTHERDESC, [VARSUFFIX=$1])
a9e48470
KZ
357dnl
358dnl - ends with error if $enable_<name> and $build_<another>
359dnl are both set to 'yes'
360dnl - sets $build_<name> to 'no' if $build_<another> is 'yes' and
361dnl $enable_<name> is 'check' or 'no'
362dnl
363dnl The <havedesc> is description used for warning/error
364dnl message (e.g. "function").
365dnl
cce05a2a 366dnl The default <name> for $build_ and $enable_ could be overwrited by option $4.
a9e48470
KZ
367dnl
368AC_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 ;;
ad869f9e
KZ
377 check:no)
378 [build_]suffix=yes ;;
a9e48470
KZ
379 yes:yes)
380 AC_MSG_ERROR([$1 selected, but it conflicts with $3]);;
381 esac
382 fi
383])
384
385
b17e8206
KZ
386dnl UL_REQUIRES_BUILD(NAME, BUILDNAME, [VARSUFFIX=$1])
387dnl
388dnl Modifies $build_<name> variable according to $enable_<name> and $have_funcname.
389dnl
390dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
391dnl
392AC_DEFUN([UL_REQUIRES_BUILD], [
393 m4_define([suffix], m4_default([$3],$1))
394
61a074f7 395 if test "x$[build_]suffix" != xno; then
b17e8206
KZ
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:*)
bdef457d 406 AC_MSG_WARN([$2 disabled; not building $1])
b17e8206
KZ
407 [build_]suffix=no ;;
408 esac
409 fi
410])
411
412dnl UL_REQUIRES_SYSCALL_CHECK(NAME, SYSCALL-TEST, [SYSCALLNAME=$1], [VARSUFFIX=$1])
413dnl
414dnl Modifies $build_<name> variable according to $enable_<name> and SYSCALL-TEST
415dnl result. The $enable_<name> variable could be "yes", "no" and "check". If build_<name>
218b1dd6 416dnl is "no" then all checks are skipped.
b17e8206
KZ
417dnl
418dnl Note that SYSCALL-TEST has to define $ul_cv_syscall_<name> variable, see
419dnl also UL_CHECK_SYSCALL().
420dnl
421dnl The default <name> for $build_ and $enable_ count be overwrited by option $4 and
422dnl $ul_cv_syscall_ could be overwrited by $3.
423dnl
424AC_DEFUN([UL_REQUIRES_SYSCALL_CHECK], [
425 m4_define([suffix], m4_default([$4],$1))
426 m4_define([callname], m4_default([$3],$1))
427
61a074f7 428 if test "x$[build_]suffix" != xno; then
b17e8206
KZ
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)
bdef457d 439 AC_MSG_WARN([callname syscall not found; not building $1])
b17e8206
KZ
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])
61a074f7 448
3d9fdac5 449dnl UL_BUILD_INIT(NAME, [ENABLE_STATE], [VARSUFFIX = $1])
61a074f7
KZ
450dnl
451dnl Initializes $build_<name> variable according to $enable_<name>. If
452dnl $enable_<name> is undefined then ENABLE_STATE is used and $enable_<name> is
453dnl set to ENABLE_STATE.
454dnl
cce05a2a 455dnl The default <name> for $build_ and $enable_ could be overwrited by option $3.
61a074f7
KZ
456dnl
457AC_DEFUN([UL_BUILD_INIT], [
458 m4_define([suffix], m4_default([$3],$1))
50d096ac 459 m4_ifblank([$2],
b248c9d4
KZ
460[if test "x$enable_[]suffix" = xno; then
461 build_[]suffix=no
462else
463 build_[]suffix=yes
464fi],
465[if test "x$ul_default_estate" != x; then
50d096ac 466 enable_[]suffix=$ul_default_estate
1ad36b52 467 build_[]suffix=yes
56ce2d58
KZ
468 if test "x$ul_default_estate" = xno; then
469 build_[]suffix=no
470 fi
50d096ac
KZ
471else[]
472 ifelse(
473 [$2], [check],[
b248c9d4
KZ
474 build_[]suffix=yes
475 enable_[]suffix=check],
50d096ac 476 [$2], [yes],[
b248c9d4
KZ
477 build_[]suffix=yes
478 enable_[]suffix=yes],
50d096ac 479 [$2], [no], [
b248c9d4
KZ
480 build_[]suffix=no
481 enable_[]suffix=no])
50d096ac
KZ
482fi])
483])
61a074f7 484
50d096ac
KZ
485dnl UL_DEFAULT_ENABLE(NAME, ENABLE_STATE)
486dnl
487dnl Initializes $enable_<name> variable according to ENABLE_STATE. The default
488dnl setting is possible to override by global $ul_default_estate.
489dnl
490AC_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
61a074f7 497])
e5cc93b5 498
6f2eb034
KZ
499
500dnl UL_ENABLE_ALIAS(NAME, MASTERNAME)
501dnl
fc72f51e 502dnl Initializes $enable_<name> variable according to $enable_<mastername>. This
73afd3f8 503dnl is useful for example if you want to use one --enable-mastername option
6f2eb034
KZ
504dnl for group of programs.
505dnl
506AC_DEFUN([UL_ENABLE_ALIAS], [
507 m4_define([suffix], $1)
508 m4_define([mastersuffix], $2)
509
fc72f51e 510 enable_[]suffix=$enable_[]mastersuffix
6f2eb034
KZ
511])
512
513
e5cc93b5
KZ
514dnl UL_NCURSES_CHECK(NAME)
515dnl
516dnl Initializes $have_<name>, NCURSES_LIBS and NCURSES_CFLAGS variables according to
517dnl <name>{6,5}_config output.
518dnl
519dnl The expected <name> is ncurses or ncursesw.
520dnl
521AC_DEFUN([UL_NCURSES_CHECK], [
522 m4_define([suffix], $1)
86232645 523 m4_define([SUFFIX], m4_toupper($1))
3f7429fd 524
86232645 525 # ncurses6-config
e5cc93b5 526 #
3f7429fd 527 AS_IF([test "x$have_[]suffix" = xno], [
86232645
KZ
528 AC_CHECK_TOOL(SUFFIX[]6_CONFIG, suffix[]6-config)
529 if AC_RUN_LOG([$SUFFIX[]6_CONFIG --version >/dev/null]); then
3f7429fd 530 have_[]suffix=yes
86232645
KZ
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
3f7429fd 543 have_[]suffix=yes
86232645
KZ
544 NCURSES_LIBS=`$SUFFIX[]5_CONFIG --libs`
545 NCURSES_CFLAGS=`$SUFFIX[]5_CONFIG --cflags`
3f7429fd 546 else
86232645 547 have_[]suffix=no
3f7429fd
KZ
548 fi
549 ])
86232645 550
4c12a334
KZ
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
86232645
KZ
561 # classic autoconf way
562 #
563 AS_IF([test "x$have_[]suffix" = xno], [
4c12a334
KZ
564 AC_CHECK_LIB([$1], [initscr], [have_[]suffix=yes], [have_[]suffix=no])
565 AS_IF([test "x$have_[]suffix" = xyes], [NCURSES_LIBS="-l[]suffix"])
86232645 566 ])
e5cc93b5 567])
ad442a81
KZ
568
569dnl
570dnl UL_TINFO_CHECK(NAME)
571dnl
572dnl Initializes $have_<name>, TINFO_LIBS and TINFO_CFLAGS variables.
573dnl
574dnl The expected <name> is tinfow or tinfo.
575dnl
576AC_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])