]> The Tcpdump Group git mirrors - libpcap/blob - aclocal.m4
Fix building without protochain support. (GH #852)
[libpcap] / aclocal.m4
1 dnl Copyright (c) 1995, 1996, 1997, 1998
2 dnl The Regents of the University of California. All rights reserved.
3 dnl
4 dnl Redistribution and use in source and binary forms, with or without
5 dnl modification, are permitted provided that: (1) source code distributions
6 dnl retain the above copyright notice and this paragraph in its entirety, (2)
7 dnl distributions including binary code include the above copyright notice and
8 dnl this paragraph in its entirety in the documentation or other materials
9 dnl provided with the distribution, and (3) all advertising materials mentioning
10 dnl features or use of this software display the following acknowledgement:
11 dnl ``This product includes software developed by the University of California,
12 dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 dnl the University nor the names of its contributors may be used to endorse
14 dnl or promote products derived from this software without specific prior
15 dnl written permission.
16 dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 dnl
20 dnl LBL autoconf macros
21 dnl
22
23 dnl
24 dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
25 dnl
26 dnl It appears that newer versions of autoconf (2.64 and later) will,
27 dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
28 dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
29 dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
30 dnl in the Autoconf documentation.
31 dnl
32 dnl This causes a steaming heap of fail in our case, as we were, in
33 dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
34 dnl calling AC_PROG_CC, and then doing the tests we now do in
35 dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
36 dnl and AC_LBL_C_INIT at the top level.
37 dnl
38 AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
39 [
40 AC_BEFORE([$0], [AC_LBL_C_INIT])
41 AC_BEFORE([$0], [AC_PROG_CC])
42 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
43 AC_BEFORE([$0], [AC_LBL_DEVEL])
44 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
45 $1=""
46 if test "${srcdir}" != "." ; then
47 $1="-I\$(srcdir)"
48 fi
49 if test "${CFLAGS+set}" = set; then
50 LBL_CFLAGS="$CFLAGS"
51 fi
52 if test -z "$CC" ; then
53 case "$host_os" in
54
55 bsdi*)
56 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
57 if test $SHLICC2 = yes ; then
58 CC=shlicc2
59 export CC
60 fi
61 ;;
62 esac
63 fi
64 if test -z "$CC" -a "$with_gcc" = no ; then
65 CC=cc
66 export CC
67 fi
68 ])
69
70 dnl
71 dnl Determine which compiler we're using (cc or gcc)
72 dnl If using gcc, determine the version number
73 dnl If using cc:
74 dnl require that it support ansi prototypes
75 dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
76 dnl do that ourselves for gcc)
77 dnl add -g flags, as appropriate
78 dnl explicitly specify /usr/local/include
79 dnl
80 dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
81 dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
82 dnl
83 dnl usage:
84 dnl
85 dnl AC_LBL_C_INIT(copt, incls)
86 dnl
87 dnl results:
88 dnl
89 dnl $1 (copt set)
90 dnl $2 (incls set)
91 dnl CC
92 dnl LDFLAGS
93 dnl LBL_CFLAGS
94 dnl
95 AC_DEFUN(AC_LBL_C_INIT,
96 [
97 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
98 AC_BEFORE([$0], [AC_LBL_DEVEL])
99 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
100 if test "$GCC" = yes ; then
101 #
102 # -Werror forces warnings to be errors.
103 #
104 ac_lbl_cc_force_warning_errors=-Werror
105
106 #
107 # Try to have the compiler default to hiding symbols,
108 # so that only symbols explicitly exported with
109 # PCAP_API will be visible outside (shared) libraries.
110 #
111 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
112 else
113 $2="$$2 -I/usr/local/include"
114 LDFLAGS="$LDFLAGS -L/usr/local/lib"
115
116 case "$host_os" in
117
118 darwin*)
119 #
120 # This is assumed either to be GCC or clang, both
121 # of which use -Werror to force warnings to be errors.
122 #
123 ac_lbl_cc_force_warning_errors=-Werror
124
125 #
126 # Try to have the compiler default to hiding symbols,
127 # so that only symbols explicitly exported with
128 # PCAP_API will be visible outside (shared) libraries.
129 #
130 AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
131 ;;
132
133 hpux*)
134 #
135 # HP C, which is what we presume we're using, doesn't
136 # exit with a non-zero exit status if we hand it an
137 # invalid -W flag, can't be forced to do so even with
138 # +We, and doesn't handle GCC-style -W flags, so we
139 # don't want to try using GCC-style -W flags.
140 #
141 ac_lbl_cc_dont_try_gcc_dashW=yes
142 ;;
143
144 irix*)
145 #
146 # MIPS C, which is what we presume we're using, doesn't
147 # necessarily exit with a non-zero exit status if we
148 # hand it an invalid -W flag, can't be forced to do
149 # so, and doesn't handle GCC-style -W flags, so we
150 # don't want to try using GCC-style -W flags.
151 #
152 ac_lbl_cc_dont_try_gcc_dashW=yes
153 #
154 # It also, apparently, defaults to "char" being
155 # unsigned, unlike most other C implementations;
156 # I suppose we could say "signed char" whenever
157 # we want to guarantee a signed "char", but let's
158 # just force signed chars.
159 #
160 # -xansi is normally the default, but the
161 # configure script was setting it; perhaps -cckr
162 # was the default in the Old Days. (Then again,
163 # that would probably be for backwards compatibility
164 # in the days when ANSI C was Shiny and New, i.e.
165 # 1989 and the early '90's, so maybe we can just
166 # drop support for those compilers.)
167 #
168 # -g is equivalent to -g2, which turns off
169 # optimization; we choose -g3, which generates
170 # debugging information but doesn't turn off
171 # optimization (even if the optimization would
172 # cause inaccuracies in debugging).
173 #
174 $1="$$1 -xansi -signed -g3"
175 ;;
176
177 osf*)
178 #
179 # Presumed to be DEC OSF/1, Digital UNIX, or
180 # Tru64 UNIX.
181 #
182 # The DEC C compiler, which is what we presume we're
183 # using, doesn't exit with a non-zero exit status if we
184 # hand it an invalid -W flag, can't be forced to do
185 # so, and doesn't handle GCC-style -W flags, so we
186 # don't want to try using GCC-style -W flags.
187 #
188 ac_lbl_cc_dont_try_gcc_dashW=yes
189 #
190 # -g is equivalent to -g2, which turns off
191 # optimization; we choose -g3, which generates
192 # debugging information but doesn't turn off
193 # optimization (even if the optimization would
194 # cause inaccuracies in debugging).
195 #
196 $1="$$1 -g3"
197 ;;
198
199 solaris*)
200 #
201 # Assumed to be Sun C, which requires -errwarn to force
202 # warnings to be treated as errors.
203 #
204 ac_lbl_cc_force_warning_errors=-errwarn
205
206 #
207 # Try to have the compiler default to hiding symbols,
208 # so that only symbols explicitly exported with
209 # PCAP_API will be visible outside (shared) libraries.
210 #
211 AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
212 ;;
213
214 ultrix*)
215 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
216 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
217 AC_TRY_COMPILE(
218 [#include <sys/types.h>],
219 [struct a { int b; };
220 void c(const struct a *)],
221 ac_cv_lbl_cc_const_proto=yes,
222 ac_cv_lbl_cc_const_proto=no))
223 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
224 if test $ac_cv_lbl_cc_const_proto = no ; then
225 AC_DEFINE(const,[],
226 [to handle Ultrix compilers that don't support const in prototypes])
227 fi
228 ;;
229 esac
230 $1="$$1 -O"
231 fi
232 ])
233
234 dnl
235 dnl Check whether the compiler option specified as the second argument
236 dnl is supported by the compiler and, if so, add it to the macro
237 dnl specified as the first argument
238 dnl
239 dnl If a third argument is supplied, treat it as C code to be compiled
240 dnl with the flag in question, and the "treat warnings as errors" flag
241 dnl set, and don't add the flag to the first argument if the compile
242 dnl fails; this is for warning options cause problems that can't be
243 dnl worked around. If a third argument is supplied, a fourth argument
244 dnl should also be supplied; it's a message describing what the test
245 dnl program is checking.
246 dnl
247 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
248 [
249 AC_MSG_CHECKING([whether the compiler supports the $2 option])
250 save_CFLAGS="$CFLAGS"
251 CFLAGS="$CFLAGS $2"
252 #
253 # XXX - yes, this depends on the way AC_LANG_WERROR works,
254 # but no mechanism is provided to turn AC_LANG_WERROR on
255 # *and then turn it back off*, so that we *only* do it when
256 # testing compiler options - 15 years after somebody asked
257 # for it:
258 #
259 # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
260 #
261 save_ac_c_werror_flag="$ac_c_werror_flag"
262 ac_c_werror_flag=yes
263 #
264 # We use AC_LANG_SOURCE() so that we can control the complete
265 # content of the program being compiled. We do not, for example,
266 # want the default "int main()" that AC_LANG_PROGRAM() generates,
267 # as it will generate a warning with -Wold-style-definition, meaning
268 # that we would treat it as not working, as the test will fail if
269 # *any* error output, including a warning due to the flag we're
270 # testing, is generated; see
271 #
272 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
273 # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
274 #
275 # This may, as per those two messages, be fixed in autoonf 2.70,
276 # but we only require 2.64 or newer for now.
277 #
278 AC_COMPILE_IFELSE(
279 [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
280 [
281 AC_MSG_RESULT([yes])
282 can_add_to_cflags=yes
283 #
284 # The compile supports this; do we have some C code for
285 # which the warning should *not* appear?
286 # We test the fourth argument because the third argument
287 # could contain quotes, breaking the test.
288 #
289 if test "x$4" != "x"
290 then
291 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
292 AC_MSG_CHECKING(whether $2 $4)
293 AC_COMPILE_IFELSE(
294 [AC_LANG_SOURCE($3)],
295 [
296 #
297 # Not a problem.
298 #
299 AC_MSG_RESULT(no)
300 ],
301 [
302 #
303 # A problem.
304 #
305 AC_MSG_RESULT(yes)
306 can_add_to_cflags=no
307 ])
308 fi
309 CFLAGS="$save_CFLAGS"
310 if test x"$can_add_to_cflags" = "xyes"
311 then
312 $1="$$1 $2"
313 fi
314 ],
315 [
316 AC_MSG_RESULT([no])
317 CFLAGS="$save_CFLAGS"
318 ])
319 ac_c_werror_flag="$save_ac_c_werror_flag"
320 ])
321
322 dnl
323 dnl Check whether the compiler supports an option to generate
324 dnl Makefile-style dependency lines
325 dnl
326 dnl GCC uses -M for this. Non-GCC compilers that support this
327 dnl use a variety of flags, including but not limited to -M.
328 dnl
329 dnl We test whether the flag in question is supported, as older
330 dnl versions of compilers might not support it.
331 dnl
332 dnl We don't try all the possible flags, just in case some flag means
333 dnl "generate dependencies" on one compiler but means something else
334 dnl on another compiler.
335 dnl
336 dnl Most compilers that support this send the output to the standard
337 dnl output by default. IBM's XLC, however, supports -M but sends
338 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
339 dnl to work around that, so we don't bother with XLC.
340 dnl
341 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
342 [
343 AC_MSG_CHECKING([whether the compiler supports generating dependencies])
344 if test "$GCC" = yes ; then
345 #
346 # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
347 # though it's not); we assume that, in this case, the flag
348 # would be -M.
349 #
350 ac_lbl_dependency_flag="-M"
351 else
352 #
353 # Not GCC or a compiler deemed to be GCC; what platform is
354 # this? (We're assuming that if the compiler isn't GCC
355 # it's the compiler from the vendor of the OS; that won't
356 # necessarily be true for x86 platforms, where it might be
357 # the Intel C compiler.)
358 #
359 case "$host_os" in
360
361 irix*|osf*|darwin*)
362 #
363 # MIPS C for IRIX, DEC C, and clang all use -M.
364 #
365 ac_lbl_dependency_flag="-M"
366 ;;
367
368 solaris*)
369 #
370 # Sun C uses -xM.
371 #
372 ac_lbl_dependency_flag="-xM"
373 ;;
374
375 hpux*)
376 #
377 # HP's older C compilers don't support this.
378 # HP's newer C compilers support this with
379 # either +M or +Make; the older compilers
380 # interpret +M as something completely
381 # different, so we use +Make so we don't
382 # think it works with the older compilers.
383 #
384 ac_lbl_dependency_flag="+Make"
385 ;;
386
387 *)
388 #
389 # Not one of the above; assume no support for
390 # generating dependencies.
391 #
392 ac_lbl_dependency_flag=""
393 ;;
394 esac
395 fi
396
397 #
398 # Is ac_lbl_dependency_flag defined and, if so, does the compiler
399 # complain about it?
400 #
401 # Note: clang doesn't seem to exit with an error status when handed
402 # an unknown non-warning error, even if you pass it
403 # -Werror=unknown-warning-option. However, it always supports
404 # -M, so the fact that this test always succeeds with clang
405 # isn't an issue.
406 #
407 if test ! -z "$ac_lbl_dependency_flag"; then
408 AC_LANG_CONFTEST(
409 [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
410 if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
411 AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
412 DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
413 MKDEP='${top_srcdir}/mkdep'
414 else
415 AC_MSG_RESULT([no])
416 #
417 # We can't run mkdep, so have "make depend" do
418 # nothing.
419 #
420 MKDEP='${top_srcdir}/nomkdep'
421 fi
422 rm -rf conftest*
423 else
424 AC_MSG_RESULT([no])
425 #
426 # We can't run mkdep, so have "make depend" do
427 # nothing.
428 #
429 MKDEP='${top_srcdir}/nomkdep'
430 fi
431 AC_SUBST(DEPENDENCY_CFLAG)
432 AC_SUBST(MKDEP)
433 ])
434
435 dnl
436 dnl Determine what options are needed to build a shared library
437 dnl
438 dnl usage:
439 dnl
440 dnl AC_LBL_SHLIBS_INIT
441 dnl
442 dnl results:
443 dnl
444 dnl V_SHLIB_CCOPT (modified to build position-independent code)
445 dnl V_SHLIB_CMD
446 dnl V_SHLIB_OPT
447 dnl V_SONAME_OPT
448 dnl V_RPATH_OPT
449 dnl
450 AC_DEFUN(AC_LBL_SHLIBS_INIT,
451 [AC_PREREQ(2.50)
452 if test "$GCC" = yes ; then
453 #
454 # On platforms where we build a shared library:
455 #
456 # add options to generate position-independent code,
457 # if necessary (it's the default in AIX and Darwin/macOS);
458 #
459 # define option to set the soname of the shared library,
460 # if the OS supports that;
461 #
462 # add options to specify, at link time, a directory to
463 # add to the run-time search path, if that's necessary.
464 #
465 V_SHLIB_CMD="\$(CC)"
466 V_SHLIB_OPT="-shared"
467 case "$host_os" in
468
469 aix*)
470 ;;
471
472 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*)
473 #
474 # Platforms where the linker is the GNU linker
475 # or accepts command-line arguments like
476 # those the GNU linker accepts.
477 #
478 # Some instruction sets require -fPIC on some
479 # operating systems. Check for them. If you
480 # have a combination that requires it, add it
481 # here.
482 #
483 PIC_OPT=-fpic
484 case "$host_cpu" in
485
486 sparc64*)
487 case "$host_os" in
488
489 freebsd*|openbsd*|linux*)
490 PIC_OPT=-fPIC
491 ;;
492 esac
493 ;;
494 esac
495 V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
496 V_SONAME_OPT="-Wl,-soname,"
497 V_RPATH_OPT="-Wl,-rpath,"
498 ;;
499
500 hpux*)
501 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
502 #
503 # XXX - this assumes GCC is using the HP linker,
504 # rather than the GNU linker, and that the "+h"
505 # option is used on all HP-UX platforms, both .sl
506 # and .so.
507 #
508 V_SONAME_OPT="-Wl,+h,"
509 #
510 # By default, directories specified with -L
511 # are added to the run-time search path, so
512 # we don't add them in pcap-config.
513 #
514 ;;
515
516 solaris*)
517 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
518 #
519 # XXX - this assumes GCC is using the Sun linker,
520 # rather than the GNU linker.
521 #
522 V_SONAME_OPT="-Wl,-h,"
523 V_RPATH_OPT="-Wl,-R,"
524 ;;
525 esac
526 else
527 #
528 # Set the appropriate compiler flags and, on platforms
529 # where we build a shared library:
530 #
531 # add options to generate position-independent code,
532 # if necessary (it's the default in Darwin/macOS);
533 #
534 # if we generate ".so" shared libraries, define the
535 # appropriate options for building the shared library;
536 #
537 # add options to specify, at link time, a directory to
538 # add to the run-time search path, if that's necessary.
539 #
540 # Note: spaces after V_SONAME_OPT are significant; on
541 # some platforms the soname is passed with a GCC-like
542 # "-Wl,-soname,{soname}" option, with the soname part
543 # of the option, while on other platforms the C compiler
544 # driver takes it as a regular option with the soname
545 # following the option. The same applies to V_RPATH_OPT.
546 #
547 case "$host_os" in
548
549 aix*)
550 V_SHLIB_CMD="\$(CC)"
551 V_SHLIB_OPT="-G -bnoentry -bexpall"
552 ;;
553
554 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
555 #
556 # "cc" is GCC.
557 #
558 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
559 V_SHLIB_CMD="\$(CC)"
560 V_SHLIB_OPT="-shared"
561 V_SONAME_OPT="-Wl,-soname,"
562 V_RPATH_OPT="-Wl,-rpath,"
563 ;;
564
565 hpux*)
566 V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z"
567 V_SHLIB_CMD="\$(LD)"
568 V_SHLIB_OPT="-b"
569 V_SONAME_OPT="+h "
570 #
571 # By default, directories specified with -L
572 # are added to the run-time search path, so
573 # we don't add them in pcap-config.
574 #
575 ;;
576
577 osf*)
578 #
579 # Presumed to be DEC OSF/1, Digital UNIX, or
580 # Tru64 UNIX.
581 #
582 V_SHLIB_CMD="\$(CC)"
583 V_SHLIB_OPT="-shared"
584 V_SONAME_OPT="-soname "
585 V_RPATH_OPT="-rpath "
586 ;;
587
588 solaris*)
589 V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
590 V_SHLIB_CMD="\$(CC)"
591 V_SHLIB_OPT="-G"
592 V_SONAME_OPT="-h "
593 V_RPATH_OPT="-R"
594 ;;
595 esac
596 fi
597 ])
598
599 #
600 # Try compiling a sample of the type of code that appears in
601 # gencode.c with "inline", "__inline__", and "__inline".
602 #
603 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
604 # as it just tests whether a function returning "int" can be inlined;
605 # at least some versions of HP's C compiler can inline that, but can't
606 # inline a function that returns a struct pointer.
607 #
608 # Make sure we use the V_CCOPT flags, because some of those might
609 # disable inlining.
610 #
611 AC_DEFUN(AC_LBL_C_INLINE,
612 [AC_MSG_CHECKING(for inline)
613 save_CFLAGS="$CFLAGS"
614 CFLAGS="$V_CCOPT"
615 AC_CACHE_VAL(ac_cv_lbl_inline, [
616 ac_cv_lbl_inline=""
617 ac_lbl_cc_inline=no
618 for ac_lbl_inline in inline __inline__ __inline
619 do
620 AC_TRY_COMPILE(
621 [#define inline $ac_lbl_inline
622 static inline struct iltest *foo(void);
623 struct iltest {
624 int iltest1;
625 int iltest2;
626 };
627
628 static inline struct iltest *
629 foo()
630 {
631 static struct iltest xxx;
632
633 return &xxx;
634 }],,ac_lbl_cc_inline=yes,)
635 if test "$ac_lbl_cc_inline" = yes ; then
636 break;
637 fi
638 done
639 if test "$ac_lbl_cc_inline" = yes ; then
640 ac_cv_lbl_inline=$ac_lbl_inline
641 fi])
642 CFLAGS="$save_CFLAGS"
643 if test ! -z "$ac_cv_lbl_inline" ; then
644 AC_MSG_RESULT($ac_cv_lbl_inline)
645 else
646 AC_MSG_RESULT(no)
647 fi
648 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
649
650 #
651 # Test whether we have __atomic_load_n() and __atomic_store_n().
652 #
653 # We use AC_TRY_LINK because AC_TRY_COMPILE will succeed, as the
654 # compiler will just think that those functions are undefined,
655 # and perhaps warn about that, but not fail to compile.
656 #
657 AC_DEFUN(AC_PCAP_C___ATOMICS,
658 [
659 AC_MSG_CHECKING(for __atomic_load_n)
660 AC_CACHE_VAL(ac_cv_have___atomic_load_n,
661 AC_TRY_LINK([],
662 [
663 int i = 17;
664 int j;
665 j = __atomic_load_n(&i, __ATOMIC_RELAXED);
666 ],
667 ac_have___atomic_load_n=yes,
668 ac_have___atomic_load_n=no))
669 AC_MSG_RESULT($ac_have___atomic_load_n)
670 if test $ac_have___atomic_load_n = yes ; then
671 AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1,
672 [define if __atomic_load_n is supported by the compiler])
673 fi
674
675 AC_MSG_CHECKING(for __atomic_store_n)
676 AC_CACHE_VAL(ac_cv_have___atomic_store_n,
677 AC_TRY_LINK([],
678 [
679 int i;
680 __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
681 ],
682 ac_have___atomic_store_n=yes,
683 ac_have___atomic_store_n=no))
684 AC_MSG_RESULT($ac_have___atomic_store_n)
685 if test $ac_have___atomic_store_n = yes ; then
686 AC_DEFINE(HAVE___ATOMIC_STORE_N, 1,
687 [define if __atomic_store_n is supported by the compiler])
688 fi])
689
690 dnl
691 dnl If using gcc, make sure we have ANSI ioctl definitions
692 dnl
693 dnl usage:
694 dnl
695 dnl AC_LBL_FIXINCLUDES
696 dnl
697 AC_DEFUN(AC_LBL_FIXINCLUDES,
698 [if test "$GCC" = yes ; then
699 AC_MSG_CHECKING(for ANSI ioctl definitions)
700 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
701 AC_TRY_COMPILE(
702 [/*
703 * This generates a "duplicate case value" when fixincludes
704 * has not be run.
705 */
706 # include <sys/types.h>
707 # include <sys/time.h>
708 # include <sys/ioctl.h>
709 # ifdef HAVE_SYS_IOCCOM_H
710 # include <sys/ioccom.h>
711 # endif],
712 [switch (0) {
713 case _IO('A', 1):;
714 case _IO('B', 1):;
715 }],
716 ac_cv_lbl_gcc_fixincludes=yes,
717 ac_cv_lbl_gcc_fixincludes=no))
718 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
719 if test $ac_cv_lbl_gcc_fixincludes = no ; then
720 # Don't cache failure
721 unset ac_cv_lbl_gcc_fixincludes
722 AC_MSG_ERROR(see the INSTALL for more info)
723 fi
724 fi])
725
726 dnl
727 dnl Checks to see if union wait is used with WEXITSTATUS()
728 dnl
729 dnl usage:
730 dnl
731 dnl AC_LBL_UNION_WAIT
732 dnl
733 dnl results:
734 dnl
735 dnl DECLWAITSTATUS (defined)
736 dnl
737 AC_DEFUN(AC_LBL_UNION_WAIT,
738 [AC_MSG_CHECKING(if union wait is used)
739 AC_CACHE_VAL(ac_cv_lbl_union_wait,
740 AC_TRY_COMPILE([
741 # include <sys/types.h>
742 # include <sys/wait.h>],
743 [int status;
744 u_int i = WEXITSTATUS(status);
745 u_int j = waitpid(0, &status, 0);],
746 ac_cv_lbl_union_wait=no,
747 ac_cv_lbl_union_wait=yes))
748 AC_MSG_RESULT($ac_cv_lbl_union_wait)
749 if test $ac_cv_lbl_union_wait = yes ; then
750 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
751 else
752 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
753 fi])
754
755 dnl
756 dnl Checks to see if -R is used
757 dnl
758 dnl usage:
759 dnl
760 dnl AC_LBL_HAVE_RUN_PATH
761 dnl
762 dnl results:
763 dnl
764 dnl ac_cv_lbl_have_run_path (yes or no)
765 dnl
766 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
767 [AC_MSG_CHECKING(for ${CC-cc} -R)
768 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
769 [echo 'main(){}' > conftest.c
770 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
771 if test ! -s conftest.out ; then
772 ac_cv_lbl_have_run_path=yes
773 else
774 ac_cv_lbl_have_run_path=no
775 fi
776 rm -f -r conftest*])
777 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
778 ])
779
780 dnl
781 dnl If the file .devel exists:
782 dnl Add some warning flags if the compiler supports them
783 dnl If an os prototype include exists, symlink os-proto.h to it
784 dnl
785 dnl usage:
786 dnl
787 dnl AC_LBL_DEVEL(copt)
788 dnl
789 dnl results:
790 dnl
791 dnl $1 (copt appended)
792 dnl HAVE_OS_PROTO_H (defined)
793 dnl os-proto.h (symlinked)
794 dnl
795 AC_DEFUN(AC_LBL_DEVEL,
796 [rm -f os-proto.h
797 if test "${LBL_CFLAGS+set}" = set; then
798 $1="$$1 ${LBL_CFLAGS}"
799 fi
800 if test -f .devel ; then
801 #
802 # Skip all the warning option stuff on some compilers.
803 #
804 if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
805 AC_LBL_CHECK_COMPILER_OPT($1, -W)
806 AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
807 AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
808 AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
809 AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
810 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
811 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
812 AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
813 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
814 AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign)
815 AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
816 AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
817 AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
818 AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
819 AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
820 # Warns about safeguards added in case the enums are
821 # extended
822 # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
823 #
824 # This can cause problems with ntohs(), ntohl(),
825 # htons(), and htonl() on some platforms, such
826 # as OpenBSD 6.3 with Clang 5.0.1. I guess the
827 # problem is that the macro that ultimately does
828 # the byte-swapping involves a conditional
829 # expression that tests whether the value being
830 # swapped is a compile-time constant or not,
831 # using __builtin_constant_p(), and, depending
832 # on whether it is, does a compile-time swap or
833 # a run-time swap; perhaps the compiler always
834 # considers one of the two results of the
835 # conditional expressin is never evaluated,
836 # because the conditional check is done at
837 # compile time, and thus always says "that
838 # expression is never executed".
839 #
840 # (Perhaps there should be a way of flagging
841 # an expression that you *want* evaluated at
842 # compile time, so that the compiler 1) warns
843 # if it *can't* be evaluated at compile time
844 # and 2) *doesn't* warn that the true or false
845 # branch will never be reached.)
846 #
847 AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code,
848 [
849 #include <arpa/inet.h>
850
851 unsigned short
852 testme(unsigned short a)
853 {
854 return ntohs(a);
855 }
856 ],
857 [generates warnings from ntohs()])
858 AC_LBL_CHECK_COMPILER_OPT($1, -Wshorten-64-to-32)
859 fi
860 AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
861 #
862 # We used to set -n32 for IRIX 6 when not using GCC (presumed
863 # to mean that we're using MIPS C or MIPSpro C); it specified
864 # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
865 # not sure why that would be something to do *only* with a
866 # .devel file; why should the ABI for which we produce code
867 # depend on .devel?
868 #
869 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
870 name="lbl/os-$os.h"
871 if test -f $name ; then
872 ln -s $name os-proto.h
873 AC_DEFINE(HAVE_OS_PROTO_H, 1,
874 [if there's an os_proto.h for this platform, to use additional prototypes])
875 else
876 AC_MSG_WARN(can't find $name)
877 fi
878 fi])
879
880 dnl
881 dnl Improved version of AC_CHECK_LIB
882 dnl
883 dnl Thanks to John Hawkinson (jhawk@mit.edu)
884 dnl
885 dnl usage:
886 dnl
887 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
888 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
889 dnl
890 dnl results:
891 dnl
892 dnl LIBS
893 dnl
894 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
895 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
896 dnl We keep it around for reference purposes in case it's ever
897 dnl useful in the future.
898 dnl
899
900 define(AC_LBL_CHECK_LIB,
901 [AC_MSG_CHECKING([for $2 in -l$1])
902 dnl Use a cache variable name containing the library, function
903 dnl name, and extra libraries to link with, because the test really is
904 dnl for library $1 defining function $2, when linked with potinal
905 dnl library $5, not just for library $1. Separate tests with the same
906 dnl $1 and different $2's or $5's may have different results.
907 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
908 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
909 [ac_save_LIBS="$LIBS"
910 LIBS="-l$1 $5 $LIBS"
911 AC_TRY_LINK(dnl
912 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
913 [/* Override any gcc2 internal prototype to avoid an error. */
914 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
915 extern "C"
916 #endif
917 ])dnl
918 [/* We use char because int might match the return type of a gcc2
919 builtin and then its argument prototype would still apply. */
920 char $2();
921 ]),
922 [$2()],
923 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
924 eval "ac_cv_lbl_lib_$ac_lib_var=no")
925 LIBS="$ac_save_LIBS"
926 ])dnl
927 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
928 AC_MSG_RESULT(yes)
929 ifelse([$3], ,
930 [changequote(, )dnl
931 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
932 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
933 changequote([, ])dnl
934 AC_DEFINE_UNQUOTED($ac_tr_lib)
935 LIBS="-l$1 $LIBS"
936 ], [$3])
937 else
938 AC_MSG_RESULT(no)
939 ifelse([$4], , , [$4
940 ])dnl
941 fi
942 ])
943
944 dnl
945 dnl AC_LBL_LIBRARY_NET
946 dnl
947 dnl This test is for network applications that need socket functions and
948 dnl getaddrinfo()/getnameinfo()-ish functions. We now require
949 dnl getaddrinfo() and getnameinfo(). We also prefer versions of
950 dnl recvmsg() that conform to the Single UNIX Specification, so that we
951 dnl can check whether a datagram received with recvmsg() was truncated
952 dnl when received due to the buffer being too small.
953 dnl
954 dnl On most operating systems, they're available in the system library.
955 dnl
956 dnl Under Solaris, we need to link with libsocket and libnsl to get
957 dnl getaddrinfo() and getnameinfo() and, if we have libxnet, we need to
958 dnl link with libxnet before libsocket to get a version of recvmsg()
959 dnl that conforms to the Single UNIX Specification.
960 dnl
961 dnl We use getaddrinfo() because we want a portable thread-safe way
962 dnl of getting information for a host name or port; there exist _r
963 dnl versions of gethostbyname() and getservbyname() on some platforms,
964 dnl but not on all platforms.
965 dnl
966 AC_DEFUN(AC_LBL_LIBRARY_NET, [
967 #
968 # Most operating systems have getaddrinfo() in the default searched
969 # libraries (i.e. libc). Check there first.
970 #
971 AC_CHECK_FUNC(getaddrinfo,,
972 [
973 #
974 # Not found in the standard system libraries.
975 # Try libsocket, which requires libnsl.
976 #
977 AC_CHECK_LIB(socket, getaddrinfo,
978 [
979 #
980 # OK, we found it in libsocket.
981 #
982 LIBS="-lsocket -lnsl $LIBS"
983 ],
984 [
985 #
986 # Not found in libsocket; test for it in libnetwork, which
987 # is where it is in Haiku.
988 #
989 AC_CHECK_LIB(network, getaddrinfo,
990 [
991 #
992 # OK, we found it in libnetwork.
993 #
994 LIBS="-lnetwork $LIBS"
995 ],
996 [
997 #
998 # We didn't find it.
999 #
1000 AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
1001 ])
1002 ], -lnsl)
1003
1004 #
1005 # OK, do we have recvmsg() in libxnet?
1006 # We also link with libsocket and libnsl.
1007 #
1008 AC_CHECK_LIB(xnet, recvmsg,
1009 [
1010 #
1011 # Yes - link with it as well.
1012 #
1013 LIBS="-lxnet $LIBS"
1014 ], , -lsocket -lnsl)
1015 ])
1016 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
1017 AC_SEARCH_LIBS(putmsg, str)
1018 ])
1019
1020 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
1021 dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1022 dnl serial 11 (pkg-config-0.29)
1023 dnl
1024 dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1025 dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
1026 dnl
1027 dnl This program is free software; you can redistribute it and/or modify
1028 dnl it under the terms of the GNU General Public License as published by
1029 dnl the Free Software Foundation; either version 2 of the License, or
1030 dnl (at your option) any later version.
1031 dnl
1032 dnl This program is distributed in the hope that it will be useful, but
1033 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
1034 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1035 dnl General Public License for more details.
1036 dnl
1037 dnl You should have received a copy of the GNU General Public License
1038 dnl along with this program; if not, write to the Free Software
1039 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1040 dnl 02111-1307, USA.
1041 dnl
1042 dnl As a special exception to the GNU General Public License, if you
1043 dnl distribute this file as part of a program that contains a
1044 dnl configuration script generated by Autoconf, you may include it under
1045 dnl the same distribution terms that you use for the rest of that
1046 dnl program.
1047
1048 dnl PKG_PREREQ(MIN-VERSION)
1049 dnl -----------------------
1050 dnl Since: 0.29
1051 dnl
1052 dnl Verify that the version of the pkg-config macros are at least
1053 dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
1054 dnl installed version of pkg-config, this checks the developer's version
1055 dnl of pkg.m4 when generating configure.
1056 dnl
1057 dnl To ensure that this macro is defined, also add:
1058 dnl m4_ifndef([PKG_PREREQ],
1059 dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
1060 dnl
1061 dnl See the "Since" comment for each macro you use to see what version
1062 dnl of the macros you require.
1063 m4_defun([PKG_PREREQ],
1064 [m4_define([PKG_MACROS_VERSION], [0.29])
1065 m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
1066 [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
1067 ])dnl PKG_PREREQ
1068
1069 dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
1070 dnl ----------------------------------
1071 dnl Since: 0.16
1072 dnl
1073 dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
1074 dnl first found in the path. Checks that the version of pkg-config found
1075 dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
1076 dnl used since that's the first version where most current features of
1077 dnl pkg-config existed.
1078 AC_DEFUN([PKG_PROG_PKG_CONFIG],
1079 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1080 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
1081 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
1082 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1083 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1084 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1085
1086 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1087 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1088 fi
1089 if test -n "$PKG_CONFIG"; then
1090 _pkg_min_version=m4_default([$1], [0.9.0])
1091 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1092 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1093 AC_MSG_RESULT([yes])
1094 else
1095 AC_MSG_RESULT([no])
1096 PKG_CONFIG=""
1097 fi
1098 fi[]dnl
1099 ])dnl PKG_PROG_PKG_CONFIG
1100
1101 dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1102 dnl -------------------------------------------------------------------
1103 dnl Since: 0.18
1104 dnl
1105 dnl Check to see whether a particular set of modules exists. Similar to
1106 dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
1107 AC_DEFUN([PKG_CHECK_EXISTS],
1108 [
1109 if test -n "$PKG_CONFIG" && \
1110 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1111 m4_default([$2], [:])
1112 m4_ifvaln([$3], [else
1113 $3])dnl
1114 fi])
1115
1116 dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1117 dnl ---------------------------------------------
1118 dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
1119 dnl pkg_failed based on the result.
1120 m4_define([_PKG_CONFIG],
1121 [if test -n "$$1"; then
1122 pkg_cv_[]$1="$$1"
1123 elif test -n "$PKG_CONFIG"; then
1124 PKG_CHECK_EXISTS([$3],
1125 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
1126 test "x$?" != "x0" && pkg_failed=yes ],
1127 [pkg_failed=yes])
1128 else
1129 pkg_failed=untried
1130 fi[]dnl
1131 ])dnl _PKG_CONFIG
1132
1133 dnl _PKG_SHORT_ERRORS_SUPPORTED
1134 dnl ---------------------------
1135 dnl Internal check to see if pkg-config supports short errors.
1136 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1137 [
1138 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1139 _pkg_short_errors_supported=yes
1140 else
1141 _pkg_short_errors_supported=no
1142 fi[]dnl
1143 ])dnl _PKG_SHORT_ERRORS_SUPPORTED
1144
1145
1146 dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1147 dnl [ACTION-IF-NOT-FOUND])
1148 dnl --------------------------------------------------------------
1149 dnl Since: 0.4.0
1150 AC_DEFUN([PKG_CHECK_MODULES],
1151 [
1152 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
1153 AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
1154
1155 pkg_failed=no
1156 AC_MSG_CHECKING([for $2 with pkg-config])
1157 PKG_CHECK_EXISTS($2,
1158 [
1159 #
1160 # The package was found, so try to get its C flags and
1161 # libraries.
1162 #
1163 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1164 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
1165
1166 m4_define([_PKG_TEXT], [
1167 Alternatively, you may set the environment variables $1[]_CFLAGS
1168 and $1[]_LIBS to avoid the need to call pkg-config.
1169 See the pkg-config man page for more details.])
1170
1171 if test $pkg_failed = yes; then
1172 #
1173 # That failed - report an error.
1174 #
1175 AC_MSG_RESULT([error])
1176 _PKG_SHORT_ERRORS_SUPPORTED
1177 if test $_pkg_short_errors_supported = yes; then
1178 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
1179 else
1180 $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
1181 fi
1182 # Put the nasty error message in config.log where it belongs
1183 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1184
1185 m4_default([$4], [AC_MSG_ERROR(
1186 [Package requirements ($2) were not met:
1187
1188 $$1_PKG_ERRORS
1189
1190 Consider adjusting the PKG_CONFIG_PATH environment variable if you
1191 installed software in a non-standard prefix.
1192
1193 _PKG_TEXT])[]dnl
1194 ])
1195 elif test $pkg_failed = untried; then
1196 #
1197 # We don't have pkg-config, so it didn't work.
1198 #
1199 AC_MSG_RESULT([not found (pkg-config not found)])
1200 else
1201 #
1202 # We found the package.
1203 #
1204 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1205 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1206 AC_MSG_RESULT([found])
1207 $3
1208 fi[]dnl
1209 ],
1210 [
1211 #
1212 # The package isn't present.
1213 #
1214 AC_MSG_RESULT([not found])
1215 ])
1216 ])dnl PKG_CHECK_MODULES
1217
1218
1219 dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1220 dnl [ACTION-IF-NOT-FOUND])
1221 dnl ---------------------------------------------------------------------
1222 dnl Since: 0.29
1223 dnl
1224 dnl Checks for existence of MODULES and gathers its build flags with
1225 dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
1226 dnl and VARIABLE-PREFIX_LIBS from --libs.
1227 AC_DEFUN([PKG_CHECK_MODULES_STATIC],
1228 [
1229 _save_PKG_CONFIG=$PKG_CONFIG
1230 PKG_CONFIG="$PKG_CONFIG --static"
1231 PKG_CHECK_MODULES($@)
1232 PKG_CONFIG=$_save_PKG_CONFIG[]dnl
1233 ])dnl PKG_CHECK_MODULES_STATIC
1234
1235
1236 dnl PKG_INSTALLDIR([DIRECTORY])
1237 dnl -------------------------
1238 dnl Since: 0.27
1239 dnl
1240 dnl Substitutes the variable pkgconfigdir as the location where a module
1241 dnl should install pkg-config .pc files. By default the directory is
1242 dnl $libdir/pkgconfig, but the default can be changed by passing
1243 dnl DIRECTORY. The user can override through the --with-pkgconfigdir
1244 dnl parameter.
1245 AC_DEFUN([PKG_INSTALLDIR],
1246 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
1247 m4_pushdef([pkg_description],
1248 [pkg-config installation directory @<:@]pkg_default[@:>@])
1249 AC_ARG_WITH([pkgconfigdir],
1250 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
1251 [with_pkgconfigdir=]pkg_default)
1252 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
1253 m4_popdef([pkg_default])
1254 m4_popdef([pkg_description])
1255 ])dnl PKG_INSTALLDIR
1256
1257
1258 dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
1259 dnl --------------------------------
1260 dnl Since: 0.27
1261 dnl
1262 dnl Substitutes the variable noarch_pkgconfigdir as the location where a
1263 dnl module should install arch-independent pkg-config .pc files. By
1264 dnl default the directory is $datadir/pkgconfig, but the default can be
1265 dnl changed by passing DIRECTORY. The user can override through the
1266 dnl --with-noarch-pkgconfigdir parameter.
1267 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
1268 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
1269 m4_pushdef([pkg_description],
1270 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
1271 AC_ARG_WITH([noarch-pkgconfigdir],
1272 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
1273 [with_noarch_pkgconfigdir=]pkg_default)
1274 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
1275 m4_popdef([pkg_default])
1276 m4_popdef([pkg_description])
1277 ])dnl PKG_NOARCH_INSTALLDIR
1278
1279
1280 dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
1281 dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1282 dnl -------------------------------------------
1283 dnl Since: 0.28
1284 dnl
1285 dnl Retrieves the value of the pkg-config variable for the given module.
1286 AC_DEFUN([PKG_CHECK_VAR],
1287 [
1288 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
1289
1290 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
1291 AS_VAR_COPY([$1], [pkg_cv_][$1])
1292
1293 AS_VAR_IF([$1], [""], [$5], [$4])dnl
1294 ])dnl PKG_CHECK_VAR