Skip to content

Commit

Permalink
[polymake] preliminary builder for x86_64 linux and mac os
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Jul 15, 2020
1 parent 36527b1 commit 46a9e74
Show file tree
Hide file tree
Showing 10 changed files with 1,029 additions and 1 deletion.
2 changes: 1 addition & 1 deletion L/libpolymake_julia/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using BinaryBuilder
import Pkg: PackageSpec

const name = "libpolymake_julia"
const version = v"0.0.3"
const version = v"0.0.4"

# Collection of sources required to build libpolymake_julia
const sources = [
Expand Down
143 changes: 143 additions & 0 deletions P/polymake/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, Pkg

name = "polymake"
version = v"4.1.3"

# Collection of sources required to build polymake
sources = [
GitSource("https://github.com/polymake/polymake.git", "8704ebbba9f8cc2b07f824a283ffed49a8c036be")
DirectorySource("./bundled")
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/polymake
perl_version=5.30.3
mkdir -p ${prefix}/deps
for dir in Perl boost GMP MPFR cddlib lrslib bliss PPL FLINT normaliz; do
ln -s .. ${prefix}/deps/${dir}_jll
done
atomic_patch -p1 ../patches/relocatable.patch
if [[ $target == *darwin* ]]; then
# we cannot run configure and instead provide config files
mkdir -p build/Opt
mkdir -p build/perlx/$perl_version/apple-darwin14
cp ../config/config-$target.ninja build/config.ninja
cp ../config/build-Opt-$target.ninja build/Opt/build.ninja
cp ../config/targets.ninja build/targets.ninja
ln -s ../config.ninja build/Opt/config.ninja
cp ../config/perlx-config-$target.ninja build/perlx/$perl_version/apple-darwin14/config.ninja
# for a modified pure perl JSON module and to make miniperl find the correct modules
export PERL5LIB=$prefix/lib/perl5/$perl_version:$prefix/lib/perl5/$perl_version/darwin-2level:$WORKSPACE/srcdir/patches
atomic_patch -p1 ../patches/polymake-cross.patch
atomic_patch -p1 ../patches/polymake-cross-build.patch
else
./configure CFLAGS="-Wno-error" CC="$CC" CXX="$CXX" \
PERL=${prefix}/deps/Perl_jll/bin/perl LDFLAGS="$LDFLAGS" \
--prefix=${prefix} \
--with-boost=${prefix}/deps/boost_jll \
--with-gmp=${prefix}/deps/GMP_jll \
--with-mpfr=${prefix}/deps/MPFR_jll \
--with-cdd=${prefix}/deps/cddlib_jll \
--with-lrs=${prefix}/deps/lrslib_jll \
--with-bliss=${prefix}/deps/bliss_jll \
--with-ppl=${prefix}/deps/PPL_jll \
--with-flint=${prefix}/deps/FLINT_jll \
--with-libnormaliz=${prefix}/deps/normaliz_jll \
--without-singular \
--without-native
fi
ninja -v -C build/Opt -j8
# $(( nproc / 2 ))
ninja -v -C build/Opt install
# undo patch needed for building
if [[ $target == *darwin* ]]; then
atomic_patch -R -p1 ../patches/polymake-cross-build.patch
fi
install -m 444 -D support/*.pl $prefix/share/polymake/support/
# replace miniperl
sed -i -e "s/miniperl-for-build/perl/" ${libdir}/polymake/config.ninja ${bindir}/polymake*
# replace binary path with env
sed -i -e "s#$bindir/perl#/usr/bin/env perl#g" ${libdir}/polymake/config.ninja ${bindir}/polymake*
# remove target and sysroot
sed -i -e "s#--sysroot[ =]\S\+##g" ${libdir}/polymake/config.ninja
sed -i -e "s#-target[ =]\S\+##g" ${libdir}/polymake/config.ninja
sed -e "s#${prefix}#\${prefix}#g" ${libdir}/polymake/config.ninja > ${libdir}/polymake/config-reloc.ninja
# cleanup
rm -rf ${prefix}/deps
install_license COPYING
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = [
MacOS(:x86_64, compiler_abi=CompilerABI(cxxstring_abi=:cxx11)),
Linux(:x86_64, libc=:glibc, compiler_abi=CompilerABI(cxxstring_abi=:cxx11)),
]

# The products that we will ensure are always built
products = [
LibraryProduct("libpolymake", :libpolymake; dont_dlopen=true)
LibraryProduct("libpolymake-apps-rt", :libpolymake_apps_rt; dont_dlopen=true)
ExecutableProduct("polymake", :polymake)
ExecutableProduct("polymake-config", Symbol("polymake_config"))
]

# Dependencies that must be installed before this package can be built
dependencies = [
Dependency(PackageSpec(name="Perl_jll", uuid="83958c19-0796-5285-893e-a1267f8ec499", version=v"5.30.3"))
Dependency("GMP_jll")
Dependency("MPFR_jll")
Dependency("boost_jll")
Dependency("CompilerSupportLibraries_jll")
Dependency("lrslib_jll")
Dependency("PPL_jll")
Dependency("cddlib_jll")
Dependency("bliss_jll")
Dependency(PackageSpec(name="FLINT_jll", uuid="e134572f-a0d5-539d-bddf-3cad8db41a82",version=v"2.6.0"))
Dependency("normaliz_jll")
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"7", init_block="""
mutable_artifacts_toml = joinpath(dirname(@__DIR__), "MutableArtifacts.toml")
polymake_tree = "polymake_tree"
polymake_tree_hash = artifact_hash(polymake_tree, mutable_artifacts_toml)
if polymake_tree_hash != nothing
unbind_artifact!(mutable_artifacts_toml,polymake_tree)
end
# create a partial polymake tree with links to dependencies
polymake_tree_hash = create_artifact() do art_dir
mkpath(joinpath(art_dir,"deps"))
# maybe we need more?
for dep in [GMP_jll, MPFR_jll, FLINT_jll, boost_jll, lrslib_jll, cddlib_jll, normaliz_jll, bliss_jll, Perl_jll, PPL_jll]
symlink(dep.artifact_dir, joinpath(art_dir,"deps","\$dep"))
end
for dir in readdir(polymake_jll.artifact_dir)
symlink(joinpath(polymake_jll.artifact_dir,dir), joinpath(art_dir,dir))
end
end
bind_artifact!(mutable_artifacts_toml,
polymake_tree,
polymake_tree_hash;
force=true
)
# Point polymake to our custom tree
ENV["POLYMAKE_DEPS_TREE"] = artifact_path(polymake_tree_hash)
""")

18 changes: 18 additions & 0 deletions P/polymake/bundled/config/build-Opt-x86_64-apple-darwin14.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
builddir=/workspace/srcdir/polymake/build
buildmode=Opt
buildtop=${builddir}/${buildmode}
config.file=${builddir}/config.ninja
include ${config.file}
perlxpath=perlx/5.30.3/apple-darwin14
include ${builddir}/${perlxpath}/config.ninja
include ${root}/support/rules.ninja
CmodeFLAGS=${COptFLAGS}
CexternModeFLAGS=${CexternOptFLAGS}
CmodeCACHE=${COptCACHE}
LDmodeFLAGS=${LDOptFLAGS}

include ${builddir}/targets.ninja

# should rerun the target generation if any of the included files changes
build build.ninja: phony | ${config.file} ${builddir}/targets.ninja

66 changes: 66 additions & 0 deletions P/polymake/bundled/config/config-x86_64-apple-darwin14.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# last configured with:
configure.command=/workspace/srcdir/polymake/configure CXX=clang++ --with-libcxx --with-lrs-include=/workspace/destdir/include/lrslib
root=/workspace/srcdir/polymake
core.includes=-I${root}/include/core-wrappers -I${root}/include/core
app.includes=-I${root}/include/app-wrappers -I${root}/include/apps -I${root}/include/external/permlib -I${root}/include/external/TOSimplex

CC = clang -target x86_64-apple-darwin14 --sysroot /opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root
CXX = clang++ -target x86_64-apple-darwin14 --sysroot /opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root
CFLAGS = -mmacosx-version-min=10.8 -I/workspace/destdir/deps/GMP_jll/include -I/workspace/destdir/deps/MPFR_jll/include
CXXFLAGS = -stdlib=libc++ -std=c++14 -mmacosx-version-min=10.8 -I/workspace/destdir/deps/GMP_jll/include -I/workspace/destdir/deps/MPFR_jll/include -I/workspace/destdir/deps/boost_jll/include -I/workspace/destdir/deps/FLINT_jll/include -DPOLYMAKE_WITH_FLINT
ARCHFLAGS =
CsharedFLAGS = -fPIC -pipe
CXXOPT = -O3
CXXDEBUG = -g
CXXCOV = --coverage -O1
CXXSANITIZE = -fno-omit-frame-pointer -O1 -g
CflagsSuppressWarnings =
CLANGversion = 4.0
CPPStd = 201402
XcodeVersion = 9.1.0
LDFLAGS = -mmacosx-version-min=10.8 -L/workspace/destdir/deps/GMP_jll/lib -Wl,-rpath,/workspace/destdir/deps/GMP_jll/lib -L/workspace/destdir/deps/MPFR_jll/lib -Wl,-rpath,/workspace/destdir/deps/MPFR_jll/lib -L/workspace/destdir/deps/FLINT_jll/lib -Wl,-rpath,/workspace/destdir/deps/FLINT_jll/lib -stdlib=libc++
LDsharedFLAGS = -mmacosx-version-min=10.8 -L/workspace/destdir/lib -Wl,-rpath,/workspace/destdir/lib -dynamiclib -undefined dynamic_lookup -fstack-protector-strong
LDcallableFLAGS = -mmacosx-version-min=10.8 -L/workspace/destdir/lib -Wl,-rpath,/workspace/destdir/lib -dynamiclib -undefined dynamic_lookup -fstack-protector-strong -mmacosx-version-min=10.8 -fstack-protector-strong
LDsonameFLAGS = -install_name /workspace/destdir/lib/
LIBS = -lc++ -lflint -lmpfr -lgmp -lpthread
ExternalHeaders = permlib TOSimplex
Arch = darwin.x86_64
BundledExts = cdd atint bliss flint libnormaliz lrs ppl sympol
BuildModes = Opt Debug
InstallTop = /workspace/destdir/share/polymake
InstallArch = /workspace/destdir/lib/polymake
InstallBin = /workspace/destdir/bin
InstallInc = /workspace/destdir/include
InstallLib = /workspace/destdir/lib
InstallDoc = /workspace/destdir/share/polymake/doc
AR = ar
GMP.version = 6.1.2
MPFR.version = 4.0.2
bundled.atint.RequireExtensions=cdd
bundled.bliss.CXXFLAGS = -I/workspace/destdir/deps/bliss_jll/include
bundled.bliss.LDFLAGS = -L/workspace/destdir/deps/bliss_jll/lib -Wl,-rpath,/workspace/destdir/deps/bliss_jll/lib
bundled.bliss.LIBS = -lbliss
bundled.bliss.RequireExtensions=
bundled.cdd.UseBundled = 0
bundled.cdd.CFLAGS = -I/workspace/destdir/deps/cddlib_jll/include/cddlib
bundled.cdd.LDFLAGS = -L/workspace/destdir/deps/cddlib_jll/lib -Wl,-rpath,/workspace/destdir/deps/cddlib_jll/lib
bundled.cdd.LIBS = -lcddgmp
bundled.cdd.RequireExtensions=
bundled.flint.RequireExtensions=
bundled.libnormaliz.UseBundled = 0
bundled.libnormaliz.CXXFLAGS = -I/workspace/destdir/deps/normaliz_jll/include
bundled.libnormaliz.LDFLAGS = -L/workspace/destdir/deps/normaliz_jll/lib -Wl,-rpath,/workspace/destdir/deps/normaliz_jll/lib
bundled.libnormaliz.LIBS = -lnormaliz -lflint -lgmpxx
bundled.libnormaliz.RequireExtensions=
bundled.lrs.UseBundled = 0
bundled.lrs.CFLAGS = -DHAVE_LRSDRIVER -I/workspace/destdir/deps/lrslib_jll/include/lrslib
bundled.lrs.LDFLAGS = -L/workspace/destdir/deps/lrslib_jll/lib -Wl,-rpath,/workspace/destdir/deps/lrslib_jll/lib
bundled.lrs.LIBS = -llrs
bundled.lrs.RequireExtensions=
bundled.ppl.CXXFLAGS = -I/workspace/destdir/deps/PPL_jll/include -Wno-class-memaccess
bundled.ppl.LDFLAGS = -L/workspace/destdir/deps/PPL_jll/lib -Wl,-rpath,/workspace/destdir/deps/PPL_jll/lib
bundled.ppl.LIBS = -lppl
bundled.ppl.RequireExtensions=
bundled.sympol.UseBundled = 1
bundled.sympol.CXXFLAGS = -I${root}/bundled/sympol/external/sympol -DPOLYMAKE_WITH_PPL
bundled.sympol.RequireExtensions=lrs cdd ppl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PERL=/workspace/destdir/deps/Perl_jll/bin/miniperl-for-build
CXXglueFLAGS=-I/workspace/destdir/deps/Perl_jll/lib/perl5/5.30.3/darwin-2level/CORE -fno-common -DPERL_DARWIN -mmacosx-version-min=10.8 -fno-strict-aliasing -pipe -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -I/workspace/destdir/deps/Perl_jll/include -DPerlVersion=5303 -Wno-nonnull
LIBperlFLAGS=-L/workspace/destdir/deps/Perl_jll/lib/perl5/5.30.3/darwin-2level/CORE -lperl
ExtUtils_xsubpp=/workspace/destdir/deps/Perl_jll/lib/perl5/5.30.3/ExtUtils/xsubpp
ExtUtils_typemap=/workspace/destdir/deps/Perl_jll/lib/perl5/5.30.3/ExtUtils/typemap
2 changes: 2 additions & 0 deletions P/polymake/bundled/config/targets.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build all: phony
build install: phony
Loading

0 comments on commit 46a9e74

Please sign in to comment.