1 { lib, stdenv, buildPackages, fetchurl, bison, m4
2 , autoreconfHook, help2man
5 # Avoid 'fetchpatch' to allow 'flex' to be used as a possible 'gcc'
6 # dependency during bootstrap. Useful when gcc is built from snapshot
7 # or from a git tree (flex lexers are not pre-generated there).
9 stdenv.mkDerivation rec {
14 url = "https://github.com/westes/flex/releases/download/v${version}/flex-${version}.tar.gz";
15 sha256 = "15g9bv236nzi665p9ggqjlfn4dwck5835vf0bbw2cz7h5c1swyp8";
18 # Also upstream, will be part of 2.6.5
19 # https://github.com/westes/flex/commit/24fd0551333e
20 patches = [(fetchurl {
21 name = "glibc-2.26.patch";
22 url = "https://raw.githubusercontent.com/lede-project/source/0fb14a2b1ab2f82ce63f4437b062229d73d90516/tools/flex/patches/200-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch";
23 sha256 = "0mpp41zdg17gx30kcpj83jl8hssks3adbks0qzbhcz882b9c083r";
28 '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
29 substituteInPlace Makefile.in --replace "tests" " "
31 substituteInPlace doc/Makefile.am --replace 'flex.1: $(top_srcdir)/configure.ac' 'flex.1: '
34 depsBuildBuild = [ buildPackages.stdenv.cc ];
35 nativeBuildInputs = [ autoreconfHook help2man ];
36 buildInputs = [ bison ];
37 propagatedBuildInputs = [ m4 ];
39 preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
40 export ac_cv_func_malloc_0_nonnull=yes
41 export ac_cv_func_realloc_0_nonnull=yes
44 postConfigure = lib.optionalString (stdenv.isDarwin || stdenv.isCygwin) ''
45 sed -i Makefile -e 's/-no-undefined//;'
48 dontDisableStatic = stdenv.buildPlatform != stdenv.hostPlatform;
51 ln -s $out/bin/flex $out/bin/lex
55 homepage = "https://github.com/westes/flex";
56 description = "A fast lexical analyser generator";
57 license = licenses.bsd2;
58 platforms = platforms.unix;