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