2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, buildPackages, fetchurl, bison, m4
|
2022-01-13 20:06:32 +00:00
|
|
|
, autoreconfHook, help2man
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
# Avoid 'fetchpatch' to allow 'flex' to be used as a possible 'gcc'
|
|
|
|
# dependency during bootstrap. Useful when gcc is built from snapshot
|
|
|
|
# or from a git tree (flex lexers are not pre-generated there).
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "flex";
|
|
|
|
version = "2.6.4";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/westes/flex/releases/download/v${version}/flex-${version}.tar.gz";
|
|
|
|
sha256 = "15g9bv236nzi665p9ggqjlfn4dwck5835vf0bbw2cz7h5c1swyp8";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Also upstream, will be part of 2.6.5
|
|
|
|
# https://github.com/westes/flex/commit/24fd0551333e
|
2022-01-13 20:06:32 +00:00
|
|
|
patches = [(fetchurl {
|
2020-04-24 23:36:52 +00:00
|
|
|
name = "glibc-2.26.patch";
|
2022-01-13 20:06:32 +00:00
|
|
|
url = "https://raw.githubusercontent.com/lede-project/source/0fb14a2b1ab2f82ce63f4437b062229d73d90516/tools/flex/patches/200-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch";
|
|
|
|
sha256 = "0mpp41zdg17gx30kcpj83jl8hssks3adbks0qzbhcz882b9c083r";
|
2020-04-24 23:36:52 +00:00
|
|
|
})];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs tests
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace Makefile.in --replace "tests" " "
|
|
|
|
|
|
|
|
substituteInPlace doc/Makefile.am --replace 'flex.1: $(top_srcdir)/configure.ac' 'flex.1: '
|
|
|
|
'';
|
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
nativeBuildInputs = [ autoreconfHook help2man ];
|
|
|
|
buildInputs = [ bison ];
|
|
|
|
propagatedBuildInputs = [ m4 ];
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
|
|
|
export ac_cv_func_malloc_0_nonnull=yes
|
|
|
|
export ac_cv_func_realloc_0_nonnull=yes
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
postConfigure = lib.optionalString (stdenv.isDarwin || stdenv.isCygwin) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
sed -i Makefile -e 's/-no-undefined//;'
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontDisableStatic = stdenv.buildPlatform != stdenv.hostPlatform;
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
postInstall = ''
|
|
|
|
ln -s $out/bin/flex $out/bin/lex
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/westes/flex";
|
|
|
|
description = "A fast lexical analyser generator";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|