xref: /freebsd/contrib/pam-krb5/m4/pam-const.m4 (revision ee3960cba1068e12fb032a68c46d74841d9edab3)
1dnl Determine whether PAM uses const in prototypes.
2dnl
3dnl Linux marks several PAM arguments const, including the argument to
4dnl pam_get_item and some arguments to conversation functions, which Solaris
5dnl doesn't.  Mac OS X, OS X, and macOS mark the first argument to
6dnl pam_strerror const, and other platforms don't.  This test tries to
7dnl determine which style is in use to select whether to declare variables
8dnl const and how to prototype functions in order to avoid compiler warnings.
9dnl
10dnl Since this is just for compiler warnings, it's not horribly important if
11dnl we guess wrong.  This test is ugly, but it seems to work.
12dnl
13dnl The canonical version of this file is maintained in the rra-c-util
14dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
15dnl
16dnl Written by Markus Moeller
17dnl Copyright 2007, 2015 Russ Allbery <eagle@eyrie.org>
18dnl Copyright 2007-2008 Markus Moeller
19dnl
20dnl This file is free software; the authors give unlimited permission to copy
21dnl and/or distribute it, with or without modifications, as long as this
22dnl notice is preserved.
23dnl
24dnl SPDX-License-Identifier: FSFULLR
25
26dnl Source used by RRA_HEADER_PAM_CONST.
27AC_DEFUN([_RRA_HEADER_PAM_CONST_SOURCE],
28[#ifdef HAVE_SECURITY_PAM_APPL_H
29# include <security/pam_appl.h>
30#else
31# include <pam/pam_appl.h>
32#endif
33])
34
35AC_DEFUN([RRA_HEADER_PAM_CONST],
36[AC_CACHE_CHECK([whether PAM prefers const], [rra_cv_header_pam_const],
37    [AC_EGREP_CPP([const void \*\* *_?item], _RRA_HEADER_PAM_CONST_SOURCE(),
38        [rra_cv_header_pam_const=yes], [rra_cv_header_pam_const=no])])
39 AS_IF([test x"$rra_cv_header_pam_const" = xyes],
40    [rra_header_pam_const=const], [rra_header_pam_const=])
41 AC_DEFINE_UNQUOTED([PAM_CONST], [$rra_header_pam_const],
42    [Define to const if PAM uses const in pam_get_item, empty otherwise.])])
43
44AC_DEFUN([RRA_HEADER_PAM_STRERROR_CONST],
45[AC_CACHE_CHECK([whether pam_strerror uses const],
46    [rra_cv_header_pam_strerror_const],
47    [AC_EGREP_CPP([pam_strerror *\(const], _RRA_HEADER_PAM_CONST_SOURCE(),
48        [rra_cv_header_pam_strerror_const=yes],
49        [rra_cv_header_pam_strerror_const=no])])
50 AS_IF([test x"$rra_cv_header_pam_strerror_const" = xyes],
51    [rra_header_pam_strerror_const=const], [rra_header_pam_strerror_const=])
52 AC_DEFINE_UNQUOTED([PAM_STRERROR_CONST], [$rra_header_pam_strerror_const],
53    [Define to const if PAM uses const in pam_strerror, empty otherwise.])])
54