|
| 1 | +using BinDeps |
| 2 | +using Libdl |
| 3 | + |
| 4 | +@BinDeps.setup |
| 5 | + |
| 6 | +lrslib_commit = "5b8ab79d3b3a40f128083da3935523cb254d3460" |
| 7 | +#lrsname = "lrslib-061" |
| 8 | +lrsname = "lrslib-$lrslib_commit" |
| 9 | +lrsnashname = "lrsnashlib-$lrslib_commit" |
| 10 | +lrslibname = "liblrs" |
| 11 | + |
| 12 | +# julia installs libgmp10 but not libgmp-dev since it |
| 13 | +# does not have to compile C program with GMP, |
| 14 | +# e.g. it does not need the headers. |
| 15 | +# FIXME BinDeps doesn't work with header, it only works for libraries because it checks for the .so |
| 16 | +# It sees libgmp.so (installed by libgmp10 as a julia dependency) and thinks that it's ok but |
| 17 | +# it does not have the headers |
| 18 | +#libgmpdev = library_dependency("libgmp-dev", aliases=["libgmp"]) |
| 19 | +liblrs = library_dependency("liblrs", aliases=[lrsname, "liblrsgmp"])#, depends=[libgmpdev]) |
| 20 | +liblrsnash = library_dependency("liblrsnash", aliases=[lrsnashname, "liblrsnashgmp"]) |
| 21 | + |
| 22 | +official_repo = "http://cgm.cs.mcgill.ca/~avis/C/lrslib/archive/$lrsname.tar.gz" |
| 23 | +forked_repo = "https://github.com/JuliaPolyhedra/lrslib/archive/$lrslib_commit.zip" |
| 24 | + |
| 25 | +#GMP |
| 26 | +@static if Sys.islinux() |
| 27 | + const has_apt = try success(`apt-get -v`) catch e false end |
| 28 | + const has_yum = try success(`yum --version`) catch e false end |
| 29 | + const has_pacman = try success(`pacman -Qq`) catch e false end |
| 30 | + if has_apt || has_yum |
| 31 | + if has_apt |
| 32 | + pkgname = "libgmp-dev" |
| 33 | + pkgman = "apt-get" |
| 34 | + else |
| 35 | + pkgname = "libgmp-devel or gmp-devel" |
| 36 | + pkgman = "yum" |
| 37 | + end |
| 38 | + |
| 39 | + println("Warning: The compilation of LRS requires the header gmp.h provided by the package $pkgname.") |
| 40 | + println("If the compilation fails, please install it as follows:") |
| 41 | + println("\$ sudo $pkgman install $pkgname") |
| 42 | + end |
| 43 | +end |
| 44 | + |
| 45 | +#LRS |
| 46 | +provides(Sources, |
| 47 | + Dict(URI(forked_repo) => liblrs), unpacked_dir="$lrsname") |
| 48 | + |
| 49 | +lrssrcdir = joinpath(BinDeps.srcdir(liblrs), lrsname) |
| 50 | +lrsprefixdir = joinpath(BinDeps.usrdir(liblrs)) |
| 51 | +lrslibdir = joinpath(lrsprefixdir, "lib") |
| 52 | + |
| 53 | +targetdirs = AbstractString["$lrslibname.$(Libdl.dlext)"] |
| 54 | +patchdir = BinDeps.depsdir(liblrs) |
| 55 | + |
| 56 | +@static if Sys.isapple() |
| 57 | + using Homebrew |
| 58 | + Homebrew.add("gmp") |
| 59 | + homebrew_includedir = joinpath(Homebrew.brew_prefix, "include") |
| 60 | + homebrew_libdir = joinpath(Homebrew.brew_prefix, "lib") |
| 61 | + provides(BuildProcess, |
| 62 | + (@build_steps begin |
| 63 | + GetSources(liblrs) |
| 64 | + CreateDirectory(lrsprefixdir) |
| 65 | + CreateDirectory(lrslibdir) |
| 66 | + @build_steps begin |
| 67 | + ChangeDirectory(lrssrcdir) |
| 68 | + FileRule(joinpath(lrslibdir,"$lrslibname.$(Libdl.dlext)"),@build_steps begin |
| 69 | + pipeline(`cat $patchdir/makefile.osx.patch`, `patch`) |
| 70 | + `make $lrslibname.$(Libdl.dlext).0 SONAME=$lrslibdir/$lrslibname.$(Libdl.dlext) SHLIB=$lrslibname.$(Libdl.dlext).0 SHLINK=$lrslibname.$(Libdl.dlext) INCLUDEDIR=$homebrew_includedir LIBDIR=$homebrew_libdir` |
| 71 | + `cp $lrslibname.$(Libdl.dlext).0 $lrslibdir/$lrslibname.$(Libdl.dlext)` |
| 72 | + end) |
| 73 | + end |
| 74 | + end),liblrs) |
| 75 | + provides(BuildProcess, |
| 76 | + (@build_steps begin |
| 77 | + ChangeDirectory(lrssrcdir) |
| 78 | + FileRule(joinpath(lrslibdir,"liblrsnash.$(Libdl.dlext)"),@build_steps begin |
| 79 | + `cp $patchdir/makefile.liblrsnash $lrssrcdir` |
| 80 | + `make -f makefile.liblrsnash SHLIB=liblrsnash.$(Libdl.dlext) LIBLRSDIR=$lrslibdir INCLUDEDIR=$homebrew_includedir LIBDIR=$homebrew_libdir` |
| 81 | + `cp liblrsnash.$(Libdl.dlext) $lrslibdir/liblrsnash.$(Libdl.dlext)` |
| 82 | + end) |
| 83 | + end),liblrsnash) |
| 84 | +else |
| 85 | + provides(BuildProcess, |
| 86 | + (@build_steps begin |
| 87 | + GetSources(liblrs) |
| 88 | + CreateDirectory(lrsprefixdir) |
| 89 | + CreateDirectory(lrslibdir) |
| 90 | + @build_steps begin |
| 91 | + ChangeDirectory(lrssrcdir) |
| 92 | + FileRule(joinpath(lrslibdir,"$lrslibname.$(Libdl.dlext)"),@build_steps begin |
| 93 | + `make $lrslibname.$(Libdl.dlext).0 SONAME=$lrslibname.$(Libdl.dlext) SHLIB=$lrslibname.$(Libdl.dlext).0` |
| 94 | + `cp $lrslibname.$(Libdl.dlext).0 $lrslibdir/$lrslibname.$(Libdl.dlext)` |
| 95 | + end) |
| 96 | + end |
| 97 | + end),liblrs) |
| 98 | + provides(BuildProcess, |
| 99 | + (@build_steps begin |
| 100 | + ChangeDirectory(lrssrcdir) |
| 101 | + FileRule(joinpath(lrslibdir,"liblrsnash.$(Libdl.dlext)"),@build_steps begin |
| 102 | + `cp $patchdir/makefile.liblrsnash $lrssrcdir` |
| 103 | + `make -f makefile.liblrsnash SHLIB=liblrsnash.$(Libdl.dlext) LIBLRSDIR=$lrslibdir` |
| 104 | + `cp liblrsnash.$(Libdl.dlext) $lrslibdir/liblrsnash.$(Libdl.dlext)` |
| 105 | + end) |
| 106 | + end),liblrsnash) |
| 107 | +end |
| 108 | + |
| 109 | +BinDeps.@install Dict([(:liblrs, :liblrs), |
| 110 | + (:liblrsnash, :liblrsnash)]) |
0 commit comments