Module: monitoring-plugins
 Branch: master
 Commit: 59d7d1c2f12363331d03d956cfce0936034c34f8
 Author: Alvar Penning <[email protected]>
   Date: Wed Dec 10 20:55:56 2025 +0100
    URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=59d7d1c2

configure.ac: Fix PostgreSQL Check for OpenBSD

On OpenBSD, crypt is named crypto. This diff is a portable version of a
patch residing in the OpenBSD ports since ages.

https://codeberg.org/OpenBSD/ports/src/commit/1f15238782c26deb728250cbf591f1ffcd10422f/net/monitoring-plugins/patches/patch-configure_ac

---

 configure.ac | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2bf94014..abd90413 100644
--- a/configure.ac
+++ b/configure.ac
@@ -205,32 +205,46 @@ fi
 dnl Check for PostgreSQL libraries
 _SAVEDLIBS="$LIBS"
 _SAVEDCPPFLAGS="$CPPFLAGS"
+case $host in
+       *openbsd*)
+               _CRYPTLIB="crypto"
+               ;;
+       *)
+               _CRYPTLIB="crypt"
+esac
+
 AC_ARG_WITH(pgsql,
        ACX_HELP_STRING([--with-pgsql=DIR],
                [sets path to pgsql installation]),
        PGSQL=$withval,)
 AC_CHECK_LIB(crypt,main)
-if test "$ac_cv_lib_crypt_main" = "yes" -a "x$PGSQL" != "xno"; then
+AC_CHECK_LIB(crypto,main)
+if test \( "$ac_cv_lib_crypt_main" = "yes" -o "$ac_cv_lib_crypto_main" = "yes" 
\) -a "x$PGSQL" != "xno"; then
   if test -n "$PGSQL"; then
     LDFLAGS="$LDFLAGS -L$PGSQL/lib"
     CPPFLAGS="$CPPFLAGS -I$PGSQL/include"
   fi
-  AC_CHECK_LIB(pq,PQsetdbLogin,,,-lcrypt)
+  AC_CHECK_LIB(pq,PQsetdbLogin,,,"-l$_CRYPTLIB")
   if test "$ac_cv_lib_pq_PQsetdbLogin" = "yes"; then
     AC_CHECK_HEADERS(pgsql/libpq-fe.h)
     AC_CHECK_HEADERS(postgresql/libpq-fe.h)
     AC_CHECK_HEADERS(libpq-fe.h)
     if [[ -n "$PGSQL" -a "$ac_cv_header_libpq_fe_h" = "yes" ]]; then
-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
+      PGLIBS="-L$PGSQL/lib -lpq -l$_CRYPTLIB"
       PGINCLUDE="-I$PGSQL/include"
     elif test  "$ac_cv_header_pgsql_libpq_fe_h" = "yes"; then
-      PGLIBS="-lpq -lcrypt"
+      PGLIBS="-lpq -l$_CRYPTLIB"
       PGINCLUDE="-I/usr/include/pgsql"
     elif test  "$ac_cv_header_postgresql_libpq_fe_h" = "yes"; then
-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
-      PGINCLUDE="-I/usr/include/postgresql"
+      PGLIBS="-L$PGSQL/lib -lpq -l$_CRYPTLIB"
+      case $host in
+        *openbsd*)
+          PGINCLUDE="-I$PGSQL/include/postgresql" ;;
+        *)
+          PGINCLUDE="-I/usr/include/postgresql"
+      esac
     elif test  "$ac_cv_header_libpq_fe_h" = "yes"; then
-      PGLIBS="-L$PGSQL/lib -lpq -lcrypt"
+      PGLIBS="-L$PGSQL/lib -lpq -l$_CRYPTLIB"
       PGINCLUDE="-I$PGSQL/include"
     fi
     if test -z "$PGINCLUDE"; then

Reply via email to