Alien-ZMQ

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


  232c208 switch distribution to zeromq-3.2.4
  cbcb271 do not print Ø for the benefit of unicode-unaware terminals
  8539173 remove use of `say' to support older perls

v0.05 2013-05-02
----------------

  03cf2eb switch distribution to zeromq-3.2.3; bump version
  f3a10ea add gitignore file
  77bb082 cflags and libs can now return a list of flags
  435ebe1 improve the abstract and add urls to dist metadata

v0.0403 2013-01-23
------------------

  e4f59b5 mention cygwin in the documentation; bump version number
  5b1617c require Archive::Tar 1.00 since older versions don't work
  2b70311 require MB 0.40 to avoid RT#68585
  78a45fb add example that compiles an executable with cbuilder

Changes  view on Meta::CPAN

  7837ede fix up documentation and bump version number
  5aeb13f do not bother building the zeromq test programs
  989b095 never treat zeromq compiler warnings as fatal
  18a76a3 run the zeromq configure script through sh explicitly

v0.03 2013-01-17
----------------

  0283879 bump version number for new release
  e20f71b output log of zeromq installation
  da7265e add smarter shell-quoting in the cflags and libs functions
  2c02694 improve handling of spaces in build args
  23f5d71 use cbuilder for cc and dlext
  fb61bef make the auto-generated changelog less verbose
  e04c8dc add markdown-formatted readme document

===================================
End of changes in the last 365 days
===================================

examples/01-compile.t  view on Meta::CPAN

    zmq_version(&major, &minor, &patch);
    printf("%d.%d.%d %d.%d.%d",
        ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH,
        major, minor, patch);
    return 0;
}
END
close $SRC;

my $obj = eval {
    $cb->compile(source => $src, extra_compiler_flags => [Alien::ZMQ->cflags]);
};
unlink $src;
ok($obj, "compile C code");
BAIL_OUT("compile failed") unless $obj;

my $exe = eval {
    $cb->link_executable(objects => $obj, extra_linker_flags => [Alien::ZMQ->libs]);
};
unlink $obj;
ok($exe, "link object");
BAIL_OUT("link failed") unless $exe;

$ENV{LD_LIBRARY_PATH} = Alien::ZMQ->lib_dir;
my $out = `./$exe`;
ok($out, "run executable");
unlink $exe;
my ($inc_version, $lib_version) = $out =~ /(\d\.\d\.\d) (\d\.\d\.\d)/;

examples/Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
use Alien::ZMQ;

WriteMakefile(
    NAME         => 'My::Module',
    VERSION_FROM => 'lib/My/Module.pm',
    INC          => Alien::ZMQ::cflags,
    LIBS         => Alien::ZMQ::libs,
    # add more params
);

inc/My/Build.pm  view on Meta::CPAN

        ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH,
        major, minor, patch);
    return 0;
}
END
    close $SRC;

    my @inc_search;
    my @lib_search;

    my $cflags = $self->args('zmq-cflags');
    my $libs   = $self->args('zmq-libs');

    my $pkg_version;

    my $pkg_config = $ENV{PKG_CONFIG_COMMAND} || "pkg-config";
    for my $pkg (qw/libzmq zeromq3/) {
        $pkg_version = `$pkg_config $pkg --modversion`;
        chomp $pkg_version;
        next unless $pkg_version;

        $cflags ||= `$pkg_config $pkg --cflags`;
        $libs   ||= `$pkg_config $pkg --libs`;

        # use -I and -L flag arguments as extra search directories
        my $inc = `$pkg_config $pkg --cflags-only-I`;
        push @inc_search, map { s/^-I//; $_ } $cb->split_like_shell($inc);
        my $lib = `$pkg_config $pkg --libs-only-L`;
        push @lib_search, map { s/^-L//; $_ } $cb->split_like_shell($lib);

        last;
    }

    my $obj = eval {
        $cb->compile(source => $src, include_dirs => [@inc_search], extra_compiler_flags => $cflags);
    };
    unlink $src;
    return unless $obj;

    my $exe = eval {
        $cb->link_executable(objects => $obj, extra_linker_flags => $libs);
    };
    unlink $obj;
    return unless $exe;

    my $out = `./$exe`;
    unlink $exe;
    my ($inc_version, $lib_version) = $out =~ /(\d\.\d\.\d) (\d\.\d\.\d)/;

    # query the compiler for include and library search paths
    push @lib_search, map {

lib/Alien/ZMQ.pm  view on Meta::CPAN


sub lib_version { }


sub inc_dir { }


sub lib_dir { }


sub cflags {
    if (wantarray) {
        "-I" . inc_dir;
    } else {
        "-I" . shell_quote(inc_dir);
    }
}


sub libs {
    if (wantarray) {

lib/Alien/ZMQ.pm  view on Meta::CPAN

the F<libzmq.so> file.

=head2 inc_dir

Get the directory containing the F<zmq.h> header file.

=head2 lib_dir

Get the directory containing the F<libzmq.so> file.

=head2 cflags

Get the C compiler flags required to compile a program that uses libzmq.  This
is a shortcut for constructing a C<-I> flag using L</inc_dir>.  In scalar
context, the flags are quoted using L<String::ShellQuote> and returned as
a single string.

=head2 libs

Get the linker flags required to link a program against libzmq.  This is
a shortcut for constructing a C<-L> flag using L</lib_dir>, plus C<-lzmq>.  In
scalar context, the flags are quoted using L<String::ShellQuote> and returned
as a single string.

On some platforms, you may also want to add the library path to your
executable or library as a runtime path; this is usually done by passing
C<-rpath> to the linker.  Something like this could work:

    my @flags = (Alien::ZMQ::libs, "-Wl,-rpath=" . Alien::ZMQ::lib_dir);

This will allow your program to find libzmq, even if it is installed in
a non-standard location, but some systems don't have this C<RPATH> mechanism.

=head1 OPTIONS

These options to F<Build.PL> affect the installation of this module.

=over 4

=item --zmq-skip-probe

By default, libzmq is not compiled and installed if it is detected to already
be on the system.  Use this to skip those checks and always install libzmq.

=item --zmq-cflags

Pass extra flags to the compiler when probing for an existing installation of
libzmq.  You can use this, along with L</--zmq-libs>, to help the probing
function locate libzmq if it is installed in an unexpected place.  For
example, if your libzmq is installed at F</opt/zeromq>, you can do something
like this:

    perl Build.PL --zmq-cflags="-I/opt/zeromq/include" \
                  --zmq-libs="-L/opt/zeromq/lib -lzmq"

These flags are only used by the probing function to locate libzmq; they will
not be used when compiling libzmq from source (if it needs to be).  To affect
the compiling of libzmq, using the L</--zmq-config> flag instead.

A better alternative to using L</--zmq-cflags> and L</--zmq-libs> is to help
the L<pkg-config> program find your libzmq by using the C<PKG_CONFIG_PATH>
environment variable.  Of course, this method requires that you have the
L<pkg-config> program installed.  Here's an example:

    perl Build.PL
    PKG_CONFIG_PATH=/opt/zeromq/lib/pkgconfig ./Build

=item --zmq-libs

Pass extra flags to the linker when probing for an existing installation of
libzmq.  You can use this, along with L</--zmq-cflags>, to help the probing
function locate libzmq if it is installed in an unexpected place.  Like
L</--zmq-cflags>, these flags are only used by the probing function to locate
libzmq.

=item --zmq-config

Pass extra flags to the libzmq F<configure> script.  You may want to consider
passing either C<--with-pgm> or C<--with-system-pgm> if you need support for
PGM; this is not enabled by default because it is not supported by every
system.

=back

=head1 CAVEATS

Probing is only done during the installation of this module, so if you are
using a system-installed version of libzmq and you uninstall or upgrade it,

t/00-basic.t  view on Meta::CPAN


BEGIN {
    use_ok 'Alien::ZMQ';
}

ok Alien::ZMQ::inc_version, "include version number";
ok Alien::ZMQ::lib_version, "library version number";
ok Alien::ZMQ::inc_dir,     "include directory path";
ok Alien::ZMQ::inc_dir,     "library directory path";

ok grep(/-I\S+/, Alien::ZMQ::cflags), "cflags array has -I";
ok grep(/-L\S+/, Alien::ZMQ::libs),   "libs array has -L";
ok grep(/-lzmq/, Alien::ZMQ::libs),   "libs array has -lzmq";

like Alien::ZMQ::cflags, qr/-I\S+/, "cflags string has -I";
like Alien::ZMQ::libs,   qr/-L\S+/, "libs string has -L";
like Alien::ZMQ::libs,   qr/-lzmq/, "libs string has -lzmq";



( run in 0.310 second using v1.01-cache-2.11-cpan-94b05bcf43c )