2013-06-22 15:16:45 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2014-11-26 21:30:25 +00:00
|
|
|
use Devel::CheckLib;
|
2014-04-28 17:23:29 +00:00
|
|
|
use ExtUtils::CppGuess;
|
2013-06-22 15:16:45 +00:00
|
|
|
use Module::Build::WithXSpp;
|
|
|
|
|
2014-04-28 17:23:29 +00:00
|
|
|
# _GLIBCXX_USE_C99 : to get the long long type for g++
|
|
|
|
# HAS_BOOL : stops Perl/lib/CORE/handy.h from doing "# define bool char" for MSVC
|
|
|
|
# NOGDI : prevents inclusion of wingdi.h which defines functions Polygon() and Polyline() in global namespace
|
2015-11-19 12:17:52 +00:00
|
|
|
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
|
|
|
|
my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE);
|
2015-12-04 20:25:45 +00:00
|
|
|
my @ldflags = ();
|
|
|
|
if ($^O eq 'darwin') {
|
|
|
|
push @ldflags, qw(-framework IOKit -framework CoreFoundation);
|
|
|
|
}
|
2014-11-26 21:30:25 +00:00
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
my @INC = qw(-Isrc/libslic3r);
|
|
|
|
my @LIBS = qw(-Lsrc/libslic3r);
|
2014-11-26 21:30:25 +00:00
|
|
|
|
2015-11-06 10:03:45 +00:00
|
|
|
# search for Boost in a number of places
|
|
|
|
my @boost_include = my @boost_libs = ();
|
2014-11-26 21:30:25 +00:00
|
|
|
if (defined $ENV{BOOST_DIR}) {
|
|
|
|
if (-d "$ENV{BOOST_DIR}/include") {
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_include, $ENV{BOOST_DIR} . '/include';
|
2014-11-26 21:30:25 +00:00
|
|
|
} else {
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_include, $ENV{BOOST_DIR};
|
2014-11-26 21:30:25 +00:00
|
|
|
}
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_libs, $ENV{BOOST_DIR};
|
2014-11-26 21:30:25 +00:00
|
|
|
} else {
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_include, grep { -d $_ }
|
2014-11-26 21:30:25 +00:00
|
|
|
qw(/opt/local/include /usr/local/include /opt/include),
|
2015-11-06 09:43:11 +00:00
|
|
|
qw(/usr/include C:\Boost\include);
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_libs, grep { -d $_ }
|
2014-11-26 21:30:25 +00:00
|
|
|
qw(/opt/local/lib /usr/local/lib /opt/lib /usr/lib),
|
2015-11-06 09:43:11 +00:00
|
|
|
qw(C:\Boost\lib /lib);
|
2015-11-05 10:02:12 +00:00
|
|
|
|
|
|
|
if ($^O eq 'MSWin32') {
|
2016-04-11 15:05:58 +00:00
|
|
|
for my $path (glob('C:\dev\boost*'), glob ('C:\boost*'), glob ('d:\src\boost*')) {
|
2015-11-06 10:03:45 +00:00
|
|
|
push @boost_include, $path;
|
|
|
|
push @boost_libs, $path . "/stage/lib";
|
2015-11-05 10:02:12 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-26 21:30:25 +00:00
|
|
|
}
|
|
|
|
|
2015-11-06 10:03:45 +00:00
|
|
|
# In order to generate the -l switches we need to know how Boost libraries are named
|
2015-11-06 09:43:11 +00:00
|
|
|
my $have_boost = 0;
|
2015-12-18 12:40:57 +00:00
|
|
|
my @boost_libraries = qw(system thread); # we need these
|
2015-11-19 14:30:27 +00:00
|
|
|
|
|
|
|
# check without explicit lib path (works on Linux)
|
|
|
|
$have_boost = 1
|
|
|
|
if check_lib(
|
2015-12-18 12:40:57 +00:00
|
|
|
lib => [ map "boost_${_}", @boost_libraries ],
|
2015-11-19 14:30:27 +00:00
|
|
|
);
|
|
|
|
|
2015-11-19 16:02:01 +00:00
|
|
|
if ($have_boost) {
|
2015-12-18 12:49:22 +00:00
|
|
|
push @LIBS, map "-lboost_${_}", @boost_libraries;
|
2015-11-19 16:02:01 +00:00
|
|
|
} else {
|
2015-11-19 14:30:27 +00:00
|
|
|
foreach my $path (@boost_libs) {
|
|
|
|
my @files = glob "$path/libboost_system*";
|
|
|
|
next if !@files;
|
2015-11-06 10:03:45 +00:00
|
|
|
|
2015-11-19 14:30:27 +00:00
|
|
|
if ($files[0] =~ /libboost_system([^.]+)/) {
|
|
|
|
my $suffix = $1;
|
|
|
|
check_lib(
|
2015-12-18 12:40:57 +00:00
|
|
|
lib => [ map "boost_${_}${suffix}", @boost_libraries ],
|
2015-11-19 14:30:27 +00:00
|
|
|
INC => join(' ', map "-I$_", @INC, @boost_include),
|
|
|
|
LIBS => "-L$path",
|
|
|
|
) or next;
|
2015-11-06 10:03:45 +00:00
|
|
|
|
2015-11-19 14:30:27 +00:00
|
|
|
push @INC, (map " -I$_", @boost_include); # TODO: only use the one related to the chosen lib path
|
2015-12-18 12:40:57 +00:00
|
|
|
push @LIBS, " -L$path", (map " -lboost_$_$suffix", @boost_libraries);
|
2015-11-19 14:30:27 +00:00
|
|
|
$have_boost = 1;
|
|
|
|
last;
|
|
|
|
}
|
2015-11-06 10:03:45 +00:00
|
|
|
}
|
2014-11-26 21:30:25 +00:00
|
|
|
}
|
2015-11-19 14:30:27 +00:00
|
|
|
push @cflags, '-DBOOST_LIBS' if $have_boost;
|
2015-11-06 10:03:45 +00:00
|
|
|
die <<'EOF' if !$have_boost;
|
|
|
|
Slic3r requires the Boost libraries. Please make sure they are installed.
|
|
|
|
|
|
|
|
If they are installed, this script should be able to locate them in several
|
|
|
|
standard locations. If this is not the case, you might want to supply their
|
|
|
|
path through the BOOST_DIR environment variable:
|
|
|
|
|
|
|
|
BOOST_DIR=/path/to/boost perl Build.PL
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2014-04-28 17:23:29 +00:00
|
|
|
if ($ENV{SLIC3R_DEBUG}) {
|
2014-05-09 12:24:35 +00:00
|
|
|
# only on newer GCCs: -ftemplate-backtrace-limit=0
|
|
|
|
push @cflags, qw(-DSLIC3R_DEBUG -g);
|
2014-04-28 17:23:29 +00:00
|
|
|
}
|
|
|
|
if (ExtUtils::CppGuess->new->is_gcc) {
|
|
|
|
# check whether we're dealing with a buggy GCC version
|
|
|
|
# see https://github.com/alexrj/Slic3r/issues/1965
|
|
|
|
if (`cc --version` =~ / 4\.7\.[012]/) {
|
2014-05-10 15:03:05 +00:00
|
|
|
# Workaround suggested by Boost devs:
|
|
|
|
# https://svn.boost.org/trac/boost/ticket/8695
|
|
|
|
push @cflags, qw(-fno-inline-small-functions);
|
2014-04-28 17:23:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
my $build = Module::Build::WithXSpp->new(
|
|
|
|
module_name => 'Slic3r::XS',
|
|
|
|
dist_abstract => 'XS code for Slic3r',
|
|
|
|
build_requires => {qw(
|
2013-06-23 18:05:20 +00:00
|
|
|
ExtUtils::ParseXS 3.18
|
2015-02-13 17:44:22 +00:00
|
|
|
ExtUtils::Typemaps 1.00
|
2014-06-25 12:57:06 +00:00
|
|
|
ExtUtils::Typemaps::Default 1.05
|
2013-06-23 18:05:20 +00:00
|
|
|
ExtUtils::XSpp 0.17
|
2013-06-22 15:16:45 +00:00
|
|
|
Module::Build 0.3601
|
|
|
|
Test::More 0
|
|
|
|
)},
|
|
|
|
configure_requires => {qw(
|
|
|
|
ExtUtils::CppGuess 0.07
|
|
|
|
Module::Build 0.38
|
2013-06-23 18:05:20 +00:00
|
|
|
Module::Build::WithXSpp 0.13
|
2013-06-22 15:16:45 +00:00
|
|
|
)},
|
2014-11-26 21:30:25 +00:00
|
|
|
extra_compiler_flags => [ @INC, @cflags ],
|
2015-12-04 20:25:45 +00:00
|
|
|
extra_linker_flags => [ @LIBS, @ldflags ],
|
2013-06-22 15:16:45 +00:00
|
|
|
|
|
|
|
# Provides extra C typemaps that are auto-merged
|
|
|
|
extra_typemap_modules => {
|
2014-11-22 21:20:28 +00:00
|
|
|
'ExtUtils::Typemaps::Basic' => '1.05',
|
2013-06-22 15:16:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
# for MSVC builds
|
|
|
|
early_includes => [qw(
|
|
|
|
cstring
|
|
|
|
cstdlib
|
|
|
|
ostream
|
2015-11-06 09:43:11 +00:00
|
|
|
sstream
|
|
|
|
libslic3r/GCodeSender.hpp
|
2013-06-22 15:16:45 +00:00
|
|
|
)]
|
|
|
|
);
|
|
|
|
|
|
|
|
$build->create_build_script;
|
|
|
|
|
|
|
|
__END__
|