1{
2 lib,
3 stdenv,
4 fetchurl,
5 buildPackages,
6 autoreconfHook,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "apr";
11 version = "1.7.6";
12
13 src = fetchurl {
14 url = "mirror://apache/apr/${pname}-${version}.tar.bz2";
15 hash = "sha256-SQMNktJXXac1eRtJbcMi885c/5SUd5uozCjH9Gxd6zI=";
16 };
17
18 patches = [
19 ./cross-assume-dev-zero-mmappable.patch
20 ];
21
22 # This test needs the net
23 postPatch = ''
24 rm test/testsock.*
25 '';
26
27 outputs = [
28 "out"
29 "dev"
30 ];
31 outputBin = "dev";
32
33 preConfigure = ''
34 configureFlagsArray+=("--with-installbuilddir=$dev/share/build")
35 '';
36
37 configureFlags =
38 lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
39 # For cross builds, provide answers to the configure time tests.
40 # These answers are valid on x86_64-linux and aarch64-linux.
41 # TODO: provide all valid answers for BSD.
42 "ac_cv_file__dev_zero=yes"
43 "ac_cv_func_setpgrp_void=${if stdenv.hostPlatform.isBSD then "no" else "yes"}"
44 "apr_cv_tcp_nodelay_with_cork=yes"
45 "ac_cv_define_PTHREAD_PROCESS_SHARED=yes"
46 "apr_cv_process_shared_works=yes"
47 "apr_cv_mutex_robust_shared=yes"
48 "ap_cv_atomic_builtins=yes"
49 "apr_cv_mutex_recursive=yes"
50 "apr_cv_epoll=yes"
51 "apr_cv_epoll_create1=yes"
52 "apr_cv_dup3=yes"
53 "apr_cv_accept4=yes"
54 "apr_cv_sock_cloexec=yes"
55 "ac_cv_struct_rlimit=yes"
56 "ac_cv_func_sem_open=yes"
57 "ac_cv_negative_eai=yes"
58 "apr_cv_gai_addrconfig=yes"
59 "ac_cv_o_nonblock_inherited=no"
60 "apr_cv_pthreads_lib=-lpthread"
61 "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/cc"
62 ]
63 ++ lib.optionals (stdenv.hostPlatform.system == "i686-cygwin") [
64 # Including the Windows headers breaks unistd.h.
65 # Based on ftp://sourceware.org/pub/cygwin/release/libapr1/libapr1-1.3.8-2-src.tar.bz2
66 "ac_cv_header_windows_h=no"
67 ];
68
69 # - Update libtool for macOS 11 support
70 # - Regenerate for cross fix patch
71 nativeBuildInputs = [ autoreconfHook ];
72
73 doCheck = true;
74
75 enableParallelBuilding = true;
76
77 meta = with lib; {
78 homepage = "https://apr.apache.org/";
79 description = "Apache Portable Runtime library";
80 mainProgram = "apr-1-config";
81 platforms = platforms.all;
82 license = licenses.asl20;
83 maintainers = [ ];
84 };
85}