nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 patches = [
26 (fetchurl {
27 # Also upstream, will be part of 2.6.5
28 # 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";
32 })
33 (fetchurl {
34 name = "gcc-15.patch";
35 url = "https://github.com/westes/flex/commit/bf254c75b1e0d2641ebbd7fc85fb183f36a62ea7.patch";
36 hash = "sha256-Bnv23M2K1Qf7pEaEz0ueSNzTCdjMTDiMm+H7JaxUISs=";
37 })
38 ];
39
40 postPatch = ''
41 patchShebangs tests
42 ''
43 + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
44 substituteInPlace Makefile.in --replace "tests" " "
45
46 substituteInPlace doc/Makefile.am --replace 'flex.1: $(top_srcdir)/configure.ac' 'flex.1: '
47 '';
48
49 depsBuildBuild = [ buildPackages.stdenv.cc ];
50 nativeBuildInputs = [
51 autoreconfHook
52 help2man
53 ];
54 buildInputs = [ bison ];
55 propagatedBuildInputs = [ m4 ];
56
57 preConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
58 export ac_cv_func_malloc_0_nonnull=yes
59 export ac_cv_func_realloc_0_nonnull=yes
60 '';
61
62 postConfigure = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isCygwin) ''
63 sed -i Makefile -e 's/-no-undefined//;'
64 '';
65
66 dontDisableStatic = stdenv.buildPlatform != stdenv.hostPlatform;
67
68 postInstall = ''
69 ln -s $out/bin/flex $out/bin/lex
70 '';
71
72 meta = {
73 homepage = "https://github.com/westes/flex";
74 description = "Fast lexical analyser generator";
75 license = lib.licenses.bsd2;
76 platforms = lib.platforms.unix;
77 };
78}