]> git.ozlabs.org Git - ppp.git/blob - m4/ax_check_srp.m4
pppd: Add support for registering ppp interface via Linux rtnetlink API
[ppp.git] / m4 / ax_check_srp.m4
1 # SYNOPSIS
2 #
3 #   AX_CHECK_SRP([action-if-found[, action-if-not-found]])
4 #
5 # DESCRIPTION
6 #
7 #   Look for libsrp in a number of default locations, or in a provided location
8 #   (via --with-srp=). Sets
9 #       SRP_CFLAGS
10 #       SRP_LDFLAGS
11 #       SRP_LIBS
12 #
13 #   and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
14 #
15 # LICENSE
16 #
17 #   Copyright (c) 2021 Eivind Naess <eivnaes@yahoo.com>
18 #
19 #   Copying and distribution of this file, with or without modification, are
20 #   permitted in any medium without royalty provided the copyright notice
21 #   and this notice are preserved. This file is offered as-is, without any
22 #   warranty.
23
24 #serial 1
25
26 AC_DEFUN([AX_CHECK_SRP], [
27     AC_ARG_WITH([srp],
28         [AS_HELP_STRING([--with-srp=DIR],
29             [With libsrp support, see http://srp.stanford.edu])],
30         [
31             case "$withval" in
32             "" | y | ye | yes)
33                 srpdirs="/usr/local /usr/lib /usr"  
34               ;;
35             n | no)
36                 with_srp="no"
37               ;;
38             *)
39                 srpdirs="$withval"
40               ;;
41             esac
42         ])
43     
44     if [ test "x${with_srp}" != "xno" ] ; then
45         SRP_LIBS="-lsrp"
46         for srpdir in $srpdirs; do
47             AC_MSG_CHECKING([for srp.h in $srpdir])
48             if test -f "$srpdir/include/srp.h"; then
49                 SRP_CFLAGS="-I$srpdir/include"
50                 SRP_LDFLAGS="-L$srpdir/lib"
51                 AC_MSG_RESULT([yes])
52                 break
53             else
54                 AC_MSG_RESULT([no])
55             fi
56         done
57
58         # try the preprocessor and linker with our new flags,
59         # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
60
61         AC_MSG_CHECKING([if compiling and linking against libsrp works])
62
63         save_LIBS="$LIBS"
64         save_LDFLAGS="$LDFLAGS"
65         save_CPPFLAGS="$CPPFLAGS"
66         LDFLAGS="$SRP_LDFLAGS $OPENSSL_LDFLAGS $LDFLAGS"
67         LIBS="$SRP_LIBS $OPENSSL_LIBS $LIBS"
68         CPPFLAGS="$SRP_CFLAGS $OPENSSL_INCLUDES $CPPFLAGS"
69         AC_LINK_IFELSE(
70             [AC_LANG_PROGRAM(
71                 [#include <srp.h>
72                  #include <stddef.h>], 
73                 [SRP_use_engine(NULL);])],
74             [
75                 AC_MSG_RESULT([yes])
76                 with_srp=yes
77                 $1
78             ], [
79                 AC_MSG_RESULT([no])
80                 with_srp=""
81                 $2
82             ])
83         CPPFLAGS="$save_CPPFLAGS"
84         LDFLAGS="$save_LDFLAGS"
85         LIBS="$save_LIBS"
86
87         AC_SUBST([SRP_CFLAGS])
88         AC_SUBST([SRP_LIBS])
89         AC_SUBST([SRP_LDFLAGS])
90     fi
91
92     AM_CONDITIONAL(WITH_SRP, test -n "${with_srp}")
93 ])
94