-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.jl
134 lines (119 loc) · 6.04 KB
/
build.jl
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using BinaryProvider
using BinDeps
using Compat
# BinaryBuilder artifacts for linux currently assume libgfortran.so.4
# is present, so they will not work for any source builds of Julia itself
# when a GCC version older than 7 was used. BinaryBuilder also does not
# support FreeBSD or non-glibc Linux distributions. Continue building from
# source on non-apple unices while these limitations apply.
use_BinaryProvider = Compat.Sys.isapple() || Compat.Sys.iswindows()
@BinDeps.setup
if use_BinaryProvider
# Parse some basic command-line arguments
const verbose = "--verbose" in ARGS
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))
products = Product[
LibraryProduct(prefix, String["libipopt"], :libipopt),
ExecutableProduct(prefix, "ipopt", :amplexe),
]
# Download binaries from hosted location
bin_prefix = "https://github.com/staticfloat/IpoptBuilder/releases/download/v3.12.8-9"
# Listing of files generated by BinaryBuilder:
download_info = Dict(
BinaryProvider.Linux(:aarch64, :glibc) => ("$bin_prefix/Ipopt.aarch64-linux-gnu.tar.gz", "ea4b4ed7612d3603307f9a9aaa298c558abcc1c07378bacc5eb0520477f23adf"),
BinaryProvider.Linux(:armv7l, :glibc) => ("$bin_prefix/Ipopt.arm-linux-gnueabihf.tar.gz", "23410ee354456e86294123cd641a01e6062bbc2fe9244f099bd3f06647ce3f3c"),
BinaryProvider.Linux(:i686, :glibc) => ("$bin_prefix/Ipopt.i686-linux-gnu.tar.gz", "7ddb2d3791fe7b8252c074f9bb77cd4094d2a38c9fdcc139ab392a200e17b22b"),
BinaryProvider.Windows(:i686) => ("$bin_prefix/Ipopt.i686-w64-mingw32.tar.gz", "91c2c70b1a4de58e0b3f512b28bcc88594489d64e721557385744e8994189f2e"),
BinaryProvider.MacOS() => ("$bin_prefix/Ipopt.x86_64-apple-darwin14.tar.gz", "8e979f6ac782af6836425bc60f594054cc7644dfc59fb9b0a19fb7a1e3b2ae24"),
BinaryProvider.Linux(:x86_64, :glibc) => ("$bin_prefix/Ipopt.x86_64-linux-gnu.tar.gz", "d3d8f69278905ea8cab23193cf03b49ac30837bcbfab67de377e4c58ec48de46"),
BinaryProvider.Windows(:x86_64) => ("$bin_prefix/Ipopt.x86_64-w64-mingw32.tar.gz", "d967b152449659591095458594948f74981fc0b772cbf3f333a9a24676beab80"),
)
# First, check to see if we're all satisfied
if any(!satisfied(p; verbose=verbose) for p in products)
if haskey(download_info, platform_key())
# Download and install binaries
url, tarball_hash = download_info[platform_key()]
install(url, tarball_hash; prefix=prefix, force=true, verbose=verbose)
else
# If we don't have a BinaryProvider-compatible .tar.gz to download, complain.
# Alternatively, you could attempt to install from a separate provider,
# build from source or something more even more ambitious here.
error("Your platform $(Sys.MACHINE) is not supported by this package!")
end
end
# Write out a deps.jl file that will contain mappings for our products
write_deps_file(joinpath(@__DIR__, "deps.jl"), products)
else # !use_BinaryProvider
windllname = "libipopt-1"
libipopt = library_dependency("libipopt", aliases=[windllname])
ipoptname = "Ipopt-3.12.8"
provides(Sources, URI("http://www.coin-or.org/download/source/Ipopt/$ipoptname.tgz"),
libipopt, os = :Unix)
prefix=joinpath(BinDeps.depsdir(libipopt),"usr")
patchdir=BinDeps.depsdir(libipopt)
srcdir = joinpath(BinDeps.depsdir(libipopt),"src",ipoptname)
# fpu_control flag for building on ARM
if Sys.ARCH == :arm
fpu_control = "ADD_CFLAGS=-DNO_fpu_control"
else
fpu_control = ""
end
provides(SimpleBuild,
(@build_steps begin
GetSources(libipopt)
@build_steps begin
ChangeDirectory(srcdir)
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","Blas"))
CreateDirectory("build", true)
`sed -i.backup 's/wget"/wget --no-check-certificate"/g' get.Blas`
`./get.Blas`
end
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","Blas","build"))
`../configure --prefix=$prefix --disable-shared --with-pic`
`make install`
end
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","Lapack"))
CreateDirectory("build", true)
`sed -i.backup 's/wget"/wget --no-check-certificate"/g' get.Lapack`
`./get.Lapack`
end
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","Lapack","build"))
`../configure --prefix=$prefix --disable-shared --with-pic
--with-blas="$prefix/lib/libcoinblas.a -lgfortran"`
`make install`
end
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","ASL"))
`./get.ASL`
end
@build_steps begin
ChangeDirectory(joinpath(srcdir,"ThirdParty","Mumps"))
`./get.Mumps`
end
`./configure --prefix=$prefix coin_skip_warn_cxxflags=yes
--with-blas="$prefix/lib/libcoinblas.a -lgfortran"
--with-lapack=$prefix/lib/libcoinlapack.a
$fpu_control`
`make`
`make test`
`make -j1 install`
end
end),libipopt, os = :Unix)
# Avoid Issue #62, building into /lib64 on OpenSUSE
configsite = nothing
if haskey(ENV, "CONFIG_SITE")
configsite = pop!(ENV, "CONFIG_SITE")
end
@BinDeps.install Dict(:libipopt => :libipopt)
if configsite !== nothing
ENV["CONFIG_SITE"] = configsite
end
end
# Save value of use_BinaryProvider into deps.jl as well
open(joinpath(@__DIR__, "deps.jl"), "a") do f
println(f, "use_BinaryProvider = $use_BinaryProvider")
end