1{
2 lib,
3 stdenv,
4 fetchurl,
5 m4,
6 makeWrapper,
7 libbsd,
8 perlPackages,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "csmith";
13 version = "2.3.0";
14
15 src = fetchurl {
16 url = "https://embed.cs.utah.edu/csmith/${pname}-${version}.tar.gz";
17 sha256 = "1mb5zgixsyf86slggs756k8a5ddmj980md3ic9sa1y75xl5cqizj";
18 };
19
20 nativeBuildInputs = [
21 m4
22 makeWrapper
23 ];
24 buildInputs = [
25 libbsd
26 ]
27 ++ (with perlPackages; [
28 perl
29 SysCPU
30 ]);
31
32 CXXFLAGS = "-std=c++98";
33
34 postInstall = ''
35 substituteInPlace $out/bin/compiler_test.pl \
36 --replace '$CSMITH_HOME/runtime' $out/include/${pname}-${version} \
37 --replace ' ''${CSMITH_HOME}/runtime' " $out/include/${pname}-${version}" \
38 --replace '$CSMITH_HOME/src/csmith' $out/bin/csmith
39
40 substituteInPlace $out/bin/launchn.pl \
41 --replace '../compiler_test.pl' $out/bin/compiler_test.pl \
42 --replace '../$CONFIG_FILE' '$CONFIG_FILE'
43
44 wrapProgram $out/bin/launchn.pl \
45 --prefix PERL5LIB : "$PERL5LIB"
46
47 mkdir -p $out/share/csmith
48 mv $out/bin/compiler_test.in $out/share/csmith/
49 '';
50
51 enableParallelBuilding = true;
52
53 meta = with lib; {
54 description = "Random generator of C programs";
55 homepage = "https://embed.cs.utah.edu/csmith";
56 # Officially, the license is this: https://github.com/csmith-project/csmith/blob/master/COPYING
57 license = licenses.bsd2;
58 longDescription = ''
59 Csmith is a tool that can generate random C programs that statically and
60 dynamically conform to the C99 standard. It is useful for stress-testing
61 compilers, static analyzers, and other tools that process C code.
62 Csmith has found bugs in every tool that it has tested, and has been used
63 to find and report more than 400 previously unknown compiler bugs.
64 '';
65 maintainers = [ ];
66 platforms = platforms.all;
67 };
68}