build: detect pppd version via pkg-config for PPPD_PLUGIN_DIR

Ppp 2.5 adds a pkg-config file, so we can detect the version.
Use it.

[thaller@redhat.com: split out patch]

(cherry picked from commit 0324098afa)
(cherry picked from commit 89bde5c9ca)
This commit is contained in:
Eivind Næss 2023-03-04 23:26:00 +01:00 committed by Thomas Haller
parent 4faad49487
commit f19c9d2097
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 14 additions and 3 deletions

View file

@ -767,13 +767,17 @@ else
fi
AM_CONDITIONAL(WITH_PPP, test "${enable_ppp}" = "yes")
PPPD_VERSION=2.4.9
PKG_CHECK_EXISTS([pppd], [
PPPD_VERSION=`$PKG_CONFIG --modversion pppd`
])
AC_ARG_WITH([pppd-plugin-dir],
AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [path to the pppd plugins directory]))
if test -n "$with_pppd_plugin_dir" ; then
PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
else
PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.5"
PPPD_PLUGIN_DIR="${libdir}/pppd/$PPPD_VERSION"
fi
AC_SUBST(PPPD_PLUGIN_DIR)

View file

@ -563,6 +563,13 @@ enable_ppp = get_option('ppp')
if enable_ppp
assert(cc.has_header('pppd/pppd.h'), 'couldn\'t find pppd.h. pppd development headers are required')
pppd_dep = dependency('pppd', required: false)
if (pppd_dep.found())
pppd_version = pppd_dep.version()
else
pppd_version = '2.4.9'
endif
pppd_path = get_option('pppd')
if pppd_path == ''
pppd = find_program('pppd', '/sbin/pppd', '/usr/sbin/pppd', required: false)
@ -574,7 +581,7 @@ if enable_ppp
pppd_plugin_dir = get_option('pppd_plugin_dir')
if pppd_plugin_dir == ''
pppd_plugin_dir = join_paths(nm_libdir, 'pppd', '2.4.5')
pppd_plugin_dir = join_paths(nm_libdir, 'pppd', pppd_version)
endif
endif
config_h.set10('WITH_PPP', enable_ppp)