1 dnl Find the compiler and linker flags for CrackLib.
3 dnl Allows the user to specify that the system CrackLib should be used instead
4 dnl of the embedded version by using --with-cracklib. In that case, finds the
5 dnl compiler and linker flags for that version. Also provides
6 dnl --with-cracklib-include and --with-cracklib-lib configure options to
7 dnl specify non-standard paths to the CrackLib headers and libraries.
9 dnl Provides the macro RRA_LIB_CRACKLIB. If --with-cracklib is not specified,
10 dnl this macro will set the Automake conditional EMBEDDED_CRACKLIB. If it is
11 dnl specified, sets the substitution variables CRACKLIB_CPPFLAGS,
12 dnl CRACKLIB_LDFLAGS, and CRACKLIB_LIBS. Also provides
13 dnl RRA_LIB_CRACKLIB_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
14 dnl remctl libraries, saving the current values first, and
15 dnl RRA_LIB_CRACKLIB_RESTORE to restore those settings to before the last
16 dnl RRA_LIB_CRACKLIB_SWITCH.
18 dnl Depends on the lib-helper.m4 framework.
20 dnl Written by Russ Allbery <eagle@eyrie.org>
21 dnl Copyright 2020 Russ Allbery <eagle@eyrie.org>
23 dnl The Board of Trustees of the Leland Stanford Junior University
25 dnl This file is free software; the authors give unlimited permission to copy
26 dnl and/or distribute it, with or without modifications, as long as this
27 dnl notice is preserved.
29 dnl SPDX-License-Identifier: FSFULLR
31 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
32 dnl versions that include the CrackLib flags. Used as a wrapper, with
33 dnl RRA_LIB_CRACKLIB_RESTORE, around tests.
34 AC_DEFUN([RRA_LIB_CRACKLIB_SWITCH], [RRA_LIB_HELPER_SWITCH([CRACKLIB])])
36 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
37 dnl RRA_LIB_CRACKLIB_SWITCH was called).
38 AC_DEFUN([RRA_LIB_CRACKLIB_RESTORE], [RRA_LIB_HELPER_RESTORE([CRACKLIB])])
40 dnl Checks if CrackLib is present and sets variables as appropriate.
41 AC_DEFUN([_RRA_LIB_CRACKLIB_INTERNAL],
42 [RRA_LIB_HELPER_PATHS([CRACKLIB])
43 RRA_LIB_CRACKLIB_SWITCH
44 AC_CHECK_LIB([crack], [FascistCheck], [CRACKLIB_LIBS=-lcrack],
45 [AC_MSG_ERROR([cannot find usable CrackLib library])])
46 AC_CHECK_HEADERS([crack.h])
47 AC_DEFINE([HAVE_SYSTEM_CRACKLIB], 1, [Define if using the system CrackLib.])
48 RRA_LIB_CRACKLIB_RESTORE])
51 AC_DEFUN([RRA_LIB_CRACKLIB],
52 [RRA_LIB_HELPER_VAR_INIT([CRACKLIB])
54 AC_ARG_WITH([cracklib],
55 [AS_HELP_STRING([--with-cracklib][@<:@=DIR@:>@],
56 [Use system CrackLib instead of embedded copy])],
57 [AS_IF([test x"$withval" = xno],
58 [rra_use_CRACKLIB=false],
59 [rra_use_CRACKLIB=true
60 AS_IF([test x"$withval" != xyes], [rra_CRACKLIB_root="$withval"])])])
61 AC_ARG_WITH([cracklib][-include],
62 [AS_HELP_STRING([--with-cracklib-include=DIR],
63 [Location of CrackLib headers])],
64 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
65 [rra_CRACKLIB_includedir="$withval"])])
66 AC_ARG_WITH([cracklib-lib],
67 [AS_HELP_STRING([--with-cracklib-lib=DIR],
68 [Location of CrackLib libraries])],
69 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
70 [rra_CRACKLIB_libdir="$withval"])])
72 AS_IF([test x"$rra_use_CRACKLIB" != xfalse],
73 [AS_IF([test x"$rra_use_CRACKLIB" != x], [_RRA_LIB_CRACKLIB_INTERNAL])
74 AC_DEFINE([HAVE_CRACKLIB], 1, [Define if CrackLib is available.])])
75 AM_CONDITIONAL([EMBEDDED_CRACKLIB], [test x"$rra_use_CRACKLIB" = x])])