From owner-dev-commits-ports-all@freebsd.org Sat Aug 28 07:41:11 2021 Return-Path: Delivered-To: dev-commits-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A69C066F9AF; Sat, 28 Aug 2021 07:41:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GxT6G6kYGz4pMs; Sat, 28 Aug 2021 07:41:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CE1FC130AF; Sat, 28 Aug 2021 07:41:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17S7fAJb080155; Sat, 28 Aug 2021 07:41:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17S7fANu080154; Sat, 28 Aug 2021 07:41:10 GMT (envelope-from git) Date: Sat, 28 Aug 2021 07:41:10 GMT Message-Id: <202108280741.17S7fANu080154@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: a8ceb6491219 - main - math/polymake: Backport patch allowing to use external Nauty library instead of Nauty source tree MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a8ceb6491219baa95155e2b55a1ba5b1654757cb Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 07:41:11 -0000 The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=a8ceb6491219baa95155e2b55a1ba5b1654757cb commit a8ceb6491219baa95155e2b55a1ba5b1654757cb Author: Philipp Ost AuthorDate: 2021-08-28 07:32:22 +0000 Commit: Yuri Victorovich CommitDate: 2021-08-28 07:41:05 +0000 math/polymake: Backport patch allowing to use external Nauty library instead of Nauty source tree Also fix stripping of ideal.so --- math/polymake/Makefile | 22 ++-- math/polymake/files/patch-libnauty | 212 +++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 9 deletions(-) diff --git a/math/polymake/Makefile b/math/polymake/Makefile index 097714d1f003..e88745e92d98 100644 --- a/math/polymake/Makefile +++ b/math/polymake/Makefile @@ -2,6 +2,7 @@ PORTNAME= polymake DISTVERSION= 4.4 +PORTREVISION= 1 CATEGORIES= math MASTER_SITES= https://polymake.org/lib/exe/fetch.php/download/ DISTNAME= ${PORTNAME}-${DISTVERSION}-minimal @@ -95,14 +96,9 @@ 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 @@ -140,6 +136,8 @@ TESTS_VARS= USE_PERL5+=test # 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}";'!} @@ -178,10 +176,16 @@ post-install: ${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 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")); + } +