nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPlatform,
4 hostPlatform,
5 fetchurl,
6 bash,
7 tinycc,
8 gnumakeBoot,
9 gnupatch,
10 gnused,
11 gnugrep,
12 gawk,
13 gnutar,
14 gzip,
15}:
16let
17 pname = "gnumake-musl";
18 version = "4.4.1";
19
20 src = fetchurl {
21 url = "mirror://gnu/make/make-${version}.tar.gz";
22 hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
23 };
24
25 patches = [
26 # Replaces /bin/sh with sh, see patch file for reasoning
27 ./0001-No-impure-bin-sh.patch
28 # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
29 # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
30 # included Makefiles, don't look in /usr/include and friends.
31 ./0002-remove-impure-dirs.patch
32 ];
33in
34bash.runCommand "${pname}-${version}"
35 {
36 inherit pname version;
37
38 nativeBuildInputs = [
39 tinycc.compiler
40 gnumakeBoot
41 gnupatch
42 gnused
43 gnugrep
44 gawk
45 gnutar
46 gzip
47 ];
48
49 passthru.tests.get-version =
50 result:
51 bash.runCommand "${pname}-get-version-${version}" { } ''
52 ${result}/bin/make --version
53 mkdir $out
54 '';
55
56 meta = with lib; {
57 description = "Tool to control the generation of non-source files from sources";
58 homepage = "https://www.gnu.org/software/make";
59 license = licenses.gpl3Plus;
60 teams = [ teams.minimal-bootstrap ];
61 mainProgram = "make";
62 platforms = platforms.unix;
63 };
64 }
65 ''
66 # Unpack
67 tar xzf ${src}
68 cd make-${version}
69
70 # Patch
71 ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
72
73 # Configure
74 export CC="tcc -B ${tinycc.libs}/lib"
75 export LD=tcc
76 bash ./configure \
77 --prefix=$out \
78 --build=${buildPlatform.config} \
79 --host=${hostPlatform.config}
80
81 # Build
82 make AR="tcc -ar"
83
84 # Install
85 make install
86 ''