| 1 | package Affix::Platform::Cygwin v1.4.0 { | ||
| 2 | use v5.40; | ||
| 3 | use DynaLoader; | ||
| 4 | use parent 'Affix::Platform::Unix'; | ||
| 5 | use parent 'Exporter'; | ||
| 6 | our @EXPORT_OK = qw[find_library]; | ||
| 7 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | ||
| 8 | |||
| 9 | sub find_library ( $name, $version //= () ) { | ||
| 10 | return $name if -f $name; | ||
| 11 | my $base = $name; | ||
| 12 | $base =~ s[^lib][]; | ||
| 13 | return 'cygwin1.dll' if $base eq 'c' || $base eq 'm'; | ||
| 14 | for my $file ( "cyg$base.dll", "lib$base.dll", "$base.dll" ) { | ||
| 15 | my $path = DynaLoader::dl_findfile($file); | ||
| 16 | return $path if $path; | ||
| 17 | for my $dir (qw[/usr/bin /usr/lib /bin]) { | ||
| 18 | my $cand = "$dir/$file"; | ||
| 19 | return $cand if -f $cand; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | my $path = DynaLoader::dl_findfile("-l$base"); | ||
| 23 | return $path if $path; | ||
| 24 | return Affix::Platform::Unix::find_library( $name, $version ); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | 1; |