at master 5.5 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 libiconv, 6 bashNonInteractive, 7 updateAutotoolsGnuConfigScriptsHook, 8}: 9 10# Note: this package is used for bootstrapping fetchurl, and thus 11# cannot use fetchpatch! All mutable patches (generated by GitHub or 12# cgit) that are needed here should be included directly in Nixpkgs as 13# files. 14 15stdenv.mkDerivation rec { 16 pname = "gettext"; 17 version = "0.25.1"; 18 19 src = fetchurl { 20 url = "mirror://gnu/gettext/${pname}-${version}.tar.gz"; 21 hash = "sha256-dG+VXULXHrac52OGnLkmgvCaQGZSjQGLbKej9ICJoIU="; 22 }; 23 patches = [ 24 ./absolute-paths.diff 25 # fix reproducibile output, in particular in the grub2 build 26 # https://savannah.gnu.org/bugs/index.php?59658 27 ./0001-msginit-Do-not-use-POT-Creation-Date.patch 28 ./memory-safety.patch 29 ]; 30 31 outputs = [ 32 "out" 33 "man" 34 "doc" 35 "info" 36 ]; 37 38 LDFLAGS = lib.optionalString stdenv.hostPlatform.isSunOS "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec"; 39 40 configureFlags = [ 41 "--disable-csharp" 42 ] 43 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 44 # On cross building, gettext supposes that the wchar.h from libc 45 # does not fulfill gettext needs, so it tries to work with its 46 # own wchar.h file, which does not cope well with the system's 47 # wchar.h and stddef.h (gcc-4.3 - glibc-2.9) 48 "gl_cv_func_wcwidth_works=yes" 49 ]; 50 51 postPatch = '' 52 # Older versions of gettext come with a copy of `extern-inline.m4` that is not compatible with clang 18. 53 # When a project uses gettext + autoreconfPhase, autoreconfPhase will invoke `autopoint -f`, which will 54 # replace whatever (probably compatible) version of `extern-inline.m4` with one that probalby wont work 55 # because `autopoint` will copy the autoconf macros from the projects required version of gettext. 56 # Fixing this requires replacing all the older copies of the problematic file with a new one. 57 # 58 # This is ugly, but it avoids requiring workarounds in every package using gettext and autoreconfPhase. 59 declare -a oldFiles=($(tar tf gettext-tools/misc/archive.dir.tar | grep '^gettext-0\.[19].*/extern-inline.m4')) 60 oldFilesDir=$(mktemp -d) 61 for oldFile in "''${oldFiles[@]}"; do 62 mkdir -p "$oldFilesDir/$(dirname "$oldFile")" 63 cp -a gettext-tools/gnulib-m4/extern-inline.m4 "$oldFilesDir/$oldFile" 64 done 65 tar uf gettext-tools/misc/archive.dir.tar --owner=0 --group=0 --numeric-owner -C "$oldFilesDir" "''${oldFiles[@]}" 66 67 substituteAllInPlace gettext-runtime/src/gettext.sh.in 68 substituteInPlace gettext-tools/projects/KDE/trigger --replace "/bin/pwd" pwd 69 substituteInPlace gettext-tools/projects/GNOME/trigger --replace "/bin/pwd" pwd 70 substituteInPlace gettext-tools/src/project-id --replace "/bin/pwd" pwd 71 '' 72 + lib.optionalString stdenv.hostPlatform.isCygwin '' 73 sed -i -e "s/\(cldr_plurals_LDADD = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in 74 sed -i -e "s/\(libgettextsrc_la_LDFLAGS = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in 75 '' 76 + lib.optionalString stdenv.hostPlatform.isMinGW '' 77 sed -i "s/@GNULIB_CLOSE@/1/" */*/unistd.in.h 78 ''; 79 80 strictDeps = true; 81 nativeBuildInputs = [ 82 updateAutotoolsGnuConfigScriptsHook 83 ]; 84 buildInputs = 85 lib.optionals (!stdenv.hostPlatform.isMinGW) [ 86 bashNonInteractive 87 ] 88 ++ lib.optionals (!stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isCygwin) [ 89 # HACK, see #10874 (and 14664) 90 libiconv 91 ]; 92 93 setupHooks = [ 94 ../../../build-support/setup-hooks/role.bash 95 ./gettext-setup-hook.sh 96 ]; 97 env = { 98 gettextNeedsLdflags = stdenv.hostPlatform.libc != "glibc" && !stdenv.hostPlatform.isMusl; 99 } 100 // lib.optionalAttrs stdenv.hostPlatform.isDarwin { 101 # macOS iconv implementation is slightly broken since Sonoma 102 # https://github.com/Homebrew/homebrew-core/pull/199639 103 # https://savannah.gnu.org/bugs/index.php?66541 104 am_cv_func_iconv_works = "yes"; 105 }; 106 107 enableParallelBuilding = true; 108 enableParallelChecking = false; # fails sometimes 109 110 meta = with lib; { 111 description = "Well integrated set of translation tools and documentation"; 112 113 longDescription = '' 114 Usually, programs are written and documented in English, and use 115 English at execution time for interacting with users. Using a common 116 language is quite handy for communication between developers, 117 maintainers and users from all countries. On the other hand, most 118 people are less comfortable with English than with their own native 119 language, and would rather be using their mother tongue for day to 120 day's work, as far as possible. Many would simply love seeing their 121 computer screen showing a lot less of English, and far more of their 122 own language. 123 124 GNU `gettext` is an important step for the GNU Translation Project, as 125 it is an asset on which we may build many other steps. This package 126 offers to programmers, translators, and even users, a well integrated 127 set of tools and documentation. Specifically, the GNU `gettext` 128 utilities are a set of tools that provides a framework to help other 129 GNU packages produce multi-lingual messages. 130 ''; 131 132 homepage = "https://www.gnu.org/software/gettext/"; 133 134 maintainers = with maintainers; [ zimbatm ]; 135 license = licenses.gpl2Plus; 136 platforms = platforms.all; 137 }; 138} 139 140// lib.optionalAttrs stdenv.hostPlatform.isDarwin { 141 makeFlags = [ "CFLAGS=-D_FORTIFY_SOURCE=0" ]; 142}