bitwarden-desktop: 2024.12.1 -> 2025.1.1 (#374021)
[NixPkgs.git] / pkgs / by-name / au / autogen / package.nix
blob2c8578b8e949991280f7e2fcbd4c64b01104ec40
2   lib,
3   stdenv,
4   buildPackages,
5   fetchurl,
6   fetchpatch,
7   autoreconfHook,
8   which,
9   pkg-config,
10   perl,
11   guile_2_2,
12   libxml2,
15 stdenv.mkDerivation rec {
16   pname = "autogen";
17   version = "5.18.16";
19   src = fetchurl {
20     url = "mirror://gnu/autogen/rel${version}/autogen-${version}.tar.xz";
21     sha256 = "16mlbdys8q4ckxlvxyhwkdnh1ay9f6g0cyp1kylkpalgnik398gq";
22   };
24   patches =
25     let
26       dp =
27         {
28           ver ? "1%255.18.16-5",
29           name,
30           sha256,
31         }:
32         fetchurl {
33           url =
34             "https://salsa.debian.org/debian/autogen/-/raw/debian/${ver}"
35             + "/debian/patches/${name}?inline=false";
36           inherit name sha256;
37         };
38     in
39     [
40       (dp {
41         name = "20_no_Werror.diff";
42         sha256 = "08z4s2ifiqyaacjpd9pzr59w8m4j3548kkaq1bwvp2gjn29m680x";
43       })
44       (dp {
45         name = "30_ag_macros.m4_syntax_error.diff";
46         sha256 = "1z8vmbwbkz3505wd33i2xx91mlf8rwsa7klndq37nw821skxwyh3";
47       })
48       (dp {
49         name = "31_allow_overriding_AGexe_for_crossbuild.diff";
50         sha256 = "0h9wkc9bqb509knh8mymi43hg6n6sxg2lixvjlchcx7z0j7p8xkf";
51       })
52       (dp {
53         name = "40_suse_01-autogen-catch-race-error.patch";
54         sha256 = "1cfkym2zds1f85md1m74snxzqmzlj7wd5jivgmyl342856848xav";
55       })
56       (dp {
57         name = "40_suse_03-gcc9-fix-wrestrict.patch";
58         sha256 = "1ifdwi6gf96jc78jw7q4bfi5fgdldlf2nl55y20h6xb78kv0pznd";
59       })
60       (dp {
61         name = "40_suse_05-sprintf-overflow.patch";
62         sha256 = "136m62k68w1h5k7iapynvbyipidw35js6pq21lsc6rpxvgp0n469";
63       })
64       (dp {
65         name = "40_suse_06-autogen-avoid-GCC-code-analysis-bug.patch";
66         sha256 = "1d65zygzw2rpa00s0jy2y1bg29vkbhnjwlb5pv22rfv87zbk6z9q";
67       })
68       # Next upstream release will contain guile-3 support. We apply non-invasive
69       # patch meanwhile.
70       (fetchpatch {
71         name = "guile-3.patch";
72         url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-devel/autogen/files/autogen-5.18.16-guile-3.patch?id=43bcc61c56a5a7de0eaf806efec7d8c0e4c01ae7";
73         sha256 = "18d7y1f6164dm1wlh7rzbacfygiwrmbc35a7qqsbdawpkhydm5lr";
74       })
75       (fetchpatch {
76         name = "lfs64.patch";
77         url = "https://cygwin.com/cgit/cygwin-packages/autogen/plain/5.16.2-cygwin17.patch?id=6f39882873b3d1290ba3739e0557a84bfe05ba60";
78         stripLen = 1;
79         hash = "sha256-6dk2imqForUHKhI82CTronWaS3KUWW/EKfA/JZZcRe0=";
80       })
81     ];
83   outputs = [
84     "bin"
85     "dev"
86     "lib"
87     "out"
88     "man"
89     "info"
90   ];
92   nativeBuildInputs =
93     [
94       which
95       pkg-config
96       perl
97       autoreconfHook # patches applied
98     ]
99     ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
100       # autogen needs a build autogen when cross-compiling
101       buildPackages.buildPackages.autogen
102       buildPackages.texinfo
103     ];
104   buildInputs = [
105     guile_2_2
106     libxml2
107   ];
109   preConfigure = ''
110     export MAN_PAGE_DATE=$(date '+%Y-%m-%d' -d "@$SOURCE_DATE_EPOCH")
111   '';
113   configureFlags =
114     [
115       "--with-libxml2=${libxml2.dev}"
116       "--with-libxml2-cflags=-I${libxml2.dev}/include/libxml2"
117       # Make sure to use a static value for the timeout. If we do not set a value
118       # here autogen will select one based on the execution time of the configure
119       # phase which is not really reproducible.
120       #
121       # If you are curious about the number 78, it has been cargo-culted from
122       # Debian: https://salsa.debian.org/debian/autogen/-/blob/master/debian/rules#L21
123       "--enable-timeout=78"
124       "CFLAGS=-D_FILE_OFFSET_BITS=64"
125     ]
126     ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
127       # the configure check for regcomp wants to run a host program
128       "libopts_cv_with_libregex=yes"
129       #"MAKEINFO=${buildPackages.texinfo}/bin/makeinfo"
130     ]
131     # See: https://sourceforge.net/p/autogen/bugs/187/
132     ++ lib.optionals stdenv.hostPlatform.isDarwin [ "ac_cv_func_utimensat=no" ];
134   #doCheck = true; # not reliable
136   postInstall =
137     ''
138       mkdir -p $dev/bin
139       mv $bin/bin/autoopts-config $dev/bin
141       for f in $lib/lib/autogen/tpl-config.tlib $out/share/autogen/tpl-config.tlib; do
142         sed -e "s|$dev/include|/no-such-autogen-include-path|" -i $f
143         sed -e "s|$bin/bin|/no-such-autogen-bin-path|" -i $f
144         sed -e "s|$lib/lib|/no-such-autogen-lib-path|" -i $f
145       done
147     ''
148     + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
149       # remove build directory (/build/**, or /tmp/nix-build-**) from RPATHs
150       for f in "$bin"/bin/*; do
151         local nrp="$(patchelf --print-rpath "$f" | sed -E 's@(:|^)'$NIX_BUILD_TOP'[^:]*:@\1@g')"
152         patchelf --set-rpath "$nrp" "$f"
153       done
154     '';
156   meta = with lib; {
157     description = "Automated text and program generation tool";
158     license = with licenses; [
159       gpl3Plus
160       lgpl3Plus
161     ];
162     homepage = "https://www.gnu.org/software/autogen/";
163     platforms = platforms.all;
164     maintainers = [ ];
165   };