PrusaSlicer-NonPlainar/xs/Build.PL

108 lines
3.1 KiB
Perl
Raw Normal View History

2013-06-22 15:16:45 +00:00
#!/usr/bin/perl -w
use strict;
use warnings;
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
my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS);
my @INC = qw();
my @LIBS = qw();
if (defined $ENV{BOOST_DIR}) {
if (-d "$ENV{BOOST_DIR}/include") {
push @INC, '-I' . $ENV{BOOST_DIR} . '/include';
} else {
push @INC, '-I' . $ENV{BOOST_DIR};
}
push @LIBS, '-L' . $ENV{BOOST_DIR};
} else {
push @INC, map "-I$_", grep { -d $_ }
qw(/opt/local/include /usr/local/include /opt/include),
2015-11-06 09:43:11 +00:00
qw(/usr/include C:\Boost\include);
push @LIBS, map "-L$_", grep { -d $_ }
qw(/opt/local/lib /usr/local/lib /opt/lib /usr/lib),
2015-11-06 09:43:11 +00:00
qw(C:\Boost\lib /lib);
if ($^O eq 'MSWin32') {
2015-11-06 09:43:11 +00:00
for my $path (glob 'C:\dev\boost* C:\boost*') {
push @INC, "-I" . $path;
push @INC, "-L" . $path . "/stage/lib";
}
}
}
push @INC, '-Iinclude';
my @boost_libs = qw(thread system);
2015-11-06 09:43:11 +00:00
my $have_boost = 0;
for my $pattern ('boost_%s', 'boost_%s-mt', 'boost_%s-mgw47-mt-1_59') {
check_lib(
lib => sprintf($pattern, 'system'),
INC => join(' ', @INC),
LIBS => join(' ', @LIBS),
) or next;
push @LIBS, map sprintf("-l$pattern", $_), @boost_libs;
push @cflags, '-DBOOST_LIBS';
2015-11-06 09:43:11 +00:00
$have_boost = 1;
last;
}
2015-11-06 09:43:11 +00:00
die "No Boost!\n" if !$have_boost;
2014-04-28 17:23:29 +00:00
if ($ENV{SLIC3R_DEBUG}) {
# 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]/) {
# 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
ExtUtils::Typemaps 1.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
)},
extra_compiler_flags => [ @INC, @cflags ],
extra_linker_flags => \@LIBS,
2013-06-22 15:16:45 +00:00
# Provides extra C typemaps that are auto-merged
extra_typemap_modules => {
'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__