12 # Avoid 'fetchpatch' to allow 'flex' to be used as a possible 'gcc'
13 # dependency during bootstrap. Useful when gcc is built from snapshot
14 # or from a git tree (flex lexers are not pre-generated there).
16 stdenv.mkDerivation rec {
21 url = "https://github.com/westes/flex/releases/download/v${version}/flex-${version}.tar.gz";
22 sha256 = "15g9bv236nzi665p9ggqjlfn4dwck5835vf0bbw2cz7h5c1swyp8";
25 # Also upstream, will be part of 2.6.5
26 # https://github.com/westes/flex/commit/24fd0551333e
29 name = "glibc-2.26.patch";
30 url = "https://raw.githubusercontent.com/lede-project/source/0fb14a2b1ab2f82ce63f4437b062229d73d90516/tools/flex/patches/200-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch";
31 sha256 = "0mpp41zdg17gx30kcpj83jl8hssks3adbks0qzbhcz882b9c083r";
39 + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
40 substituteInPlace Makefile.in --replace "tests" " "
42 substituteInPlace doc/Makefile.am --replace 'flex.1: $(top_srcdir)/configure.ac' 'flex.1: '
45 depsBuildBuild = [ buildPackages.stdenv.cc ];
50 buildInputs = [ bison ];
51 propagatedBuildInputs = [ m4 ];
53 preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
54 export ac_cv_func_malloc_0_nonnull=yes
55 export ac_cv_func_realloc_0_nonnull=yes
58 postConfigure = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isCygwin) ''
59 sed -i Makefile -e 's/-no-undefined//;'
62 dontDisableStatic = stdenv.buildPlatform != stdenv.hostPlatform;
65 ln -s $out/bin/flex $out/bin/lex
69 homepage = "https://github.com/westes/flex";
70 description = "Fast lexical analyser generator";
71 license = licenses.bsd2;
72 platforms = platforms.unix;