at master 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPackages, 5 fetchurl, 6 bison, 7 m4, 8 autoreconfHook, 9 help2man, 10}: 11 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). 15 16stdenv.mkDerivation rec { 17 pname = "flex"; 18 version = "2.6.4"; 19 20 src = fetchurl { 21 url = "https://github.com/westes/flex/releases/download/v${version}/flex-${version}.tar.gz"; 22 sha256 = "15g9bv236nzi665p9ggqjlfn4dwck5835vf0bbw2cz7h5c1swyp8"; 23 }; 24 25 # Also upstream, will be part of 2.6.5 26 # https://github.com/westes/flex/commit/24fd0551333e 27 patches = [ 28 (fetchurl { 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"; 32 }) 33 ]; 34 35 postPatch = '' 36 patchShebangs tests 37 '' 38 + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' 39 substituteInPlace Makefile.in --replace "tests" " " 40 41 substituteInPlace doc/Makefile.am --replace 'flex.1: $(top_srcdir)/configure.ac' 'flex.1: ' 42 ''; 43 44 depsBuildBuild = [ buildPackages.stdenv.cc ]; 45 nativeBuildInputs = [ 46 autoreconfHook 47 help2man 48 ]; 49 buildInputs = [ bison ]; 50 propagatedBuildInputs = [ m4 ]; 51 52 preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' 53 export ac_cv_func_malloc_0_nonnull=yes 54 export ac_cv_func_realloc_0_nonnull=yes 55 ''; 56 57 postConfigure = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isCygwin) '' 58 sed -i Makefile -e 's/-no-undefined//;' 59 ''; 60 61 dontDisableStatic = stdenv.buildPlatform != stdenv.hostPlatform; 62 63 postInstall = '' 64 ln -s $out/bin/flex $out/bin/lex 65 ''; 66 67 meta = with lib; { 68 homepage = "https://github.com/westes/flex"; 69 description = "Fast lexical analyser generator"; 70 license = licenses.bsd2; 71 platforms = platforms.unix; 72 }; 73}