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