]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/cracklib.m4
Change CrackLib tests for system CrackLib
[kerberos/krb5-strength.git] / m4 / cracklib.m4
1 dnl Find the compiler and linker flags for CrackLib.
2 dnl
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.
8 dnl
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.
17 dnl
18 dnl Depends on RRA_SET_LDFLAGS.
19 dnl
20 dnl Written by Russ Allbery <eagle@eyrie.org>
21 dnl Copyright 2010
22 dnl     The Board of Trustees of the Leland Stanford Junior University
23 dnl
24 dnl This file is free software; the authors give unlimited permission to copy
25 dnl and/or distribute it, with or without modifications, as long as this
26 dnl notice is preserved.
27
28 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
29 dnl versions that include the Kerberos v5 flags.  Used as a wrapper, with
30 dnl RRA_LIB_CRACKLIB_RESTORE, around tests.
31 AC_DEFUN([RRA_LIB_CRACKLIB_SWITCH],
32 [rra_cracklib_save_CPPFLAGS="$CPPFLAGS"
33  rra_cracklib_save_LDFLAGS="$LDFLAGS"
34  rra_cracklib_save_LIBS="$LIBS"
35  CPPFLAGS="$CRACKLIB_CPPFLAGS $CPPFLAGS"
36  LDFLAGS="$CRACKLIB_LDFLAGS $LDFLAGS"
37  LIBS="$CRACKLIB_LIBS $LIBS"])
38
39 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
40 dnl RRA_LIB_CRACKLIB_SWITCH was called).
41 AC_DEFUN([RRA_LIB_CRACKLIB_RESTORE],
42 [CPPFLAGS="$rra_cracklib_save_CPPFLAGS"
43  LDFLAGS="$rra_cracklib_save_LDFLAGS"
44  LIBS="$rra_cracklib_save_LIBS"])
45
46 dnl Set CRACKLIB_CPPFLAGS and CRACKLIB_LDFLAGS based on rra_cracklib_root,
47 dnl rra_cracklib_libdir, and rra_cracklib_includedir.
48 AC_DEFUN([_RRA_LIB_CRACKLIB_PATHS],
49 [AS_IF([test x"$rra_cracklib_libdir" != x],
50     [CRACKLIB_LDFLAGS="-L$rra_cracklib_libdir"],
51     [AS_IF([test x"$rra_cracklib_root" != x],
52         [RRA_SET_LDFLAGS([CRACKLIB_LDFLAGS], [$rra_cracklib_root])])])
53  AS_IF([test x"$rra_cracklib_includedir" != x],
54     [CRACKLIB_CPPFLAGS="-I$rra_cracklib_includedir"],
55     [AS_IF([test x"$rra_cracklib_root" != x],
56         [AS_IF([test x"$rra_cracklib_root" != x/usr],
57             [CRACKLIB_CPPFLAGS="-I${rra_cracklib_root}/include"])])])])
58
59 dnl Sanity-check the results of the CrackLib library search to be sure we can
60 dnl really link a CrackLib program.
61 AC_DEFUN([_RRA_LIB_CRACKLIB_CHECK],
62 [RRA_LIB_CRACKLIB_SWITCH
63  AC_CHECK_FUNC([FascistCheck], ,
64     [AC_MSG_FAILURE([unable to link with CrackLib library])])
65  RRA_LIB_CRACKLIB_RESTORE])
66
67 dnl The main macro.
68 AC_DEFUN([RRA_LIB_CRACKLIB],
69 [rra_system_cracklib=
70  rra_cracklib_root=
71  rra_cracklib_libdir=
72  rra_cracklib_includedir=
73  CRACKLIB_CPPFLAGS=
74  CRACKLIB_LDFLAGS=
75  CRACKLIB_LIBS=
76  AC_SUBST([CRACKLIB_CPPFLAGS])
77  AC_SUBST([CRACKLIB_LDFLAGS])
78  AC_SUBST([CRACKLIB_LIBS])
79
80  AC_ARG_WITH([cracklib],
81     [AS_HELP_STRING([--with-cracklib@<:@=DIR@:>@],
82         [Use system CrackLib instead of embedded copy])],
83     [AS_IF([test x"$withval" != xno], [rra_system_cracklib=yes])
84      AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
85         [rra_cracklib_root="$withval"])])
86  AC_ARG_WITH([cracklib-include],
87     [AS_HELP_STRING([--with-cracklib-include=DIR],
88         [Location of CrackLib headers])],
89     [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
90         [rra_cracklib_includedir="$withval"])])
91  AC_ARG_WITH([cracklib-lib],
92     [AS_HELP_STRING([--with-cracklib-lib=DIR],
93         [Location of cracklib libraries])],
94     [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
95         [rra_cracklib_libdir="$withval"])])
96
97  AM_CONDITIONAL([EMBEDDED_CRACKLIB], [test x"$rra_system_cracklib" != xyes])
98  AS_IF([test x"$rra_system_cracklib" = xyes],
99      [_RRA_LIB_CRACKLIB_PATHS
100       CRACKLIB_LIBS="-lcrack"
101       _RRA_LIB_CRACKLIB_CHECK])])