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