diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2023-10-03 13:12:10 +0200 |
---|---|---|
committer | Alexey Gladkov <gladkov.alexey@gmail.com> | 2024-01-04 17:47:50 +0000 |
commit | b1511a24c3d042a6421f276d5b6ecbfb993389e1 (patch) | |
tree | 68b1d03d2b7a1363b38bb92c7e9849fd084980fd | |
parent | 2fbb4ca5a5b7ae3692b694c99caf789794a5bc42 (diff) | |
download | kbd-b1511a24c3d042a6421f276d5b6ecbfb993389e1.tar.gz |
Use pkg-config for external dependencies
These days, many libraries have pkg-config files in which the authors
themselves specify the correct CFLAGS and LIBS. It is much more correct
to use it rather than try to guess it for ourselves.
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r-- | configure.ac | 34 | ||||
-rw-r--r-- | src/vlock/Makefile.am | 3 |
2 files changed, 25 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index 95d8e5b1..a4be8383 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,14 @@ AC_FUNC_CLOSEDIR_VOID AC_FUNC_FORK AC_FUNC_STAT +m4_ifndef([PKG_PROG_PKG_CONFIG], + [m4_fatal([Could not locate the pkg-config autoconf + macros. These are usually located in /usr/share/aclocal/pkg.m4. + If your macros are in a different location, try setting the + environment variable AL_OPTS="-I/other/macro/dir" before running + ./autogen.sh or autoreconf again. Make sure pkg-config is installed.])]) +PKG_PROG_PKG_CONFIG + AC_CHECK_FUNCS([alarm memset setlocale strcasecmp strchr strdup strerror \ strspn strstr strtol strtoul setpgrp malloc realloc]) @@ -145,18 +153,22 @@ AC_ARG_ENABLE(vlock, AM_CONDITIONAL(VLOCK, test "$VLOCK_PROG" = "yes") if test "$VLOCK_PROG" = "yes"; then - AC_CHECK_LIB(pam, pam_start, [ - AC_CHECK_HEADER([security/pam_appl.h], - [have_pam=1], - AC_MSG_ERROR([Can't find required header files.]))]) - AC_CHECK_LIB(pam_misc, misc_conv, [ - AC_CHECK_HEADER([security/pam_misc.h], - [have_pam_misc=1], - AC_MSG_ERROR([Can't find required header files.]))]) - if test -z "$have_pam" -o -z "$have_pam_misc"; then - AC_MSG_ERROR([libpam-devel required.]) + PKG_CHECK_MODULES(PAM, pam, [HAVE_PAM=yes], [HAVE_PAM=no]) + PKG_CHECK_MODULES(PAM_MISC, pam_misc, [HAVE_PAM_MISC=yes], [HAVE_PAM_MISC=no]) + if test "$HAVE_PAM" != yes -o "$HAVE_PAM_MISC" != yes; then + AC_CHECK_LIB(pam, pam_start, [ + AC_CHECK_HEADER([security/pam_appl.h], + [HAVE_PAM=yes], + AC_MSG_ERROR([Can't find required header files.]))]) + AC_CHECK_LIB(pam_misc, misc_conv, [ + AC_CHECK_HEADER([security/pam_misc.h], + [HAVE_PAM_MISC=yes], + AC_MSG_ERROR([Can't find required header files.]))]) + if test "$HAVE_PAM" != yes -o "$HAVE_PAM_MISC" != yes; then + AC_MSG_ERROR([libpam-devel required.]) + fi + AC_SUBST(PAM_LIBS, "-lpam -lpam_misc") fi - AC_SUBST(PAM_LIBS, "-lpam -lpam_misc") fi AC_ARG_ENABLE(tests, diff --git a/src/vlock/Makefile.am b/src/vlock/Makefile.am index f4b064b2..e1716541 100644 --- a/src/vlock/Makefile.am +++ b/src/vlock/Makefile.am @@ -25,4 +25,5 @@ vlock_SOURCES = \ vlock.h \ vt.c -vlock_LDADD = $(top_builddir)/src/libcommon/libcommon.a @PAM_LIBS@ +vlock_CFLAGS = @PAM_CFLAGS@ @PAM_MISC_CFLAGS@ +vlock_LDADD = $(top_builddir)/src/libcommon/libcommon.a @PAM_LIBS@ @PAM_MISC_LIBS@ |