about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/apr-util
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/apr-util')
-rw-r--r--nixpkgs/pkgs/development/libraries/apr-util/clang-bdb.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/apr-util/default.nix90
-rw-r--r--nixpkgs/pkgs/development/libraries/apr-util/fix-libxcrypt-build.patch14
-rw-r--r--nixpkgs/pkgs/development/libraries/apr-util/include-static-dependencies.patch12
4 files changed, 128 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/apr-util/clang-bdb.patch b/nixpkgs/pkgs/development/libraries/apr-util/clang-bdb.patch
new file mode 100644
index 000000000000..02e9c8378c63
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/apr-util/clang-bdb.patch
@@ -0,0 +1,12 @@
+diff -ur a/build/dbm.m4 b/build/dbm.m4
+--- a/build/dbm.m4	2013-11-23 13:00:53.000000000 -0500
++++ b/build/dbm.m4	2023-10-22 20:16:37.764571446 -0400
+@@ -235,7 +235,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <$apu_try_berkeley_db_header>
+-main ()
++int main ()
+ {
+   int major, minor, patch;
+ 
diff --git a/nixpkgs/pkgs/development/libraries/apr-util/default.nix b/nixpkgs/pkgs/development/libraries/apr-util/default.nix
new file mode 100644
index 000000000000..bd32ad45c47b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/apr-util/default.nix
@@ -0,0 +1,90 @@
+{ lib, stdenv, fetchurl, makeWrapper, apr, expat, gnused
+, sslSupport ? true, openssl
+, bdbSupport ? true, db
+, ldapSupport ? !stdenv.isCygwin, openldap
+, libiconv, libxcrypt
+, cyrus_sasl, autoreconfHook
+}:
+
+assert sslSupport -> openssl != null;
+assert bdbSupport -> db != null;
+assert ldapSupport -> openldap != null;
+
+stdenv.mkDerivation rec {
+  pname = "apr-util";
+  version = "1.6.3";
+
+  src = fetchurl {
+    url = "mirror://apache/apr/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-pBB243EHRjJsOUUEKZStmk/KwM4Cd92P6gdv7DyXcrU=";
+  };
+
+  patches = [
+    ./fix-libxcrypt-build.patch
+    # Fix incorrect Berkeley DB detection with newer versions of clang due to implicit `int` on main errors.
+    ./clang-bdb.patch
+  ] ++ lib.optional stdenv.isFreeBSD ./include-static-dependencies.patch;
+
+  NIX_CFLAGS_LINK = [ "-lcrypt" ];
+
+  outputs = [ "out" "dev" ];
+  outputBin = "dev";
+
+  nativeBuildInputs = [ makeWrapper autoreconfHook ];
+
+  configureFlags = [ "--with-apr=${apr.dev}" "--with-expat=${expat.dev}" ]
+    ++ lib.optional (!stdenv.isCygwin) "--with-crypto"
+    ++ lib.optional sslSupport "--with-openssl=${openssl.dev}"
+    ++ lib.optional bdbSupport "--with-berkeley-db=${db.dev}"
+    ++ lib.optional ldapSupport "--with-ldap=ldap"
+    ++ lib.optionals stdenv.isCygwin
+      [ "--without-pgsql" "--without-sqlite2" "--without-sqlite3"
+        "--without-freetds" "--without-berkeley-db" "--without-crypto" ]
+    ;
+
+  postConfigure = ''
+    echo '#define APR_HAVE_CRYPT_H 1' >> confdefs.h
+  '' +
+    # For some reason, db version 6.9 is selected when cross-compiling.
+    # It's unclear as to why, it requires someone with more autotools / configure knowledge to go deeper into that.
+    # Always replacing the link flag with a generic link flag seems to help though, so let's do that for now.
+    lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
+      substituteInPlace Makefile \
+        --replace "-ldb-6.9" "-ldb"
+      substituteInPlace apu-1-config \
+        --replace "-ldb-6.9" "-ldb"
+  '';
+
+  propagatedBuildInputs = [ apr expat libiconv libxcrypt ]
+    ++ lib.optional sslSupport openssl
+    ++ lib.optional bdbSupport db
+    ++ lib.optional ldapSupport openldap
+    ++ lib.optional stdenv.isFreeBSD cyrus_sasl;
+
+  postInstall = ''
+    for f in $out/lib/*.la $out/lib/apr-util-1/*.la $dev/bin/apu-1-config; do
+      substituteInPlace $f \
+        --replace "${expat.dev}/lib" "${expat.out}/lib" \
+        --replace "${db.dev}/lib" "${db.out}/lib" \
+        --replace "${openssl.dev}/lib" "${lib.getLib openssl}/lib"
+    done
+
+    # Give apr1 access to sed for runtime invocations.
+    wrapProgram $dev/bin/apu-1-config --prefix PATH : "${gnused}/bin"
+  '';
+
+  enableParallelBuilding = true;
+
+  passthru = {
+    inherit sslSupport bdbSupport ldapSupport;
+  };
+
+  meta = with lib; {
+    homepage = "https://apr.apache.org/";
+    description = "A companion library to APR, the Apache Portable Runtime";
+    mainProgram = "apu-1-config";
+    maintainers = [ maintainers.eelco ];
+    platforms = platforms.unix;
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/apr-util/fix-libxcrypt-build.patch b/nixpkgs/pkgs/development/libraries/apr-util/fix-libxcrypt-build.patch
new file mode 100644
index 000000000000..2994e5de0f78
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/apr-util/fix-libxcrypt-build.patch
@@ -0,0 +1,14 @@
+diff --git a/crypto/apr_passwd.c b/crypto/apr_passwd.c
+index c961de2..a397f27 100644
+--- a/crypto/apr_passwd.c
++++ b/crypto/apr_passwd.c
+@@ -24,9 +24,7 @@
+ #if APR_HAVE_STRING_H
+ #include <string.h>
+ #endif
+-#if APR_HAVE_CRYPT_H
+ #include <crypt.h>
+-#endif
+ #if APR_HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
diff --git a/nixpkgs/pkgs/development/libraries/apr-util/include-static-dependencies.patch b/nixpkgs/pkgs/development/libraries/apr-util/include-static-dependencies.patch
new file mode 100644
index 000000000000..1813c7217810
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/apr-util/include-static-dependencies.patch
@@ -0,0 +1,12 @@
+diff --git a/build/apu-conf.m4 b/build/apu-conf.m4
+index 8943f10..aa44305 100644
+--- a/build/apu-conf.m4
++++ b/build/apu-conf.m4
+@@ -279,6 +279,7 @@ AC_ARG_WITH(ldap,[  --with-ldap=library     ldap library to use],
+         APU_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl")
+         APU_FIND_LDAPLIB("ldap", "-ldl -lpthread")
+       else
++        APU_FIND_LDAPLIB($LIBLDAP, "-llber -lcrypto -lssl -lsasl2")
+         APU_FIND_LDAPLIB($LIBLDAP)
+         APU_FIND_LDAPLIB($LIBLDAP, "-lresolv")
+         APU_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl")