/usr/bin/polymake-config is in libpolymake-dev 3.2r2-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | #!/usr/bin/perl
#
# Copyright (c) 1997-2018
# Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
# http://www.polymake.org
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version: http://www.gnu.org/licenses/gpl.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#-------------------------------------------------------------------------------
use strict;
my $Version=3.2;
my $InstallArch="/usr/lib/polymake";
sub usage {
print STDERR <<'.';
usage: polymake-config --help | --version | [--debug] --OPTION
Print bits of polymake configuration useful to compose Makefiles
for programs linked with its callable library.
OPTION may be one of:
--cc print the name of C++ compiler and linker
--cflags print the C++ compiler flags without header paths
--includes print the C++ compiler flags for header paths
--ldflags print the linker flags
--libs print the libraries to link with
.
exit(0);
}
@ARGV || usage;
my $root="/usr/share/polymake";
do "$root/support/install_utils.pl";
die $@ if $@;
my %ConfigFlags=load_config_file("$InstallArch/config.ninja", $root);
if ($ConfigFlags{LDcallableFLAGS} eq "none") {
die <<'.';
polymake has been built without callable library,
probably because of missing shared library libperl.
.
}
my $debug;
my $tmpdir;
foreach ($ENV{TMPDIR}, "/tmp", "/var/tmp", ".", $ENV{HOME}) {
if (defined($_) && -d $_ && -w _ && -x _) {
$tmpdir=$_; last;
}
}
defined($tmpdir) or die <<'.';
Can't find any writable directory for temporary files;
Please set enviroment variable TMPDIR to an appropriate location.
.
my $tmpfile="$tmpdir/polymake-config-$$";
my $debug_asked;
while (defined ($_=shift)) {
if ($_ eq "--debug") {
if (defined $debug_asked) {
usage;
} else {
$debug=1;
}
} elsif ($_ eq "--version") {
print $Version, "\n";
} elsif ($_ eq "--cc") {
print $ConfigFlags{CXX}, "\n";
} elsif ($_ eq "--cflags") {
my ($major, $minor)=split /\./, $Version;
my $version_for_c=sprintf("%d%02d", $major, $minor);
$_="-DPOLYMAKE_VERSION=$version_for_c $ConfigFlags{CsharedFLAGS} $ConfigFlags{CXXFLAGS}";
if ($^O eq "darwin") {
s/\$\{ARCHFLAGS\}/$ConfigFlags{ARCHFLAGS}/;
}
# include paths are reported separately
s/-I\S+//g;
# do not impose the strict warning policy on foreign software
s/-W(?:all|error)(?:\s|$)//g;
# strip spaces
s/^\s+//; s/\s+$//; s/\s{2,}/ /g;
if ($debug_asked=defined($debug)) {
print "$_ $ConfigFlags{CXXDEBUG} -DPOLYMAKE_DEBUG=1\n";
} else {
print "$_ $ConfigFlags{CXXOPT} -DPOLYMAKE_DEBUG=0\n";
}
} elsif ($_ eq "--includes") {
my $inc=join(" ", grep { /^-I/ } split /\s+/, $ConfigFlags{CXXFLAGS});
if (glob "$ConfigFlags{InstallInc}/polymake/external/*") {
$inc="-I$ConfigFlags{InstallInc}/polymake/external $inc";
}
if ($inc !~ /(?:^|\s)-I$ConfigFlags{InstallInc}(?:\s|$)/) {
$inc="-I$ConfigFlags{InstallInc} $inc";
}
# collect standard include paths of the C++ compiler and exclude them from the result
open CF, ">$tmpfile.cc" or die "can't create temporary file $tmpfile.cc: $!\n";
print CF "int main() { return 0; }\n";
close CF;
open CC, "$ConfigFlags{CXX} -o $tmpfile.bin -v $tmpfile.cc 2>&1 |" or die "can't run C++ compiler $ConfigFlags{CXX}: $!\n";
while (<CC>) {
last if (/^\#include.*starts here/i);
}
while (<CC>) {
last if /end of search list/i;
if (! /^\#/ && /(\S+)/) {
my $dir=$1;
$inc =~ s/(^|\s)-I$dir(\s\$)/$1$2/;
}
}
close CC;
$inc=~s/^\s+//; $inc=~s/\s+$//; $inc=~s/\s{2,}/ /g;
print $inc, "\n";
} elsif ($_ eq "--ldflags") {
my $ldflags=$ConfigFlags{LDFLAGS};
if ($ldflags !~ /(?:^|\s)-L$ConfigFlags{InstallLib}(?:\s|$)/) {
$ldflags="-L$ConfigFlags{InstallLib} $ldflags";
}
my $add_rpath=1;
# collect standard library paths of the C++ compiler and exclude them from the result
open CF, ">$tmpfile.cc" or die "can't create temporary file $tmpfile.cc: $!\n";
print CF "int main() { return 0; }\n";
close CF;
open CC, "$ConfigFlags{CXX} -o $tmpfile.bin -v $tmpfile.cc 2>&1 |" or die "can't run C++ compiler $ConfigFlags{CXX}: $!\n";
while (<CC>) {
if (/^LIBRARY_PATH=/i) {
foreach my $dir (split /:/, $') {
$ldflags =~ s/(^|\s)-L$dir(\s\$)/$1$2/;
$add_rpath &&= $dir ne $ConfigFlags{InstallLib};
}
last;
}
}
close CC;
if ($^O eq "darwin") {
$ldflags="$ConfigFlags{ARCHFLAGS} $ldflags -flat_namespace";
} elsif ($add_rpath) {
$ldflags.=" -Wl,-rpath,$ConfigFlags{InstallLib}";
}
$ldflags=~s/^\s+//; $ldflags=~s/\s+$//; $ldflags=~s/\s{2,}/ /g;
if ($debug_asked=defined($debug)) {
print "$ldflags $ConfigFlags{CXXDEBUG}\n";
} else {
print $ldflags, "\n";
}
} elsif ($_ eq "--libs") {
my $libs="$ConfigFlags{LIBS} $ConfigFlags{LIBXML2_LIBS}";
$libs=~s/\s+$//;
print "-lpolymake -lpolymake-apps $libs\n";
} else {
usage;
}
}
END {
if (defined $tmpfile) {
unlink $_ for glob "$tmpfile*";
}
}
# Local Variables:
# mode: perl
# cperl-indent-level:3
# indent-tabs-mode:nil
# End:
|