Alien-IUP
view release on metacpan or search on metacpan
inc/My/Builder/Unix.pm view on Meta::CPAN
$has{l_GLU} = $self->check_lib( 'GLU', $extra_cflags, $extra_lflags . ' -lGL -lm' );
$has{l_glut} = $self->check_lib( 'glut', $extra_cflags, $extra_lflags );
$has{'l_stdc++'} = $self->check_lib( 'stdc++', $extra_cflags, $extra_lflags );
$has{Xm} = $self->check_header('Xm/Xm.h', $extra_cflags);
$has{Xlib} = $self->check_header('X11/Xlib.h',$extra_cflags); #iupgl cdx11
$has{glx} = $self->check_header('GL/glx.h', $extra_cflags); #iupgl
$has{glu} = $self->check_header('GL/glu.h', $extra_cflags);
$has{gl} = $self->check_header('GL/gl.h', $extra_cflags);
#kind of a special hack
$has{freetype} = $self->check_header('ft2build.h', `pkg-config --cflags gtk+-2.0 gdk-2.0 2>/dev/null`) ||
$self->check_header('ft2build.h', `pkg-config --cflags gtk+-3.0 gdk-3.0 2>/dev/null`);
my @x11_libs; # just base X11 libs
push(@x11_libs, 'X11') if $has{l_X11};
push(@x11_libs, 'Xext') if $has{l_Xext};
my @opengl_libs;
push(@opengl_libs, 'GL') if $has{l_GL};
push(@opengl_libs, 'GLU') if $has{l_GLU};
my @imtargets;
my @cdtargets;
my @iuptargets;
#possible targets: im im_process im_jp2 im_fftw im_capture im_avi im_wmv
#possible targets: cd_zlib cd_freetype cd_ftgl cd cd_pdflib cdpdf cdgl cdcontextplus cdcairo
#possible targets: iup iupcd iupcontrols iup_pplot iup_mglplot iupgl iupim iupimglib iupweb iuptuio iup_plot
if ($self->notes('is_devel_cvs_version')) {
### DEVEL BUILD ###
@imtargets = qw[im im_process im_jp2 im_fftw im_capture];
@cdtargets = qw[cd cd_pdflib cdpdf cdgl]; #xxx add cdcontextplus
@iuptargets = qw[iup iupcd iupcontrols iupmatrixex iup_plot iup_mglplot iupgl iupglcontrols iup_scintilla iupim iupimglib iupweb iuptuio iup_plot];
}
else {
@imtargets = qw[im];
@cdtargets = qw[cd cdgl];
@iuptargets = qw[iup iupcd iupcontrols iupmatrixex iup_plot iup_mglplot iupgl iupglcontrols iup_scintilla iupim iupimglib iup_plot];
#if ($^O eq 'openbsd') {
# warn "###WARN### skipping im_process on OpenBSD";
# @imtargets = grep { $_ !~ /^im_process$/ } @imtargets;
#}
#if ($^O eq 'solaris') {
# warn "###WARN### skipping iuptuio on Solaris";
# @iuptargets = grep { $_ !~ /^iuptuio$/ } @iuptargets;
#}
if ($^O eq 'solaris') {
warn "###WARN### skipping iup_mglplot on Solaris (fails to compile)";
@iuptargets = grep { $_ !~ /^iup_mglplot$/ } @iuptargets;
}
}
my $ftgl_target = 1;
unless ($has{l_GL} && $has{l_GLU} && $has{gl} && $has{glx} && $has{glu}) {
warn "###WARN### OpenGL libraries not found or not complete\n";
warn "- required headers: GL/gl.h GL/glx.h GL/glu.h\n";
warn "- required libraries: libGL libGLU\n";
my $skip = $ENV{TRAVIS} ? 'y' : $self->prompt("Skip OpenGL related IUP/CD components?", 'y');
if (lc($skip) eq 'y') {
@cdtargets = grep { $_ !~ /^(cd_ftgl|cdgl)$/ } @cdtargets;
@iuptargets = grep { $_ !~ /^(iup_mglplot|iup_plot|iupglcontrols|iupgl)$/ } @iuptargets;
$ftgl_target = 0;
}
}
@iuptargets = grep { $_ !~ /^(iupweb)$/ } @iuptargets unless $has{webkit};
#store debug info into ConfigData
$self->config_data('info_has', \%has);
$self->config_data('info_lib_details', \%has_details);
$self->config_data('info_imtargets', \@imtargets);
$self->config_data('info_cdtargets', \@cdtargets);
$self->config_data('info_iuptargets', \@iuptargets);
my @makeopts = qw[NO_DYNAMIC=Yes USE_NODEPEND=Yes];
#my @makeopts = qw[NO_STATIC=Yes USE_NODEPEND=Yes];
#On solaris, some tools like 'ar' are not in the default PATH, but in /usr/???/bin
if ($^O eq 'solaris') {
my ($ar, $ranlib);
for (qw[/usr/ccs/bin /usr/xpg4/bin /usr/sfw/bin /usr/xpg6/bin /usr/gnu/bin /opt/gnu/bin /usr/bin]) {
$ar = "$_/ar" if (!$ar && -x "$_/ar");
$ranlib = "$_/ranlib" if (!$ranlib && -x "$_/ranlib");
}
push @makeopts, "AR=$ar" if $ar;
push @makeopts, "RANLIB=$ranlib" if $ranlib;
}
#choose GUI subsystem, priorities if multiple subsystems detected: 1. GTK, 2. X11/Motif
my @libs;
my @build_opts;
my $build_target;
push(@build_opts, 'GTK3') if ($has{gtk3} && $has{gdk3} && $has{cairo} && $has{Xlib});
push(@build_opts, 'GTK2') if ($has{gtk} && $has{gdk} && $has{cairo} && $has{Xlib});
push(@build_opts, 'X11/Motif') if ($has{Xlib} && $has{Xm});
if (scalar(@build_opts) == 1) {
$build_target = $build_opts[0];
}
elsif (scalar(@build_opts) > 1) {
my $n = 1;
my $msg = "\nYou have the following build options available:\n" .
join("\n", map ($n++ . ") $_", @build_opts)) .
"\nWhat do you wanna build?";
my $i = $ENV{TRAVIS} ? 1 : $self->prompt($msg, 1);
$build_target = $build_opts[$i-1];
die "###ERROR### Wrong selection!" unless $build_target;
}
else {
warn "###WARNING### No supported GUI subsystem detected!\n";
}
if ($self->notes('build_debug_info') || ( !$build_target && $ENV{AUTOMATED_TESTING} ) ) {
foreach (sort keys %has) {
my $msg = "has: $has{$_} - $_";
$msg .= "; version=" . $has_details{$_}->{version} if $has_details{$_}->{version};
$msg .= "; prefix=" . $has_details{$_}->{prefix} if $has_details{$_}->{prefix};
print STDERR $msg, "\n";
}
print STDERR "Dumping some pkg-info:\n";
print STDERR "[gtk2 cflags] " . $self->run_stdout2str(qw[pkg-config --cflags gtk+-2.0]) . "\n";
print STDERR "[gtk2 libs ] " . $self->run_stdout2str(qw[pkg-config --libs gtk+-2.0]) . "\n";
print STDERR "[gtk3 cflags] " . $self->run_stdout2str(qw[pkg-config --cflags gtk+-3.0]) . "\n";
print STDERR "[gtk3 libs ] " . $self->run_stdout2str(qw[pkg-config --libs gtk+-3.0]) . "\n";
for my $pkg (qw[gtk+-2.0 gtk+-3.0 gl glu glut x11 xt xext xmu]) {
print STDERR "[prefix $pkg] " . $self->run_stdout2str(qw[pkg-config --variable=prefix], $pkg) . "\n";
print STDERR "[libdir $pkg] " . $self->run_stdout2str(qw[pkg-config --variable=libdir], $pkg) . "\n";
print STDERR "[includedir $pkg] " . $self->run_stdout2str(qw[pkg-config --variable=includedir], $pkg) . "\n";
}
print STDERR "Brute force lookup:\n";
my $re = qr/\/(Xlib.h|Xm.h|gtk.h|cairo.h|glu.h|glut.h|gl.h|freetype.h|gtkprintunixdialog.h|jasper.h|jas_image.h|lib(X11|GL|Xm|freetype)\.[^\d]*)$/;
print STDERR "[/usr ] $_\n" foreach ($self->find_file('/usr', $re));
print STDERR "[/lib ] $_\n" foreach ($self->find_file('/usr', $re));
print STDERR "[/opt ] $_\n" foreach ($self->find_file('/opt', $re));
print STDERR "[/sw ] $_\n" foreach ($self->find_file('/sw', $re));
print STDERR "[/System ] $_\n" foreach ($self->find_file('/System', $re));
print STDERR "[/Library] $_\n" foreach ($self->find_file('/Library', $re));
print STDERR "[/Network] $_\n" foreach ($self->find_file('/Network', $re));
}
unless ($build_target) {
warn <<'MARKER';
###FATAL### No supported GUI subsystem (GTK3, GTK2, X11/Motif) detected! (gonna exit)
### for GTK3 you need: gtk+-3.0, gdk-3.0, cairo + X11/Xlib.h
### for GTK2 you need: gtk+-2.0, gdk-2.0, cairo + X11/Xlib.h
### for X11/Motif you need: -lXm, -lX11 + Xm/Xm.h, X11/Xlib.h
###
### on Debian/Ubuntu you need to install:
### $ aptitude install libgtk-2-dev libcairo2-dev libx11-dev libglu-dev freeglut3-dev
### $ aptitude install libgtk-3-dev libcairo2-dev libx11-dev libglu-dev freeglut3-dev
### or
### $ sudo apt-get install libgtk-2-dev libcairo2-dev libx11-dev libglu-dev freeglut3-dev
### $ sudo apt-get install libgtk-3-dev libcairo2-dev libx11-dev libglu-dev freeglut3-dev
###
### on RedHat/CentOS/Fedora you need to install:
### $ yum install gtk2-devel cairo-devel libX11-devel libGLU-devel freeglut-devel
###
### on FreeBSD you need to install:
### $ pkg install gtk2 cairo freeglut
###
MARKER
die;
}
( run in 0.721 second using v1.01-cache-2.11-cpan-0b5f733616e )