| 1 | #!perl |
| 2 | |
| 3 | use strictscip-perl cpan PAR-Packer 1.064 strict/; |
| 4 | use warningsscip-perl cpan PAR-Packer 1.064 warnings/; |
| 5 | use Configscip-perl cpan PAR-Packer 1.064 Config/; |
| 6 | use File::Globscip-perl cpan PAR-Packer 1.064 File/Glob/; |
| 7 | use File::Basenamescip-perl cpan PAR-Packer 1.064 File/Basename/; |
| 8 | use File::Specscip-perl cpan PAR-Packer 1.064 File/Spec/; |
| 9 | |
| 10 | my $ld = $Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{ld} || (($^Oscip-perl cpan PAR-Packer 1.064 main/`$^O`. eq 'MSWin32') ? 'link.exe' : $Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{cc}); |
| 11 | $ld = $Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{cc} if ($^Oscip-perl cpan PAR-Packer 1.064 main/`$^O`. =~ /^(?:dec_osf|aix|hpux)$/); |
| 12 | |
| 13 | sub find_files_to_embedscip-perl cpan PAR-Packer 1.064 main/find_files_to_embed(). |
| 14 | { |
| 15 | my ($par, $libperl) = @_scip-perl cpan PAR-Packer 1.064 main/`@_`.; |
| 16 | |
| 17 | # If on Windows and Perl was built with GCC 4.x or higher, then libperl*.dll |
| 18 | # may depend on some libgcc_*.dll (e.g. Strawberry Perl 5.12). |
| 19 | # This libgcc_*.dll has to be included into with any packed executable |
| 20 | # in the same way as libperl*.dll itself, otherwise a packed executable |
| 21 | # won't run when libgcc_*.dll isn't installed. |
| 22 | # The same holds for libstdc++*.dll (e.g. Strawberry Perl 5.16). |
| 23 | my ($libgcc, $libstdcpp, $libwinpthread); |
| 24 | if ($^Oscip-perl cpan PAR-Packer 1.064 main/`$^O`. eq 'MSWin32' |
| 25 | and definedscip-perl cpan PAR-Packer 1.064 main/defined(). $Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{gccversion} # gcc version >= 4.x was used |
| 26 | and $Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{gccversion} =~ m{\A(\d+)}ms && $1scip-perl cpan PAR-Packer 1.064 main/$1. >= 4) { |
| 27 | $libgcc = find_dllscip-perl cpan PAR-Packer 1.064 main/find_dll().("libgcc_*.$Config{so}"); |
| 28 | $libwinpthread = find_dllscip-perl cpan PAR-Packer 1.064 main/find_dll().("libwinpthread*.$Config{so}"); |
| 29 | } |
| 30 | if ($ld =~ /(\b|-)g\+\+(-.*)?(\.exe)?$/) { # g++ was used to link |
| 31 | $libstdcpp = find_dllscip-perl cpan PAR-Packer 1.064 main/find_dll().("libstdc++*.$Config{so}"); |
| 32 | } |
| 33 | |
| 34 | return { mapscip-perl cpan PAR-Packer 1.064 main/map(). { basenamescip-perl cpan PAR-Packer 1.064 main/basename().($_scip-perl cpan PAR-Packer 1.064 main/$_.) => $_scip-perl cpan PAR-Packer 1.064 main/$_. } |
| 35 | grepscip-perl cpan PAR-Packer 1.064 main/grep(). { definedscip-perl cpan PAR-Packer 1.064 main/defined(). } $libperl, $libgcc, $libwinpthread, $libstdcpp }; |
| 36 | } |
| 37 | |
| 38 | sub find_dllscip-perl cpan PAR-Packer 1.064 main/find_dll(). |
| 39 | { |
| 40 | my ($dll_glob) = @_scip-perl cpan PAR-Packer 1.064 main/`@_`.; |
| 41 | |
| 42 | # look for $dll_glob |
| 43 | # - in the same directory as the perl executable itself |
| 44 | # - in the same directory as gcc (only useful if it's an absolute path) |
| 45 | # - in PATH |
| 46 | my ($dll_path) = mapscip-perl cpan PAR-Packer 1.064 main/map(). { File::Glob::bsd_globscip-perl cpan PAR-Packer 1.064 File/Glob/bsd_glob().(File::Spec->catfilescip-perl cpan PAR-Packer 1.064 File/Spec/catfile().($_scip-perl cpan PAR-Packer 1.064 main/$_., $dll_glob)) } |
| 47 | dirnamescip-perl cpan PAR-Packer 1.064 main/dirname().($^Xscip-perl cpan PAR-Packer 1.064 main/`$^X`.), |
| 48 | dirnamescip-perl cpan PAR-Packer 1.064 main/dirname().($Configscip-perl cpan PAR-Packer 1.064 main/`%Config`.{cc}), |
| 49 | File::Spec->pathscip-perl cpan PAR-Packer 1.064 File/Spec/path().(); |
| 50 | return $dll_path; |
| 51 | } |
| 52 | |
| 53 | 1; |