1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, gprbuild-boot
6, which
7, gnat
8, xmlada
9}:
10
11stdenv.mkDerivation {
12 pname = "gprbuild";
13
14 # See ./boot.nix for an explanation of the gprbuild setupHook,
15 # our custom knowledge base entry and the situation wrt a
16 # (future) gprbuild wrapper.
17 inherit (gprbuild-boot)
18 version
19 src
20 setupHooks
21 meta
22 ;
23
24 nativeBuildInputs = [
25 gnat
26 gprbuild-boot
27 which
28 ];
29
30 propagatedBuildInputs = [
31 xmlada
32 ];
33
34 makeFlags = [
35 "ENABLE_SHARED=${if stdenv.hostPlatform.isStatic then "no" else "yes"}"
36 "PROCESSORS=$(NIX_BUILD_CORES)"
37 # confusingly, for gprbuild --target is autoconf --host
38 "TARGET=${stdenv.hostPlatform.config}"
39 "prefix=${placeholder "out"}"
40 ] ++ lib.optionals (!stdenv.hostPlatform.isStatic) [
41 "LIBRARY_TYPE=relocatable"
42 ];
43
44 # Fixes gprbuild being linked statically always
45 patches = lib.optional (!stdenv.hostPlatform.isStatic) (fetchpatch {
46 name = "gprbuild-relocatable-build.patch";
47 url = "https://aur.archlinux.org/cgit/aur.git/plain/relocatable-build.patch?h=gprbuild&id=1d4e8a5cb982e79135a0aaa3ef87654bed1fe4f0";
48 sha256 = "1r3xsp1pk9h666mm8mdravkybmd5gv2f751x2ffb1kxnwq1rwiyn";
49 });
50
51 buildFlags = [ "all" "libgpr.build" ];
52
53 installFlags = [ "all" "libgpr.install" ];
54
55 # link gprconfig_kb db from gprbuild-boot into build dir,
56 # the install process copies its contents to $out
57 preInstall = ''
58 ln -sf ${gprbuild-boot}/share/gprconfig share/gprconfig
59 '';
60
61 # no need for the install script
62 postInstall = ''
63 rm $out/doinstall
64 '';
65}