X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=inc%2FMy%2FBuild.pm;h=a6a55f489e38e68b16bdc7d24688d8e99bc9deae;hb=5aeb13fc6eda81b2a2ef79fb71c66c48c7cb8134;hp=33bfc2b05ae15ad8dc83fbb4324a485d2483ea58;hpb=23f5d71553692b5d53978eedeb8a7323a14ba988;p=chaz%2Fp5-Alien-ZMQ diff --git a/inc/My/Build.pm b/inc/My/Build.pm index 33bfc2b..a6a55f4 100644 --- a/inc/My/Build.pm +++ b/inc/My/Build.pm @@ -10,7 +10,7 @@ use Cwd qw/realpath/; use Digest::SHA qw/sha1_hex/; use File::Path qw/remove_tree/; use File::Spec::Functions qw/catdir catfile/; -use IPC::Cmd qw/can_run run/; +use IPC::Run qw/run/; use LWP::Simple qw/getstore RC_OK/; use Module::Build; @@ -34,7 +34,7 @@ sub ACTION_code { %vars = $self->probe_zeromq; } - if ($vars{inc_version} && $vars{lib_version}) { + if ($vars{inc_version} && $vars{lib_version} && $vars{inc_dir} && $vars{lib_dir}) { say "Found ØMQ $vars{lib_version}; skipping installation"; } else { say "ØMQ not found; building from source..."; @@ -43,7 +43,7 @@ sub ACTION_code { # write vars to ZMQ.pm my $module = catfile qw/blib lib Alien ZMQ.pm/; - open my $LIB, "<$module" or die "Cannot read module"; + open my $LIB, '<', $module or die "Cannot read module"; my $lib = do { local $/; <$LIB> }; close $LIB; $lib =~ s/^sub inc_dir.*$/sub inc_dir { "$vars{inc_dir}" }/m; @@ -52,12 +52,12 @@ sub ACTION_code { $lib =~ s/^sub lib_version.*$/sub lib_version { v$vars{lib_version} }/m; my @stats = stat $module; chmod 0644, $module; - open $LIB, ">$module" or die "Cannot write config to module"; + open $LIB, '>', $module or die "Cannot write config to module"; print $LIB $lib; close $LIB; chmod $stats[2], $module; - open my $TARGET, ">build-zeromq"; + open my $TARGET, '>', "build-zeromq"; print $TARGET time, "\n"; close $TARGET; } @@ -68,7 +68,7 @@ sub probe_zeromq { my %config = $cb->get_config; my $src = "test-$$.c"; - open my $SRC, ">$src"; + open my $SRC, '>', $src; print $SRC < #include @@ -102,9 +102,9 @@ END # use -I and -L flag arguments as extra search directories my $inc = `$pkg_config $pkg --cflags-only-I`; - push @inc_search, map { s/^-I//; $_ } split(/\s+/, $inc); + 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//; $_ } split(/\s+/, $lib); + push @lib_search, map { s/^-L//; $_ } $cb->split_like_shell($lib); last; } @@ -153,8 +153,7 @@ END sub install_zeromq { my $self = shift; - - can_run("libtool") or die "The libtool command cannot be found"; + my $cb = $self->cbuilder; my $version = $self->notes('zmq-version'); my $sha1 = $self->notes('zmq-sha1'); @@ -166,7 +165,7 @@ sub install_zeromq { say "Verifying..."; my $sha1sum = Digest::SHA->new; - open my $ARCHIVE, "<$archive"; + open my $ARCHIVE, '<', $archive or die "Can't open source archive"; binmode $ARCHIVE; $sha1sum->addfile($ARCHIVE); close $ARCHIVE; @@ -180,18 +179,23 @@ sub install_zeromq { my $basedir = $self->base_dir; my $datadir = catdir($basedir, "share"); my $srcdir = catdir($basedir, "zeromq-$version"); + chdir $srcdir; + + say "Patching..."; + for my $patch (glob("$basedir/files/zeromq-$version-*.patch")) { + run ["patch"], '<', $patch or die "Failed to patch ØMQ"; + } say "Configuring..."; - my @config = split(/\s/, $self->args('zmq-config') || ""); - chdir $srcdir; - run(command => ["./configure", "--prefix=$prefix", @config]) + my @config = $cb->split_like_shell($self->args('zmq-config') || ""); + $cb->do_system(qw/sh configure CPPFLAGS=-Wno-error/, "--prefix=$prefix", @config) or die "Failed to configure ØMQ"; say "Compiling..."; - run(command => ['make']) or die "Failed to make ØMQ"; + $cb->do_system("make") or die "Failed to make ØMQ"; say "Installing..."; - run(command => [qw|make install prefix=/|, "DESTDIR=$datadir"]) + $cb->do_system(qw|make install prefix=/|, "DESTDIR=$datadir") or die "Failed to install ØMQ"; chdir $basedir;