nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, fetchurl, buildPackages
2, # "newlib-nano" is what the official ARM embedded toolchain calls this build
3 # configuration that prioritizes low space usage. We include it as a preset
4 # for embedded projects striving for a similar configuration.
5 nanoizeNewlib ? false
6}:
7
8stdenv.mkDerivation rec {
9 pname = "newlib";
10 version = "4.1.0";
11
12 src = fetchurl {
13 url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz";
14 sha256 = "0m01sjjyj0ib7bwlcrvmk1qkkgd66zf1dhbw716j490kymrf75pj";
15 };
16
17 depsBuildBuild = [ buildPackages.stdenv.cc ];
18
19 # newlib expects CC to build for build platform, not host platform
20 preConfigure = ''
21 export CC=cc
22 '';
23
24 configurePlatforms = [ "build" "target" ];
25 configureFlags = [
26 "--host=${stdenv.buildPlatform.config}"
27
28 "--disable-newlib-supplied-syscalls"
29 "--disable-nls"
30 "--enable-newlib-retargetable-locking"
31 ] ++ (if !nanoizeNewlib then [
32 "--enable-newlib-io-long-long"
33 "--enable-newlib-register-fini"
34 ] else [
35 "--enable-newlib-reent-small"
36 "--disable-newlib-fvwrite-in-streamio"
37 "--disable-newlib-fseek-optimization"
38 "--disable-newlib-wide-orient"
39 "--enable-newlib-nano-malloc"
40 "--disable-newlib-unbuf-stream-opt"
41 "--enable-lite-exit"
42 "--enable-newlib-global-atexit"
43 "--enable-newlib-nano-formatted-io"
44 ]);
45
46 dontDisableStatic = true;
47
48 passthru = {
49 incdir = "/${stdenv.targetPlatform.config}/include";
50 libdir = "/${stdenv.targetPlatform.config}/lib";
51 };
52}