aclocal/libs2.ac
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 dnl
       
     2 dnl    Copyright 2005-2006 Intel Corporation
       
     3 dnl 
       
     4 dnl    Licensed under the Apache License, Version 2.0 (the "License");
       
     5 dnl    you may not use this file except in compliance with the License.
       
     6 dnl    You may obtain a copy of the License at
       
     7 dnl 
       
     8 dnl        http://www.apache.org/licenses/LICENSE-2.0
       
     9 dnl 
       
    10 dnl    Unless required by applicable law or agreed to in writing, software
       
    11 dnl    distributed under the License is distributed on an "AS IS" BASIS,
       
    12 dnl    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13 dnl    See the License for the specific language governing permissions and
       
    14 dnl    limitations under the License.
       
    15 dnl
       
    16 
       
    17 
       
    18 #
       
    19 # Macro based on AC_CHECK_LIB but which takes a particular
       
    20 # LFLAGS setting as another argument to go into the cache.
       
    21 #
       
    22 
       
    23 # AC_CHECK_LIB_FLAGS(LIBRARY, FUNCTION, LDFLAGS,
       
    24 #                    [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
       
    25 #                    [OTHER-LIBRARIES])
       
    26 # ------------------------------------------------------
       
    27 #
       
    28 # Use a cache variable name containing both the library and function name,
       
    29 # because the test really is for library $1 defining function $2, not
       
    30 # just for library $1.  Separate tests with the same $1 and different $2s
       
    31 # may have different results.
       
    32 #
       
    33 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])
       
    34 # is asking for troubles, since AC_CHECK_LIB($lib, fun) would give
       
    35 # ac_cv_lib_$lib_fun, which is definitely not what was meant.  Hence
       
    36 # the AS_LITERAL_IF indirection.
       
    37 #
       
    38 # FIXME: This macro is extremely suspicious.  It DEFINEs unconditionally,
       
    39 # whatever the FUNCTION, in addition to not being a *S macro.  Note
       
    40 # that the cache does depend upon the function we are looking for.
       
    41 #
       
    42 # It is on purpose we used `ac_check_lib_save_LIBS' and not just
       
    43 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
       
    44 # changed but still want to use AC_CHECK_LIB, so they save `LIBS'.
       
    45 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
       
    46 # freedom.
       
    47 AC_DEFUN([AC_CHECK_LIB_FLAGS],
       
    48 [m4_ifval([$4], , [AH_CHECK_LIB([$1])])dnl
       
    49 AS_LITERAL_IF([$1],
       
    50               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2_$3])],
       
    51               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2_$3])])dnl
       
    52 AC_CACHE_CHECK([for $2 in -l$1 with $3], ac_Lib,
       
    53 [ac_check_lib_save_LIBS=$LIBS
       
    54 ac_check_lib_save_LDFLAGS=$LDFLAGS
       
    55 LIBS="-l$1 $6 $LIBS"
       
    56 LDFLAGS="$3 $LDFLAGS"
       
    57 AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
       
    58                [AS_VAR_SET(ac_Lib, yes)],
       
    59                [AS_VAR_SET(ac_Lib, no)])
       
    60 LIBS=$ac_check_lib_save_LIBS
       
    61 LDFLAGS=$ac_check_lib_save_LDFLAGS])
       
    62 AS_IF([test AS_VAR_GET(ac_Lib) = yes],
       
    63       [m4_default([$4], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
       
    64   LIBS="-l$1 $LIBS"
       
    65 ])],
       
    66       [$5])dnl
       
    67 AS_VAR_POPDEF([ac_Lib])dnl
       
    68 ])# AC_CHECK_LIB