-
Notifications
You must be signed in to change notification settings - Fork 62
/
build-dependencies.rb
79 lines (67 loc) · 2.86 KB
/
build-dependencies.rb
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
# Copyright © 2021,2024 David Caldwell
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'fileutils'
require 'pathname'
require 'pp'
require_relative 'verbose-shell'
require_relative 'build'
class BuildDependencies
def initialize(prefix)
arm = `uname -m`.chomp == 'arm64'
kernel_version = `uname -r`.chomp
@prefix = File.expand_path(prefix)
@deps = [ # Ordered carefully so dependencies work.
{ source: "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.tar.gz", builddep: true,
extra_configure_args: [*%W"--with-internal-glib --disable-debug --disable-host-tool", "LIBS=-framework corefoundation -framework cocoa"] },
{ source: "https://gmplib.org/download/gmp/gmp-6.2.1.tar.bz2" },
{ source: "https://ftp.gnu.org/gnu/nettle/nettle-3.7.2.tar.gz",
extra_configure_args: %W"--disable-openssl" +
(arm ? %W"--build=aarch64-apple-darwin#{kernel_version}" : []) },
{ source: "https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz" },
{ source: "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.15.tar.xz",
extra_configure_args: %W"--with-included-unistring --with-included-libtasn1 --without-p11-kit",
patches: %W"patches/gnutls-fallthrough.patch" },
{ source: "https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz" }
.merge(arm ? { extra_configure_args: %W"--build=aarch64-apple-darwin#{kernel_version}" } : {}),
{ source: "https://digip.org/jansson/releases/jansson-2.13.1.tar.bz2" },
].map {|opts| Build.new(opts.merge(prefix: @prefix)) }
end
def clean
Vsh.rm_rf(@prefix)
@deps.each {|dep| dep.clean }
end
def add_to(key, val)
ENV[key] = (ENV[key]||'') == '' ? val : "#{val}:#{ENV[key]}"
end
def ensure
add_to "PATH", "#{@prefix}/bin"
add_to "PKG_CONFIG_PATH", "#{@prefix}/lib/pkgconfig"
add_to "LIBRARY_PATH", "#{@prefix}/lib"
add_to "CPATH", "#{@prefix}/include"
@deps.each {|dep|
dep.fetch()
dep.build(@prefix)
}
end
def export_sources(dir, all=false)
Vsh.mkdir_p(dir)
@deps.each {|dep|
dep.fetch
if all || !dep.builddep
Vsh.rm_f(File.join(dir, File.basename(dep.archive_path)))
Vsh.ln(dep.archive_path, dir)
end
}
end
end