diff --git a/math/polymake/Makefile b/math/polymake/Makefile index 097714d1f003..e88745e92d98 100644 --- a/math/polymake/Makefile +++ b/math/polymake/Makefile @@ -1,196 +1,200 @@ # Created by: Ewgenij Gawrilow PORTNAME= polymake DISTVERSION= 4.4 +PORTREVISION= 1 CATEGORIES= math MASTER_SITES= https://polymake.org/lib/exe/fetch.php/download/ DISTNAME= ${PORTNAME}-${DISTVERSION}-minimal MAINTAINER= bsd@philippost.de COMMENT= Software package for research in polyhedral geometry LICENSE= GPLv2+ LICENSE_FILE= ${WRKSRC}/COPYING BUILD_DEPENDS= boost-libs>=1.72:devel/boost-libs \ ninja:devel/ninja \ permlib>=0.2.9:math/permlib \ p5-XML-SAX>=1.02:textproc/p5-XML-SAX \ p5-XML-Writer>=0.900:textproc/p5-XML-Writer \ p5-Term-ReadLine-Gnu>=1.37:devel/p5-Term-ReadLine-Gnu \ p5-Term-ReadKey>=2.38:devel/p5-Term-ReadKey \ p5-JSON>=2.97:converters/p5-JSON LIB_DEPENDS= libcddgmp.so:math/cddlib \ libflint.so:math/flint2 \ libgmpxx.so:math/gmp \ libmpfr.so:math/mpfr RUN_DEPENDS= bash>=5.0:shells/bash \ boost-libs>=1.72:devel/boost-libs \ permlib>=0.2.9:math/permlib \ p5-XML-SAX>=1.02:textproc/p5-XML-SAX \ p5-XML-Writer>=0.900:textproc/p5-XML-Writer \ p5-Term-ReadLine-Gnu>=1.37:devel/p5-Term-ReadLine-Gnu \ p5-Term-ReadKey>=2.38:devel/p5-Term-ReadKey \ p5-JSON>=2.97:converters/p5-JSON USES= compiler:c++14-lang gmake gnome perl5 readline shebangfix \ tar:bzip2 USE_GNOME= libxml2 libxslt USE_LDCONFIG= ${PREFIX}/lib USE_PERL5= build run SHEBANG_FILES= resources/host-agent/bin/env resources/host-agent/bin/polymake SHEBANG_GLOB= *.pl *.sh # polymake's configure script expects options to be disabled by --without-option # and most options to be enabled by --with-option=DIR HAS_CONFIGURE= yes CONFIGURE_ARGS= --prefix=${PREFIX} \ --exec-prefix=${PREFIX} \ --bindir=${PREFIX}/bin \ --includedir=${PREFIX}/include \ --libdir=${PREFIX}/lib \ --libexecdir=${PREFIX}/libexec/polymake \ --datadir=${PREFIX}/share/polymake \ --docdir=${DOCSDIR} \ --without-prereq \ --with-libcxx \ --with-cdd=${LOCALBASE} \ --with-flint=${LOCALBASE} \ --with-permlib=${LOCALBASE}/lib \ --without-java \ --without-javaview \ --without-sympol CONFIGURE_LOG= build/bundled.log # Optional features; SoPlex defaults to off due to licencsing and SCIP defaults # to off due to a dependency on libsoplex.so. OPTIONS_DEFINE= LRS NATIVE NORMALIZ OPENMP PPL SCIP SINGULAR SOPLEX TESTS OPTIONS_DEFAULT= BLISS LRS NORMALIZ OPENMP PPL SINGULAR # Exlude lrslib on i386 and powerpc because it is marked BROKEN for those # architectures OPTIONS_EXCLUDE_i386= LRS OPTIONS_EXCLUDE_powerpc= LRS OPTIONS_SUB= yes # polymake needs either math/bliss or math/nauty to compute graph automorphism # groups OPTIONS_SINGLE= GRAPH OPTIONS_SINGLE_GRAPH= BLISS NAUTY BLISS_DESC= Compute graph automorphism groups using bliss GRAPH_DESC= Graph automorphism groups LRS_DESC= Convex hull computation and vertex enumeration NATIVE_DESC= Build with native optimizations (-march=native) NAUTY_DESC= Compute graph automorphism groups using nauty NORMALIZ_DESC= Computations in affine monoids and lattice polytopes PPL_DESC= Manipulation of convex polyhedra SCIP_DESC= Solver for mixed integer linear and nonlinear problems SINGULAR_DESC= Computation of Groebner bases SOPLEX_DESC= Solver for linear programming problems TESTS_DESC= Run bundled self tests after build BLISS_CONFIGURE_ON= --with-bliss=${LOCALBASE} BLISS_CONFIGURE_OFF= --without-bliss BLISS_BUILD_DEPENDS= bliss-graph-tool>=0.73:math/bliss BLISS_RUN_DEPENDS= bliss-graph-tool>=0.73:math/bliss -NAUTY_WRKSRC= ${:!${MAKE} -V WRKSRC -C ${.CURDIR:H:H}/math/nauty!} -NAUTY_CONFIGURE_ON= --with-nauty-src=${NAUTY_WRKSRC} -NAUTY_BUILD_DEPENDS= ${NONEXISTENT}:math/nauty:patch -NAUTY_RUN_DEPENDS= nauty>=27:math/nauty -# Do not explicitly disable nauty. polymake's configure script currently fails -# if a reconfiguration is triggered. However, it is aware that bliss and nauty -# are mutually exclusive and disables nauty if BLISS=on. -#NAUTY_CONFIGURE_OFF= --without-nauty +NAUTY_CONFIGURE_ON= --with-nauty=${LOCALBASE} +NAUTY_CONFIGURE_OFF= --without-nauty +NAUTY_LIB_DEPENDS= libnauty.so:math/nauty LRS_CONFIGURE_ON= --with-lrs=${LOCALBASE} \ --with-lrs-include=${LOCALBASE}/include/lrslib LRS_CONFIGURE_OFF= --without-lrs LRS_LIB_DEPENDS= liblrs.so:math/lrslib NATIVE_CONFIGURE_OFF= --without-native NORMALIZ_CONFIGURE_ON= --with-libnormaliz=${LOCALBASE} NORMALIZ_CONFIGURE_OFF= --without-libnormaliz NORMALIZ_LIB_DEPENDS= libnormaliz.so:math/libnormaliz OPENMP_USES= compiler:openmp OPENMP_CONFIGURE_OFF= --without-openmp PPL_CONFIGURE_ON= --with-ppl=${LOCALBASE} PPL_CONFIGURE_OFF= --without-ppl PPL_LIB_DEPENDS= libppl.so:devel/ppl SCIP_CONFIGURE_ON= --with-scip=${LOCALBASE} SCIP_CONFIGURE_OFF= --without-scip SCIP_LIB_DEPENDS= libscip.so:math/SCIP SINGULAR_CONFIGURE_ON= --with-singular=${LOCALBASE} SINGULAR_CONFIGURE_OFF= --without-singular SINGULAR_LIB_DEPENDS= libSingular.so:math/singular SOPLEX_CONFIGURE_ON= --with-soplex=${LOCALBASE} SOPLEX_CONFIGURE_OFF= --without-soplex SOPLEX_LIB_DEPENDS= libsoplex-pic.so:math/SoPlex TESTS_VARS= USE_PERL5+=test # The port uses the minimal distribution tarball without bundled libraries. # Set WRKSRC accordingly. WRKSRC= ${WRKDIR}/${PORTNAME}-${DISTVERSION} +.include + # Deal with site specific installation directory # polymake installs a perlxs module which depends on the perl configuration PERL_ARCHNAME= ${:!${PERL} -E 'use Config; print "\$Config::Config{archname}";'!} PLIST_FILES= libexec/polymake/perlx/${PERL_VERSION}/${PERL_ARCHNAME}/auto/Polymake/Ext/Ext.so # Keep track of the major version DISTVERSION_MAJ= ${:!expr ${DISTVERSION} : '\([0-9]*\).*'!} post-install: ${RLN} ${STAGEDIR}${PREFIX}/lib/libpolymake.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/lib/libpolymake.so.${DISTVERSION_MAJ} ${RLN} ${STAGEDIR}${PREFIX}/lib/libpolymake.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/lib/libpolymake.so ${STRIP_CMD} \ ${STAGEDIR}${PREFIX}/lib/libpolymake.so.${DISTVERSION} \ .for _lp in libpolymake-apps libpolymake-apps-rt ${RLN} ${STAGEDIR}${PREFIX}/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/lib/${_lp}.so.${DISTVERSION_MAJ} ${RLN} ${STAGEDIR}${PREFIX}/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/lib/${_lp}.so ${RLN} ${STAGEDIR}${PREFIX}/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so.${DISTVERSION_MAJ} ${RLN} ${STAGEDIR}${PREFIX}/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so ${RLN} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so.${DISTVERSION_MAJ} ${RLN} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so.${DISTVERSION} \ ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so # strip the libraries ${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${_lp}.so.${DISTVERSION} .endfor ${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/polymake/perlx/${PERL_VERSION}/${PERL_ARCHNAME}/auto/Polymake/Ext/Ext.so -.for l in common fan fulton graph group ideal matroid polytope topaz tropical +.for l in common fan fulton graph group matroid polytope topaz tropical ${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${l}.so .endfor +# only strip libexec/polymake/lib/ideal.so iff SINGULAR=on, if SINGULAR=off it +# is an empty file and stripping fails +.if ${PORT_OPTIONS:MSINGULAR} + ${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/ideal.so +.endif + .for lp in libpolymake-apps libpolymake-apps-rt ${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/polymake/lib/${lp}.so.${DISTVERSION} .endfor post-install-TESTS-on: test # Set HOME=${WRKDIR} to prevent polymake writing its .polymake directory outside # WRKDIR. test: @cd ${WRKSRC} && HOME=${WRKDIR} perl/polymake --script run_testcases .include diff --git a/math/polymake/files/patch-libnauty b/math/polymake/files/patch-libnauty new file mode 100644 index 000000000000..77eaf347b801 --- /dev/null +++ b/math/polymake/files/patch-libnauty @@ -0,0 +1,212 @@ +- patch from the upstream allowing to link to libnauty.so: https://github.com/polymake/polymake/issues/10#issuecomment-906184045 + +commit 3d5f15812247c37e1821d30a24e69acc308bc54b +Author: Benjamin Lorenz +Date: Tue Aug 24 21:20:40 2021 +0200 + + bundled/nauty: add support for libnauty installation to configuration + + in addition to bundled and source-dir + + without any options this will try to run a test-program and fall back + to the bundled nauty if that fails. + +diff --git bundled/nauty/apps/graph/src/GraphIso.cc bundled/nauty/apps/graph/src/GraphIso.cc +index 26779977ff..26a0b689bf 100644 +--- bundled/nauty/apps/graph/src/GraphIso.cc ++++ bundled/nauty/apps/graph/src/GraphIso.cc +@@ -29,8 +29,8 @@ + #define set nauty_set + #define permutation nauty_permutation + +-#include +-#include ++#include ++#include + #include + + namespace { +diff --git bundled/nauty/apps/graph/src/build_flags.pl bundled/nauty/apps/graph/src/build_flags.pl +index 1b6fac03e2..9efd0a0cd0 100644 +--- bundled/nauty/apps/graph/src/build_flags.pl ++++ bundled/nauty/apps/graph/src/build_flags.pl +@@ -1,6 +1,6 @@ + # input for generate_ninja_targets.pl + +-my $foreign_src = $ConfigFlags{'bundled.nauty.NautySrc'}; ++my $foreign_src = $ConfigFlags{'bundled.nauty.NautySrc'} ne "bundled" && $ConfigFlags{'bundled.nauty.NautySrc'}; + my $nauty_src = $foreign_src ? '${bundled.nauty.NautySrc}' : '${root}/bundled/nauty/external/nauty'; + my $generated_dir = '${buildroot}/staticlib/nauty'; + my @generated_headers = qw( nauty.h naututil.h gtools.h ); +@@ -9,17 +9,21 @@ my @generated_out = map { "$generated_dir/$_" } @generated_headers; + my $include_generated = ($foreign_src && grep { -f "$foreign_src/$_" } @generated_headers) + ? join(" ", map { "-include $_" } @generated_out) + : "-I$generated_dir"; ++my $nauty_inc = $ConfigFlags{'bundled.nauty.NautySrc'} ++ ? " -I$generated_dir -I$nauty_src" ++ : ""; + +-( CXXFLAGS => "-DBIGNAUTY -I$generated_dir -I$nauty_src", ++( 'GraphIso.cc' => $nauty_inc, + +- GENERATED => { +- out => "@generated_out", in => "@generated_in", +- command => "cd $generated_dir; CC=\"\${CC}\" CFLAGS=\"\${CFLAGS}\" $nauty_src/configure --quiet >/dev/null 2>/dev/null; rm -f makefile", +- }, +- +- staticlib => { +- SOURCEDIR => $nauty_src, +- SOURCES => [ qw(naugraph.c naurng.c nausparse.c nautaux.c nautil.c nautinv.c naututil.c nauty.c rng.c schreier.c) ], +- CFLAGS => "-DBIGNAUTY $include_generated -I$nauty_src", +- } ++ $ConfigFlags{'bundled.nauty.NautySrc'} ++ ? ( GENERATED => { ++ out => "@generated_out", in => "@generated_in", ++ command => "cd $generated_dir; CC=\"\${CC}\" CFLAGS=\"\${CFLAGS}\" $nauty_src/configure --quiet >/dev/null 2>/dev/null; rm -rf makefile nauty; ln -s . nauty", ++ }, ++ staticlib => { ++ SOURCEDIR => $nauty_src, ++ SOURCES => [ qw(naugraph.c naurng.c nausparse.c nautaux.c nautil.c nautinv.c naututil.c nauty.c rng.c schreier.c) ], ++ CFLAGS => "$include_generated -I$nauty_src", ++ } ) ++ : () + ) +diff --git bundled/nauty/support/configure.pl bundled/nauty/support/configure.pl +index 73ac8c2b22..e8b9eec126 100644 +--- bundled/nauty/support/configure.pl ++++ bundled/nauty/support/configure.pl +@@ -14,19 +14,19 @@ + # GNU General Public License for more details. + #------------------------------------------------------------------------------- + +-@conf_vars=qw( NautySrc ); ++@conf_vars=qw( NautySrc CXXFLAGS LDFLAGS LIBS ); + + sub allowed_options { + my ($allowed_options, $allowed_with)=@_; +- @$allowed_with{ qw( nauty-src ) }=(); ++ @$allowed_with{ qw( nauty-src nauty ) }=(); + } + + + sub usage { +- print STDERR " --with-nauty-src=PATH Source directory of nauty.\n", +- " By default polymake will use the bundled nauty source files,\n", +- " for the minimal tarball this option allows using a custom\n", +- " directory containing the nauty sources.\n"; ++ print STDERR " By default polymake will use the bundled nauty source files,\n", ++ " these options allow using a custom nauty source or installation:\n", ++ " --with-nauty-src=PATH Source directory of nauty.\n", ++ " --with-nauty=PATH Installation prefix of nauty.\n"; + } + + sub check_nauty { +@@ -36,17 +36,100 @@ sub check_nauty { + + sub proceed { + my ($options)=@_; +- my $nautysrc; +- if (defined ($nautysrc=$options->{"nauty-src"})) { +- check_nauty($nautysrc) or +- die "Specified nauty source directory invalid, could not find 'nauty-h.in'."; +- $NautySrc = $nautysrc; +- } elsif (!check_nauty()) { ++ my $nauty_path; ++ my $nauty_src; ++ my $nautyver; ++ $NautySrc = "bundled"; ++ if (defined ($nauty_path=$options->{nauty}) && $nauty_path ne "bundled") { ++ my $nauty_inc="$nauty_path/include"; ++ my $nauty_lib=Polymake::Configure::get_libdir($nauty_path, "nauty"); ++ unless (-f "$nauty_inc/nauty/nauty.h" ++ && ( -f "$nauty_lib/libnauty.$Config::Config{dlext}" ++ || -f "$nauty_lib/libnauty.a" ) ) { ++ die "Invalid installation location of nauty library: header file nauty/nauty.h and/or library libnauty.$Config::Config{dlext} / libnauty.a not found\n"; ++ } ++ $LDFLAGS.=" -Wl,-rpath,$nauty_lib" ++ if $nauty_path !~ m|^/usr$| && -f "$nauty_lib/libnauty.$Config::Config{dlext}"; ++ $CXXFLAGS = "-I$nauty_inc"; ++ $LDFLAGS = "-L$nauty_lib"; ++ undef $NautySrc; ++ } elsif (defined ($nauty_src=$options->{"nauty-src"}) && $nauty_src ne "bundled") { ++ check_nauty($nauty_src) or ++ die "Specified nauty source directory invalid, could not find 'nauty-h.in' in $nauty_src."; ++ $NautySrc = "$nauty_src"; ++ } ++ ++ if (!$nauty_src && $nauty_path ne "bundled" && $options->{prereq} ne ".none.") { ++ # compile test-program, soft-fail ++ my $testcode = <<'---'; ++// simplified example from nautyex1.c from the nauty source ++ ++#define MAXN 1000 /* Define this before including nauty.h */ ++#include ++#include ++ ++int ++main(int argc, char *argv[]) ++{ ++ graph g[MAXN*MAXM]; ++ int lab[MAXN],ptn[MAXN],orbits[MAXN]; ++ static DEFAULTOPTIONS_GRAPH(options); ++ statsblk stats; ++ int n = 5; ++ int m = 1; ++ int v; ++ ++ options.writeautoms = FALSE; ++ ++ /* The following optional call verifies that we are linking ++ to compatible versions of the nauty routines. */ ++ ++ nauty_check(WORDSIZE,m,n,NAUTYVERSIONID); ++ EMPTYGRAPH(g,m,n); ++ for (v = 0; v < n; ++v) ADDONEEDGE(g,v,(v+1)%n,m); ++ ++ densenauty(g,lab,ptn,orbits,&options,&stats,m,n,NULL); ++ std::cout << "VERSION " << NAUTYVERSIONID << std::endl; ++ ++ exit(0); ++} ++--- ++ my $error=Polymake::Configure::build_test_program($testcode, LIBS => "-lnauty", CXXFLAGS => "$CXXFLAGS", LDFLAGS => "$LDFLAGS"); ++ ++ if ($? == 0) { ++ my $message=Polymake::Configure::run_test_program(); ++ if ($?) { ++ check_nauty() and !defined($nauty_path) or ++ die "Could not run a test program checking for nauty library.\n", ++ "The complete error log follows:\n\n$message\n", ++ "Please investigate the reasons and fix the installation.\n"; ++ } else { ++ ($nautyver) = $message =~ /VERSION (\d+)/; ++ my $nautymin = 25000; # version*10000 ++ if ($nautyver < $nautymin) { ++ check_nauty() and !defined($nauty_path) or ++ die "Your nauty version $nautyver is too old, at least version $nautymin is required.\n"; ++ } else { ++ $LIBS = "-lnauty"; ++ undef $NautySrc; ++ } ++ } ++ } else { ++ check_nauty() and !defined($nauty_path) or ++ die "Could not compile a test program checking for nauty.\n", ++ "The most probable reasons are that the library is installed at a non-standard location,\n", ++ "is not configured to build a shared module, or missing at all.\n", ++ "The complete error log follows:\n\n$error\n", ++ "Please install the library and specify its location using --with-nauty option, if needed.\n"; ++ } ++ } ++ ++ if ($NautySrc eq "bundled" && !check_nauty()) { + die "Bundled nauty directory seems to be missing, to use the nauty interface\n", + "with the minimal tarball please specify a nauty source directory\n", +- "via --with-nauty-src=PATH."; ++ "via --with-nauty-src=PATH, or a nauty installation with --with-nauty=PATH."; + } + +- return $NautySrc ? "$NautySrc" : "bundled"; ++ return $NautySrc ? "source: $NautySrc" : ("version $nautyver @ ".($nauty_path//"system")); + } +