#!/usr/bin/perl -w # recompile_xs_module # Max Baker # see bottom for usage. $|=1; use Cwd 'chdir'; use FindBin; use Config; $arch = $Config{myarchname}; $perl_version = $Config{version}; $lib = 'liblocal'; #$lib = 'lib'; # this causes weird recursive behavior # since makemaker looks for this dir. $dest = shift || ''; die &usage unless -d $dest; # append . if not full path $dest = "$FindBin::Bin/$dest" unless $dest =~ /^\//; $arch = "$dest/$lib/$perl_version/$arch"; $perlexe = $^X; $sitelib = "$dest/$lib/site_perl/$perl_version"; $cmd = "$perlexe Makefile.PL"; $cmd .= " PREFIX=$dest"; $cmd .= " INSTALLBIN=$dest/bin INSTALLSCRIPT=$dest/bin"; $cmd .= " INSTALLMAN1DIR=$dest/man INSTALLMAN3DIR=$dest/man"; $cmd .= " INSTALLARCHLIB=$arch"; $cmd .= " INSTALLSITELIB=$sitelib"; # these don't work right in 5.6.0 #$cmd .= " LIB=$dest/lib"; chdir($dest); #system("make clean") if -r 'Makefile'; print "$cmd\n\n"; system("$cmd"); system("make install"); sub usage{ return <<'end_usage'; recompile_xs_module (module_dir) Recompile an XS module into a liblocal/ dir So we can have a local c-based (XS) module working for multiple architectures. Will compile into module_dir/locallib/ module_dir/locallib/$perl_version/$arch module_dir/locallib/site_perl/$perl_version To use: 1) tar xvfz Module-0.05.tar.gz 2) ./recompile_xs_module Module-0.05 3) Code to add to your perl module then: ----------------8<--------------------8<------------------------ $ModDir = 'Module-0.05'; # Add a bunch of local library paths so that we can have # multiple architectures using a local version of an # XS-based module. use FindBin; use Config; $Perl = $Config{version}; $Arch = $Config{myarchname}; @Lib = ("$FindBin::Bin/$ModDir/liblocal/$Perl/$Arch", "$FindBin::Bin/$ModDir/liblocal/site_perl/$Perl", "$FindBin::Bin/$ModDir/liblocal/site_perl/$Perl/auto", "$FindBin::Bin/$ModDir/liblocal"); foreach my $l (@Lib) { warn "Can't find lib dir : $l" unless -d $l; } unshift(@INC,@Lib); # Make sure that the module loads. eval "use Module;" die << "end_die" if ($@); $@ Can't find Module for this architecture. Please run ./recompile_xs_module $ModDir. end_die ----------------8<--------------------8<------------------------ maxb 3/2/5 end_usage }