]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/krb5-config.m4
Update hash iterations in heimdal-history
[kerberos/krb5-strength.git] / m4 / krb5-config.m4
1 # serial 1
2
3 dnl Use krb5-config to get link paths for Kerberos libraries.
4 dnl
5 dnl Provides one macro, RRA_KRB5_CONFIG, which attempts to get compiler and
6 dnl linker flags for a library via krb5-config and sets the appropriate shell
7 dnl variables.  Defines the Autoconf variable PATH_KRB5_CONFIG, which can be
8 dnl used to find the default path to krb5-config.
9 dnl
10 dnl Depends on RRA_ENABLE_REDUCED_DEPENDS.
11 dnl
12 dnl The canonical version of this file is maintained in the rra-c-util
13 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
14 dnl
15 dnl Written by Russ Allbery <eagle@eyrie.org>
16 dnl Copyright 2018, 2021-2022 Russ Allbery <eagle@eyrie.org>
17 dnl Copyright 2011-2012
18 dnl     The Board of Trustees of the Leland Stanford Junior University
19 dnl
20 dnl This file is free software; the authors give unlimited permission to copy
21 dnl and/or distribute it, with or without modifications, as long as this
22 dnl notice is preserved.
23 dnl
24 dnl SPDX-License-Identifier: FSFULLR
25
26 dnl Check for krb5-config in the user's path and set PATH_KRB5_CONFIG.  This
27 dnl is moved into a separate macro so that it can be loaded via AC_REQUIRE,
28 dnl meaning it will only be run once even if we link with multiple krb5-config
29 dnl libraries.
30 AC_DEFUN([_RRA_KRB5_CONFIG_PATH],
31 [AC_ARG_VAR([PATH_KRB5_CONFIG], [Path to krb5-config])
32  AC_PATH_PROG([PATH_KRB5_CONFIG], [krb5-config], [],
33     [${PATH}:/usr/kerberos/bin])])
34
35 dnl Check whether the --deps flag is supported by krb5-config.  Takes the path
36 dnl to krb5-config to use.  Note that this path is not embedded in the cache
37 dnl variable, so this macro implicitly assumes that we will always use the
38 dnl same krb5-config program.
39 AC_DEFUN([_RRA_KRB5_CONFIG_DEPS],
40 [AC_REQUIRE([_RRA_KRB5_CONFIG_PATH])
41  AC_CACHE_CHECK([for --deps support in krb5-config],
42     [rra_cv_krb5_config_deps],
43     [AS_IF(["$1" 2>&1 | grep deps >/dev/null 2>&1],
44         [rra_cv_krb5_config_deps=yes],
45         [rra_cv_krb5_config_deps=no])])])
46
47 dnl Obtain the library flags for a particular library using krb5-config.
48 dnl Takes the path to the krb5-config program to use, the argument to
49 dnl krb5-config to use, and the variable prefix under which to store the
50 dnl library flags.
51 AC_DEFUN([_RRA_KRB5_CONFIG_LIBS],
52 [AC_REQUIRE([_RRA_KRB5_CONFIG_PATH])
53  AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS])
54  _RRA_KRB5_CONFIG_DEPS([$1])
55  AS_IF([test x"$rra_reduced_depends" = xfalse \
56         && test x"$rra_cv_krb5_config_deps" = xyes],
57     [$3[]_LIBS=`"$1" --deps --libs $2 2>/dev/null`],
58     [$3[]_LIBS=`"$1" --libs $2 2>/dev/null`])])
59
60 dnl Attempt to find the flags for a library using krb5-config.  Takes the
61 dnl following arguments (in order):
62 dnl
63 dnl 1. The root directory for the library in question, generally from an
64 dnl    Autoconf --with flag.  Used by preference as the path to krb5-config.
65 dnl
66 dnl 2. The argument to krb5-config to retrieve flags for this particular
67 dnl    library.
68 dnl
69 dnl 3. The variable prefix to use when setting CPPFLAGS and LIBS variables
70 dnl    based on the result of krb5-config.
71 dnl
72 dnl 4. Further actions to take if krb5-config was found and supported that
73 dnl    library type.
74 dnl
75 dnl 5. Further actions to take if krb5-config could not be used to get flags
76 dnl    for that library type.
77 dnl
78 dnl Special-case a krb5-config argument of krb5 and run krb5-config without an
79 dnl argument if that option was requested and not supported.  Old versions of
80 dnl krb5-config didn't take an argument to specify the library type, but
81 dnl always returned the flags for libkrb5.
82 AC_DEFUN([RRA_KRB5_CONFIG],
83 [rra_krb5_config_$3=
84  rra_krb5_config_$3[]_ok=
85  AS_IF([test x"$1" != x && test -x "$1/bin/krb5-config"],
86     [rra_krb5_config_$3="$1/bin/krb5-config"],
87     [_RRA_KRB5_CONFIG_PATH
88      rra_krb5_config_$3="$PATH_KRB5_CONFIG"])
89  AS_IF([test x"$rra_krb5_config_$3" != x && test -x "$rra_krb5_config_$3"],
90     [AC_CACHE_CHECK([for $2 support in krb5-config], [rra_cv_lib_$3[]_config],
91         [AS_IF(["$rra_krb5_config_$3" 2>&1 | grep $2 >/dev/null 2>&1],
92             [rra_cv_lib_$3[]_config=yes],
93             [rra_cv_lib_$3[]_config=no])])
94      AS_IF([test "$rra_cv_lib_$3[]_config" = yes],
95         [$3[]_CPPFLAGS=`"$rra_krb5_config_$3" --cflags $2 2>/dev/null`
96          _RRA_KRB5_CONFIG_LIBS([$rra_krb5_config_$3], [$2], [$3])
97          rra_krb5_config_$3[]_ok=yes],
98         [AS_IF([test x"$2" = xkrb5],
99             [$3[]_CPPFLAGS=`"$rra_krb5_config_$3" --cflags 2>/dev/null`
100              $3[]_LIBS=`"$rra_krb5_config_$3" --libs $2 2>/dev/null`
101              rra_krb5_config_$3[]_ok=yes])])])
102  AS_IF([test x"$rra_krb5_config_$3[]_ok" = xyes],
103     [$3[]_CPPFLAGS=`AS_ECHO(["$$3[]_CPPFLAGS"]) | sed 's%-I/usr/include %%'`
104      $3[]_CPPFLAGS=`AS_ECHO(["$$3[]_CPPFLAGS"]) | sed 's%-I/usr/include$%%'`
105      $4],
106     [$5])])