6 Usage: makeliblinks libautodir targetdir
7 where libautodir is the architecture-dependent auto directory
8 (e.g. $Config::Config{archlib}/auto).
13 my ($libautodir, $targetdir) = @ARGV;
15 # Calculate relative path prefix from $targetdir to $libautodir
19 for ($up = 0; substr($to, 0, length($from)) ne $from; $up++) {
21 [^/]+ (?# a group of non-slashes)
22 /* (?# maybe with some trailing slashes)
23 $ (?# at the end of the path)
26 return (("../" x $up) . substr($to, length($from)));
29 my $relprefix = relprefix($libautodir, $targetdir);
31 my ($dlext, $lib_ext) = @Config::Config{qw(dlext lib_ext)};
34 if (/\.($dlext|$lib_ext)$/o) {
36 my $name = $File::Find::name;
37 if (substr($name, 0, length($libautodir) + 1) ne "$libautodir/") {
38 die "directory of $name doesn't match $libautodir\n";
40 substr($name, 0, length($libautodir) + 1) = '';
41 my @parts = split(m(/), $name);
42 if ($parts[-1] ne "$parts[-2].$ext") {
43 die "module name $_ doesn't match its directory $libautodir\n";
46 my $libpath = "$targetdir/lib" . join("__", @parts) . ".$ext";
47 print "$libpath -> $relprefix/$name\n";
48 symlink("$relprefix/$name", $libpath)
49 or warn "above link failed with error: $!\n";
53 find(\&link_if_library, $libautodir);