1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
{
lib,
stdenvNoCC,
stdenv,
fetchNetBSD,
bsdSetupHook,
netbsdSetupHook,
makeMinimal,
install,
tsort,
lorder,
mandoc,
groff,
statHook,
rsync,
compatIfNeeded,
defaultMakeFlags,
}:
lib.makeOverridable (
attrs:
let
stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
in
stdenv'.mkDerivation (
{
pname = "${attrs.pname or (baseNameOf attrs.path)}-netbsd";
inherit (attrs) version;
src = fetchNetBSD attrs.path attrs.version attrs.sha256;
extraPaths = [ ];
nativeBuildInputs = [
bsdSetupHook
netbsdSetupHook
makeMinimal
install
tsort
lorder
mandoc
groff
statHook
rsync
];
buildInputs = compatIfNeeded;
HOST_SH = stdenv'.shell;
MACHINE_ARCH =
{
i486 = "i386";
i586 = "i386";
i686 = "i386";
}
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
MACHINE =
{
x86_64 = "amd64";
aarch64 = "evbarm64";
i486 = "i386";
i586 = "i386";
i686 = "i386";
}
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
COMPONENT_PATH = attrs.path;
makeFlags = defaultMakeFlags;
strictDeps = true;
meta = with lib; {
maintainers = with maintainers; [
matthewbauer
qyliss
];
platforms = platforms.unix;
license = licenses.bsd2;
};
}
// lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp";
}
// lib.optionalAttrs stdenv'.isDarwin { MKRELRO = "no"; }
// lib.optionalAttrs (stdenv'.cc.isClang or false) {
HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
}
// lib.optionalAttrs (stdenv'.cc.isGNU or false) {
HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
}
// lib.optionalAttrs (stdenv'.isx86_32) { USE_SSP = "no"; }
// lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase";
dontBuild = true;
}
// attrs
// {
# Files that use NetBSD-specific macros need to have nbtool_config.h
# included ahead of them on non-NetBSD platforms.
postPatch =
lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
set +e
grep -Zlr "^__RCSID
^__BEGIN_DECLS" $COMPONENT_PATH | xargs -0r grep -FLZ nbtool_config.h |
xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
set -e
''
+ attrs.postPatch or "";
}
)
)
|