2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
2020-04-24 23:36:52 +00:00
|
|
|
# TODO: links -lsigsegv but loses the reference for some reason
|
|
|
|
, withSigsegv ? (false && stdenv.hostPlatform.system != "x86_64-cygwin"), libsigsegv
|
|
|
|
, interactive ? false, readline
|
2023-01-20 10:41:00 +00:00
|
|
|
, autoreconfHook # no-pma fix
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
/* Test suite broke on:
|
|
|
|
stdenv.isCygwin # XXX: `test-dup2' segfaults on Cygwin 6.1
|
|
|
|
|| stdenv.isDarwin # XXX: `locale' segfaults
|
|
|
|
|| stdenv.isSunOS # XXX: `_backsmalls1' fails, locale stuff?
|
|
|
|
|| stdenv.isFreeBSD
|
|
|
|
*/
|
|
|
|
, doCheck ? (interactive && stdenv.isLinux), glibcLocales ? null
|
|
|
|
, locale ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert (doCheck && stdenv.isLinux) -> glibcLocales != null;
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-03-05 16:20:37 +00:00
|
|
|
pname = "gawk" + lib.optionalString interactive "-interactive";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "5.2.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-08-22 07:53:02 +00:00
|
|
|
url = "mirror://gnu/gawk/gawk-${version}.tar.xz";
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-ZzVTuR+eGMxXku1RB1341RDJBA9VCm904Jya3SQ6fk8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
patches = [
|
|
|
|
# Pull upstream fix for aarch64-darwin where pma does not work.
|
|
|
|
# Can be removed after next gawk release.
|
|
|
|
./darwin-no-pma.patch
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
# PIE is incompatible with the "persistent malloc" ("pma") feature.
|
|
|
|
# While build system attempts to pass -no-pie to gcc. nixpkgs' `ld`
|
|
|
|
# wrapped still passes `-pie` flag to linker and breaks linkage.
|
|
|
|
# Let's disable "pie" until `ld` is fixed to do the right thing.
|
|
|
|
hardeningDisable = [ "pie" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# When we do build separate interactive version, it makes sense to always include man.
|
2021-09-18 10:52:07 +00:00
|
|
|
outputs = [ "out" "info" ]
|
|
|
|
++ lib.optional (!interactive) "man";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
# no-pma fix
|
|
|
|
nativeBuildInputs = [ autoreconfHook ]
|
|
|
|
++ lib.optional (doCheck && stdenv.isLinux) glibcLocales;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
buildInputs = lib.optional withSigsegv libsigsegv
|
|
|
|
++ lib.optional interactive readline
|
|
|
|
++ lib.optional stdenv.isDarwin locale;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
(if withSigsegv then "--with-libsigsegv-prefix=${libsigsegv}" else "--without-libsigsegv")
|
|
|
|
(if interactive then "--with-readline=${readline.dev}" else "--without-readline")
|
|
|
|
];
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"AR=${stdenv.cc.targetPrefix}ar"
|
|
|
|
];
|
|
|
|
|
|
|
|
inherit doCheck;
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
rm "$out"/bin/gawk-*
|
|
|
|
ln -s gawk.1 "''${!outputMan}"/share/man/man1/awk.1
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
libsigsegv = if withSigsegv then libsigsegv else null; # for stdenv bootstrap
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.gnu.org/software/gawk/";
|
|
|
|
description = "GNU implementation of the Awk programming language";
|
|
|
|
longDescription = ''
|
|
|
|
Many computer users need to manipulate text files: extract and then
|
|
|
|
operate on data from parts of certain lines while discarding the rest,
|
|
|
|
make changes in various text files wherever certain patterns appear,
|
|
|
|
and so on. To write a program to do these things in a language such as
|
|
|
|
C or Pascal is a time-consuming inconvenience that may take many lines
|
|
|
|
of code. The job is easy with awk, especially the GNU implementation:
|
|
|
|
Gawk.
|
|
|
|
|
|
|
|
The awk utility interprets a special-purpose programming language that
|
|
|
|
makes it possible to handle many data-reformatting jobs with just a few
|
|
|
|
lines of code.
|
|
|
|
'';
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.unix ++ platforms.windows;
|
|
|
|
maintainers = [ ];
|
|
|
|
};
|
2023-02-02 18:25:31 +00:00
|
|
|
}
|