use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. use File::Find; my ( $extra_external_top # ${DESTDIR}/prefix directory to which libgmp lib and header were installed , $extra_external_libdir # subdir under that where the libgmp.a file (or gmp.lib, etc.) is , $extra_external_incdir # subdir under that where the gmp.h header file needed for compilation is , $lib_basefn # the base filename of the library that provides the linkable objects we need , %MMext # Fully-formed params for WriteMakefile ); %MMext = (); if ( -d './extlib' ) { $extra_external_top = './extlib'; find( sub{ return unless -f and m{^(libgmp\.a|gmp\.lib)$}; $lib_basefn = $1; $extra_external_libdir = $File::Find::dir; } , $extra_external_top ); find( sub{ return unless -f and $_ eq 'gmp.h'; $extra_external_incdir = $File::Find::dir; } , $extra_external_top ); if ($extra_external_incdir and $extra_external_libdir) { my $gnustyle = $lib_basefn; $gnustyle=~ s{^(?:lib)?(\S+)\.(?:a|lib)$} {$1}; %MMext = ( 'INC' => '-I'.$extra_external_incdir ,'LIBS' => '-L'.$extra_external_libdir ." "."-l".$gnustyle ); } } WriteMakefile( 'NAME' => 'Math::GMP', 'VERSION_FROM' => 'lib/Math/GMP.pm', # finds $VERSION %MMext, ); #------------------ sub MY::post_initialize { #------------------ my $mm_self = shift(); return <<" DO!INTERPOLATE!"; # MakeMaker mechanism being directed to add include dir (where cc looks for headers): # $extra_external_incdir # MakeMaker mechanism being directed to add lib search (what ExtUtils::Liblist operates # on): # $extra_external_libdir # And looking there for $lib_basefn DO!INTERPOLATE! #------------------ } #**** E O S **** #------------------