# Let's start with the basics. If we detect that this is git clone, # then it's very likely that we don't have all the Module::Install # plugins and such, so run a separate script to detect it. # Otherwise, do the usual. BEGIN { if (-e '.git') { do 'tools/check_mi_mods.pl'; } else { unshift @INC, 'inc'; require inc::Module::Install; Module::Install->import; } } # Usual boilder plate... name 'ZMQ-LibZMQ3'; all_from 'lib/ZMQ/LibZMQ3.pm'; # Detect libzmq, and display it for sanity do 'tools/detect_zmq.pl'; print "Detected the following ZMQ settings:\n"; foreach my $env (qw(ZMQ_HOME ZMQ_H ZMQ_INCLUDES ZMQ_LIBS ZMQ_TRACE)) { printf " + %s = %s\n", $env, exists $ENV{$env} ? $ENV{$env} : "(null)"; } if (-f $ENV{ZMQ_H}) { printf "Detecting zmq version...\n"; open my $fh, '<', $ENV{ZMQ_H} or die; my %version; while (<$fh>) { if (/#define\s+ZMQ_VERSION_(MAJOR|MINOR|PATCH)\s+(\d+)$/) { $version{$1} = $2; } } printf " + Detected libzmq version %d.%d.%d\n", $version{MAJOR}, $version{MINOR}, $version{PATCH}, ; if ( $version{MAJOR} * 10000 + $version{MINOR} * 100 + $version{PATCH} < 30100) { print <= 3.1.0 Make sure to set your ZMQ paths correctly, e.g.: ZMQ_HOME=/usr/local/libzmq-3.1.0/ perl Makefile.PL EOM exit 1; } } # XXX As of Devel::CheckLib 0.93, it seems like LIBS = "-L/path/to/foo" # gets ignored (unlike what the docs say). So we manually strip and # re-arrange the paths here { my @libs = grep { -d $_ } map { s/^-L//; $_ } split /\s+/, $ENV{ZMQ_LIBS}; assertlibs lib => 'zmq', header => 'zmq.h', incpath => [ split /\s+/, $ENV{ZMQ_INCLUDES} ], libpath => \@libs, ; } requires 'Task::Weaken'; requires 'ZMQ::Constants'; test_requires 'Test::More', '0.98'; test_requires 'Test::TCP' => '1.08'; test_requires 'Test::Requires'; test_requires 'Test::Fatal'; use_xshelper '-clean'; use_ppport; cc_warnings; cc_include_paths split/\s+/, $ENV{ZMQ_INCLUDES}; cc_include_paths 'xs'; cc_src_paths 'xs'; cc_assert_lib 'zmq'; { my @libs = split /\s+/, $ENV{ZMQ_LIBS}; if ($^O eq 'cygwin') { push @libs, '-lzmq', '-luuid'; # uuid for cygwin, but can't hurt } else { push @libs, '-lzmq'; } cc_libs @libs; $ENV{ZMQ_LIBS} = join ' ', @libs; } if ($ENV{ZMQ_TRACE}) { cc_define qq|-DPERLZMQ_TRACE=$ENV{ZMQ_TRACE}|; } sub myguard (&) { bless [ $_[0] ], 'myguard'; } sub myguard::DESTROY { $_[0]->[0]->(); } my @constants; my @clean = qw(xs/*.inc xs/typemap); my $zmqcheck_dir = "tools/zmqcheck"; { my $pwd = Cwd::abs_path(); my $guard = myguard { chdir $pwd }; chdir $zmqcheck_dir; if (system($^X, "Makefile.PL") != 0) { die "Failed to execute $zmqcheck_dir/Makefile.PL"; } my $found = 0; foreach my $file (glob("*.c")) { my $name = $file; $name =~ s/\.c$//; push @clean, "$zmqcheck_dir/$name"; print STDERR "CHECK: Does your zmq have $name..."; my $ok = (system("make", $name) == 0); print STDERR " @{[$ok ? 'YES' : 'NO']}\n"; my $constname = sprintf "HAS_%s", uc $name; if ($ok) { $found++; cc_define "-D$constname"; } push @constants, $constname; } if (! $found) { print STDERR <) { print STDERR $_ } print STDERR "=== END zmqcheck.out ===\n"; } } print STDERR "Cleaning up $zmqcheck_dir...\n"; system "make", "clean"; } { # Create constants-xs.inc my $file = 'xs/constants-xs.inc'; open my $fh, '>', $file or die "Failed to create $file: $!"; print $fh <) { if ($^O eq 'darwin') { s/MACOSX_DEPLOYMENT_TARGET=(\d+\.\d+)/$1 < 10.5 ? "MACOSX_DEPLOYMENT_TARGET=$version" : "MACOSX_DEPLOYMENT_TARGET=$1"/e; } s/OTHERLDFLAGS =\s*$/OTHERLDFLAGS = -Wl,-rpath $ENV{ZMQ_LIBS}\n/; print; } }