NAME
<<module_name_colon>> - Short description of <<module_name_colon>> END $str =~ s/\<module_name_colon>\E/$self->{module_name}/g; _write_file( $fn, $str ); }
sub write_makefile_pl { my ( $self ) = @_;
my $str = <<'END';
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile( NAME => '<<module_name_colon>>', VERSION_FROM => 'lib/<<module_name_slash>>.pm', ABSTRACT_FROM => 'lib/<<module_name_slash>>.pm', PERL => "$^X -w", LIBS => ['-L./<<lib_dir>> -l<<lib_name>>'], INC => '-I. -I./<<lib_dir>>', ); END my $mod_name1 = $self->{module_name}; my $mod_name2 = $self->{module_name}; $mod_name2 =~ s{::}{/}g; $str =~ s/\<module_name_colon>\E/$mod_name1/g; $str =~ s/\<module_name_slash>\E/$mod_name2/g; $str =~ s/\<lib_dir>\E/$self->{mylib_dir}/g; $str =~ s/\<lib_name>\E/$self->{mylib_lib_name}/g; _write_file('Makefile.PL', $str); }
sub compile_library { my ($self) = @_;
_mkpath( $self->{mylib_dir} );
my $cwd = getcwd;
_chdir( $self->{mylib_dir} );
$self->write_mylib_h();
$self->write_mylib_c();
$self->compile_mylib();
_chdir( $cwd );
}
sub compile_mylib { my ($self) = @_;
my $cc = $Config{cc};
my $libext = $Config{so};
my $libname = 'lib' . $self->{mylib_lib_name} . '.' . $libext;
my @cmd = ($cc, '-I.', '-dynamiclib', '-install_name',
'@rpath/' . $libname,
'mylib.c', '-o', $libname);
_run_system_cmd(\@cmd);
}
sub _capture_stdout { my ($cmd) = @_;
my $out = `@$cmd`;
_check_sys_cmd_error( $cmd, $? ) if $? != 0;
return $out;
}
sub _stringify_cmd { '"' . (join " ", @{$_[0]}) . '"' }
sub _check_sys_cmd_error { my ( $cmd, $error ) = @_; my $cmd_str = _stringify_cmd($cmd); if ( $error == -1 ) { # A return value of -1 from system() indicates a failure to start the program die "Could not run $cmd_str: $!"; } elsif ($error & 127) { die sprintf "Command $cmd_str : killed by signal %d, %s coredump\n", ($error & 127), ($error & 128) ? 'with' : 'without'; } elsif ($error != 0) { die sprintf "$cmd_str exited with error code %d\n", $error >> 8; } }
sub _run_system_cmd { my ($cmd) = @_;
my $res = system @$cmd;
_check_sys_cmd_error( $cmd, $res ) if $res != 0;
}
sub write_mylib_c { my ($self) = @_; my $str = <<'END'; #include <stdio.h> #include <stdlib.h> #include "mylib.h"
void foo() { printf( "Hello from foo()\n"); } END _write_file($self->{mylib_c_fn}, $str); }
sub write_mylib_h { my ($self) = @_; my $str = 'void foo();'; _write_file($self->{mylib_h_fn}, $str); }
sub _write_file { my ($file, $text) = @_; my $utf8 = ("$]" < 5.008 or !$Config{useperlio}) ? "" : ":utf8"; open(FILE, ">$utf8", $file) || die "Can't create $file: $!"; print FILE $text; close FILE; }
sub new { my ($class, %args) = @_; return bless \%args, $class; }
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 146:
Deleting unknown formatting code Q<>
- Around line 160:
Deleting unknown formatting code Q<>
Deleting unknown formatting code Q<>
Deleting unknown formatting code Q<>
Deleting unknown formatting code Q<>